![]() |
vec<x/y>, sin, cos
What does vecx/vecy, sin, and cos do/mean??
|
Vectors.
Level of Math Education Suggested: 10 - 11th Grade Calculus |
darn im only at an 8th grader's math edu :(
so how about cos and sin? |
im 11 xD i only know algebra and can swear in 3 differant languages.....
|
vecx/y and sin cos are simple to learn with Graal. I learned that stuff way back in 7th grade on my own(I honestly don't know the true mathmatics behind it... though we did start getting into sine/cosine in Geometry).
vec stands for vector, in which you're getting the vectorx/y of a direction. Basically, vecx and vecy are like the following arrays: vecx={0,-1,0,1}; vecy={-1,0,1,0}; It's generally used to get the movement of a direction. x=vecx(player.dir) y=vecy(player.dir) if your direction was 3, would return (1,0). You can also multiply it like so: player.x+=vecx(player.dir)*.5 player.y+=vecy(player.dir)*.5 Which would move the player .5 tiles in their direction. Sin/cos are kind of the same(in principle in Graal, I'm sure I will have the math guru's all over me for this post), in which it gets the 'movement' of an angle. |
My suggestion applied to both subjects.
|
I honestly wouldn't dwell on the whole "I'm not in a high enough grade," thing. Best thing to do is find scripts that use the functions and pick them apart(this was a lot easier to do way back than it is now, as offline levels had a lot of scripts, and they weren't as overwhelming as they are now adays). You'll soon learn how they work by trial and error and be impressed with yourself. I learned a lot of stuff in Graal before I was ever taught it in a class, such as coordinates(a Graal level is just like a huge graph paper), arrays, problem solving and algorithms' :)
I mean, it might not apply the same in class, but you'll learn how to use them in Graal, and you won't feel completely out of the loop when you start learning them in school, unlike just about everyone else in your class. |
We didnt learn cos/sin in school yet, though I already know how it works. You can really learn alot through Graal, but I guess I cannot help you understand it, because my english is not enough for such things ;P
|
Ok, some basic things I learned from playing with sin and cos in graal:
They are from the math term 'trigonometry' where radians is used instead of degrees. Radians goes from 0 to PI*2. For example, if you want your player to move in the direction that the player is facing, do this: PHP Code:
Cos belongs to the x-axis Sin belongs to the y-axis This is some simple basic stuff I first learned about cos and sin when I played around with it.. so I don't know if all above is fully correct, so if I'm not, someone else can correct me ;o |
Quote:
But really, I forgot all the trig I learned in Geometry and Algebra 2. >.< |
Quote:
|
Quote:
Quote:
|
sin and cos are properties of angles. If you have a right triangle such that angle a is opposite of side A, b opposite of B, and c, the right angle, opposite of the hypotenuse, C, sin(a) = A/C, cos(a) = B/C, sin(b)=B/C, cos(b)=A/C, sin(c)=1, and cos(c)=0.
Though I'm sure you haven't learned it, trigonometry is essential to spherical, polar, and cylindrical coordinate systems. Vector calculations rely heavily on trigonometry, as well as 3D graphics. They're basically only ever used in graal for pretty light effects and movement systems. |
Quote:
|
Quote:
|
Ya, you can do that. Or you can also specify a few check points (I did this once withe sword.gani, I opened the gani up in Graalshop and translated the pixel position of the tip of the sword into tiles for each frame, and did checks there.
|
That seems like a good alternative. However, I plan to use weapons which vary in length. It'd look silly if I had a large bamboo pole (there's a japanese word I'm trying to think of) that only did damage at the end of the pole. Obviously, I'm looking more towards doing damage if you're in the area of the sector rather than on the circumference.
|
You can define the area of a circle you're willing to check by specifying a point A with an angle and radius, then check all along a circle until getting to point B, which would also be an angle with a radius. Something like:
PHP Code:
|
Grades of Math are different in every school so you can't really say "10th grade math".
|
I got taught about basic trig, including cos/sin/tan functions, at around 13 years old and was a recurring subject until I'd finished school, which was about 3 months ago or so.
As soon as it comes up once in your syllabus, it's more than likely to reoccur in the future. For example, I'm taking Maths at Sixth-Form (which is like Year 12 and 13 of school) and trigonometry makes up a good part of it. |
Quote:
|
Quote:
|
Quote:
|
Quote:
Nothing is stopping you from learning though :P |
Quote:
|
Quote:
|
Quote:
|
Quote:
|
| All times are GMT +2. The time now is 04:13 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.