
j00 r teh pwnz0r3d
How do I set angle measure depending on x velocity and y velocity?
Can someone help me with this???

It would be helpful if you posted some code or more explanation.
Perhaps this will start you off:
angleInRadians = Math.atan2 (y, x);
angleInDegrees = angleInRadians * 180 / Math.PI;
This is the basic process of turning x and y coordinates into an angle.
Hope that helps.
Last edited by robertpenner; 11182002 at 09:22 PM.

Hi Robert,
I might be a little confused here but Keith Peters says the following in his tutorial (http://www.bit101.com/tutorials/3Drotation.html):
I'm not going to go into an explanation of the trigonometry involved here. It's actually pretty simple, but I'll leave that for another tutorial. Just know that this works. A very important point you need to know is that "angle" needs to be in radians. This is a different system from the 360 degrees that you might be used to. Since it's a lot easier to think in degrees, you'll need to convert them. The formula for that is:
rad=degree*Math.PI/180;
Is that not the opposite of your formula? Please help me to clarify.
Could you also explain the differences between these: tan, atan, atan2
Thanks
BTW  your work is pretty awesome.
someday i'll be a kickass flash developer  you'll see.

yes, it is opposite. because he is converting in the opposite direction.
radians = degrees*Math.PI/180;
degrees = radians*180/Math.PI;

as far as tan.
take a right triangle. pick one of the non90 angles. you have three sides. the long side is the hypotenuse. then you have the side opposite your angle and the side adjacent to your angle. if you divide the length of the opposite side by the adjacent, you will get a number. that is the tan of that angle. it doesn't matter how big the triangle is. as long as you have that angle, you will get that number when you divide those two sides.
so... Math.tan(angle) gives you that number.
Math.atan(number) goes in the opposite direction. you take a ratio by dividing those two numbers, and it will give you the angle (in radians of course).
Math.atan2(y, x) handles at least one problem with atan. if you just divide the sides and plug the number in, you will get an angle, but you don't know which quadrant the angle is in. say you have y=1 and x=2. then another example of y=1 and x=2. 1/2 is the same as 1/2. they both give you .5 and atan will give you the same angle. but they are different angles. when you plug in y and x into atan2, it takes that into account and gives you the correct angle.

Keith, thanks for trying to explain. As you may have guessed, I'm not a Math fundi. I've had a look at Flash Math Creativity reviews  most are positive. I've also had a look at Flash MX Studio which also has a chapter on Trig.
So who better to ask than the source itself right? Which book would you recommend for someone like myself  amateur Flasher who wants to beef up his skills. Is Flash Math Creativity too advanced? I mean does the book explain basic trig and explain what each calculation does, etc, etc?
Perhaps you know of a novice to intermediate "Flash+Math" book that may offer some hope.
Thanks again for your time (which I know is very limited).
someday i'll be a kickass flash developer  you'll see.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
