degrees = 270;
angle = degrees * (Math.PI / 180);
cos = Math.cos(angle);
How can I convert back to angle??
you take the cosine inverse or the arccosine.
in general:
If $\displaystyle \cos x = y$
then $\displaystyle x = \cos^{-1} y = \arccos y$
is this what you want?
maybe you should tell me the specific problem, what are you calculating and what form do you want the answer in?
I will try to explain. Please forgive misuse of terms. I am working on a drawing program using Macromedia Flash. I believe the Flash uses Cartesian turning clockwise. I am working with x,y coordinates on a unit circle. x1, y1 (center point) and x2, y2 (outer point) are known values. How do I calculate the radians or degrees for the angle created by these two points??
for example:
x1 = 100
y1 = 100
x2 = 300
y2 = 300
Angle is 45 degrees.
x1 = 100
y1 = 100
x2 = 100
y2 = 0
Angle is 270 degrees.
I just don't know how to calculate the value mathmatically. Result in radians or degrees should work for me.
Thanks
First preform a parallel coordinate transfort.
$\displaystyle x \mapsto x-100$
$\displaystyle y\mapsto y-100$
So that the circle is at the center.
Now if a circle is at the center with radius $\displaystyle r>0$ and $\displaystyle (x,y)$ is a point on this circle then:
$\displaystyle x=r\cos \theta \mbox{ and }y=r\sin \theta$
Where $\displaystyle \theta$ is the angle created conterclockwise. (That is what positive direction is).
Say you have a circle centered at $\displaystyle (2,1)$ then its equation is:
$\displaystyle (x-2)^2+(y-1)^2 = r^2$
Parallel transform means you replace $\displaystyle x-2$ by $\displaystyle x$ (which just means you move everything to the left 2 units) and $\displaystyle y-1$ by $\displaystyle y$ (which just means you move everything to the left 1 unit). That gives $\displaystyle x^2+y^2=r^2$. The reason is that this is a much easier circle to deal with and since the transform was parallel the angle measurements stay the same. Basically all you are doing is relabeling the origin of the coordinate axes to be at the center of the circle.