atan2 formula..

Sep 21, 2008 at 12:30am
Okay; For reasons, I'd like to know the formula for atan2.

Thanks in advance.
Sep 21, 2008 at 1:08am
Good luck. It's usually implemented in hardware. I'm still trying to find how to manually calculate the sine of an angle.
Sep 21, 2008 at 1:20am
Sep 21, 2008 at 1:59am
Cool, thanks. I knew how to do sine and the like but I was unsure about atan2.
Sep 21, 2008 at 2:02am
The sine section in Wikipedia doesn't actually explain how to calculate the length of the opposite side, it just says sine is the ratio between that length and the hypotenuse.
Neither does the other link.

EDIT: Never mind. Taylor polynomial of degree 7 ftw.
Last edited on Sep 21, 2008 at 2:16am
Sep 21, 2008 at 7:17pm
You've lost me with the Taylor series.

The sine is nothing more than the ratio of two scalars: opposite / hypotenuse. Sine will not give you those values --you have to know them in advance. The inverse sine gives you the value of the angle (since sin-1 is not bijective, the domain and range are usually restricted to [-1,1] and [-π/2,π/2]). The inverse sine is usually calculated in computers using a lookup table.

What exactly is it that you are trying to calculate?
Sep 21, 2008 at 7:27pm
What I'm looking for is a way to, for a hypotenuse of 1 and an angle x, calculate the lengths of the adjacent side and the opposite side.
This gives me a pretty close approximation:
1
2
3
double taylor7(double x){
	return x - pow(x,3)/6 + pow(x,5)/125 - pow(x,7)/5040;
}
Last edited on Sep 21, 2008 at 8:20pm
Sep 21, 2008 at 9:06pm
Given:

/|
/ |
1/ | y
/ _|
/) | |
A-----+
x


sin A = y/1 --> 1 × sin A = y --> sin A = y

cos A = x/1 --> 1 × cos A = x --> cos A = x

I still don't think I understand what it is that you are trying to compute.
Sep 21, 2008 at 9:25pm
I think we're saying the same thing in two different languages, while both speaking English at the same time.

I know about sin() and I know that I can get that value from sin(). BUT what I was interested in was a function that gave equivalent results. I.e. calculate the sine without using sin(). A replacement for sin(), so to speak.
I don't think there's such a mathematical function, however.
Topic archived. No new replies allowed.