A Flash Developer Resource Site

# Thread: Inverted trig functions in Flash 5?

1. Does anyone know how to do inverted trigonometry functions in Flash 5? I mean like the ones that say cos -1 etc. on calculator buttons?

I need this do work out some angles.

2. I just read some notes by Colin Moock about Trig functions.
See if this helps you.

http://www.moock.org/webdesign/lectures/ff2001sfMotion/

3. Yeah, I believe you can use the math objects Math.atan (arctangent), Math.acos (arccosine) and Math.asin (arcsin).

4. ## ignore me! I can't do math!

forget and forgive this post. I'm completely incompetent in Math!

[wrong]I don't think pyez is looking for arc-trig functions, but for an inverse trig funtion -- sin^-1 and so on.

the only one available is Math.atan2, or tan^-1. The arguments are y,x:

Math.atan2(y,x);
[/wrong]

So for instance if you want to return the angle of the mouse location from the center of a movieclip:

Math.atan2(mc._ymouse, mc._xmouse);
[Edited by LuxFX on 03-27-2001 at 04:28 PM]

5. It's been a lot of years since I did trig, and Flash 5 is making me use some previously forgotten grey matter, but I thought that f(x)=sin^-1(x) was the same as f(x)=arcsin(x). Perhaps I have some misfiring neurons, but that's what I remember.

Am I wrong? And if so, how?

6. ## inverse trig

I can't decipher why Math.atan(y/x) is different from Math.atan2(y,x) but I've been using the latter because the results are right for some reason.

(cos^-1) and (arccos) are used interchangably. The cunfusion with cos^-1 is this: cos(x)^-1 = 1/cos(x); whereas cos^-1(x) is just faster than writing arccos. This is how we did it when I went to school, but that was a while ago.

7. Originally posted by thewiz1972
It's been a lot of years since I did trig, and Flash 5 is making me use some previously forgotten grey matter, but I thought that f(x)=sin^-1(x) was the same as f(x)=arcsin(x). Perhaps I have some misfiring neurons, but that's what I remember.

Am I wrong? And if so, how?
sorry dude, I'm the one with the seriously misfiring neurons. In fact, they somehow convinced me I was competent in math again.

Rrr...I used to be GOOD at math!

8. hehe
Don't worry about it. I just wish I could remember everything I learned in math (and physics).

9. are you kidding? I'd settle for remembering anything at this point!

10. I did A level pure maths at school (and got a good grade too!)... but I'd settle for remembering what the school looked like right about now!

When did I get that old?....

A

11. ## Re: inverse trig

Originally posted by ironmallet
I can't decipher why Math.atan(y/x) is different from Math.atan2(y,x) but I've been using the latter because the results are right for some reason.
I didn't know this until too long ago also...the difference is that "atan2" will check the quadrant the terminal side of the angle is in and return an angle in standard position. However, "atan" only returns the reference angle with the x-axis. For example:
Code:
```   _   y-axis
|\    |
\   |
\  |
\ |
_______\|_________ x-axis```
In a trigonometry class the above angle would be measured from the x-axis right of the y-axis, counter-clockwise to the arrow. However, arctangent, by definition, only returns principal values, which is between -pi/2 and pi/2. Therefore arctangent, used strictly, cannot return the angle of the above picture. However, it returns the reference angle which is the angle made up with the x-axis to the right of the y-axis measured clockwise to the arrow. You then just subtract that angle from pi.

Anyway, in conclusion...the "atan2" function would return the entire angle measured counter-clockwise whereas "atan" would only return the reference angle measure clockwise.

Good luck.

12. atan2 ?!?!
I'm pretty good at math (and physics), and Ive had to make a couple of if statements the whole time to get the right quadrant.
I feel stupid now...why the HELL didnt I know that before?!
thanks guys, this will make some of my work a lot easier.
[Edited by PsychoFlasher on 03-27-2001 at 05:51 PM]

13. I didn't know that either but it's pretty damn helpful now that I do. Thanks ahab.

14. dudes, I spent about two hours browsing maths sites for the quadrant approach, only to find a tiny reference to Math.atan2 about 30 minutes after I'd built the (horrific) 'if' nest.

Life sure can be funny.

But I still wanted to beat my mouse with my keyboard.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap