0
New Here
,
/t5/animate-discussions/math-atan2-function-explanation/td-p/750986
Mar 07, 2009
Mar 07, 2009
Copy link to clipboard
Copied
Hello guys
This is a piece of code from AS3 Making Things Move
I tried to understand what actually atan2 does?
Please explain
Hopefully, ill get help from here :)
Thanks in advance
This is a piece of code from AS3 Making Things Move
I tried to understand what actually atan2 does?
Please explain
Hopefully, ill get help from here :)
Thanks in advance
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Community Expert
,
Mar 07, 2009
Mar 07, 2009
that's pretty accurate.
if you remember from trigonometry, the tangent of an angle (theta) formed by the x-axis and a line from (0,0) to (x,y) is y/x. ie, tan(theta) = y/x.
and the arctan is just the inverse: given the number y/x, what's the angle? ie, arctan(y/x) = theta.
in mos' code (dx,dy) can be considered a point on a cartesian coordinate system. if you draw a line from the (0,0) to (dx,dy) that line intersects the x-axis and forms an angle with the x-axis. that angle is the inverse ta...
if you remember from trigonometry, the tangent of an angle (theta) formed by the x-axis and a line from (0,0) to (x,y) is y/x. ie, tan(theta) = y/x.
and the arctan is just the inverse: given the number y/x, what's the angle? ie, arctan(y/x) = theta.
in mos' code (dx,dy) can be considered a point on a cartesian coordinate system. if you draw a line from the (0,0) to (dx,dy) that line intersects the x-axis and forms an angle with the x-axis. that angle is the inverse ta...
LEGEND
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750987#M15300
Mar 07, 2009
Mar 07, 2009
Copy link to clipboard
Copied
If this is a trigonometry wondering, you can look up atan2
via Google and try to find an explanation that makes sense to you
(it can be hard to explain in simple terms by words alone). Here's
a link to what Wikipedia has to say:
http://en.wikipedia.org/wiki/Atan2
In the simplest of terms for the code shown, what it's doing is telling you the angle (in radians) of the mouse relative to the x and y location of an arrow (likely the axis of rotation).
In the simplest of terms for the code shown, what it's doing is telling you the angle (in radians) of the mouse relative to the x and y location of an arrow (likely the axis of rotation).
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
ARaza
AUTHOR
New Here
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750992#M15305
Mar 09, 2009
Mar 09, 2009
Copy link to clipboard
Copied
Thanks for your replies,
I tried to explain what i learnd from ur discussion
Please correct me if i am wrong
Due to u guys, i could learn these difficult things
Thanks once again :)
I tried to explain what i learnd from ur discussion
Please correct me if i am wrong
Due to u guys, i could learn these difficult things
Thanks once again :)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
ARaza
AUTHOR
New Here
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750988#M15301
Mar 07, 2009
Mar 07, 2009
Copy link to clipboard
Copied
Many Thanks :)
Pretty bad with Math
so u have to tolerate me for a while.
I mean, how dy and dx forms a triangle? are not they at the same point :/
this is where im struck !
can u jst visualize this things in words?
Pretty bad with Math
so u have to tolerate me for a while.
I mean, how dy and dx forms a triangle? are not they at the same point :/
this is where im struck !
can u jst visualize this things in words?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750989#M15302
Mar 07, 2009
Mar 07, 2009
Copy link to clipboard
Copied
I'm no math expert either, so if I'm off in this attempt, a
more accurate description is welcome. The part I won't be able to
explain is the atan2 bit itself.
If you look at dx and dy, they are not points, but the distance between two points. So you have an x-related distance of dx, and a y-related distance dy (the "d" is also often referred to as "delta", or "the change in").
When you take the x-length and intersect it with the y-length, you end up with a right angle. The rest is where I best not tread trying to explain, just accept that the atan2 relates to those lengths, possibly providing the angle of a line that would join them from the 0,0 axis to the opposite corner were you to make a rectangle of it.
While I prefer to not drop names, there is one person I can think of in these forums that likely understands this like we understand tomorrow is Sunday. Maybe he'll stop in and give it a shot.
If you look at dx and dy, they are not points, but the distance between two points. So you have an x-related distance of dx, and a y-related distance dy (the "d" is also often referred to as "delta", or "the change in").
When you take the x-length and intersect it with the y-length, you end up with a right angle. The rest is where I best not tread trying to explain, just accept that the atan2 relates to those lengths, possibly providing the angle of a line that would join them from the 0,0 axis to the opposite corner were you to make a rectangle of it.
While I prefer to not drop names, there is one person I can think of in these forums that likely understands this like we understand tomorrow is Sunday. Maybe he'll stop in and give it a shot.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750990#M15303
Mar 07, 2009
Mar 07, 2009
Copy link to clipboard
Copied
that's pretty accurate.
if you remember from trigonometry, the tangent of an angle (theta) formed by the x-axis and a line from (0,0) to (x,y) is y/x. ie, tan(theta) = y/x.
and the arctan is just the inverse: given the number y/x, what's the angle? ie, arctan(y/x) = theta.
in mos' code (dx,dy) can be considered a point on a cartesian coordinate system. if you draw a line from the (0,0) to (dx,dy) that line intersects the x-axis and forms an angle with the x-axis. that angle is the inverse tangent (arctan) of dy divided by dx (dy/dx).
flash, in addition to having a Math.atan(y/x) function also has an atan2 function Math.atan2(y,x) that accepts two parameters so no division is needed.
if you remember from trigonometry, the tangent of an angle (theta) formed by the x-axis and a line from (0,0) to (x,y) is y/x. ie, tan(theta) = y/x.
and the arctan is just the inverse: given the number y/x, what's the angle? ie, arctan(y/x) = theta.
in mos' code (dx,dy) can be considered a point on a cartesian coordinate system. if you draw a line from the (0,0) to (dx,dy) that line intersects the x-axis and forms an angle with the x-axis. that angle is the inverse tangent (arctan) of dy divided by dx (dy/dx).
flash, in addition to having a Math.atan(y/x) function also has an atan2 function Math.atan2(y,x) that accepts two parameters so no division is needed.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750991#M15304
Mar 07, 2009
Mar 07, 2009
Copy link to clipboard
Copied
Thanks for stopping in... I was hoping you might. If I
remembered much of anything from trig, I might have stood a chance
at providing the proper explanation, but I'd still probably have to
blow the dust off some old textbooks.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
ARaza
AUTHOR
New Here
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750993#M15306
Mar 09, 2009
Mar 09, 2009
Copy link to clipboard
Copied
Sorry, these right side of the monitor got messed (containing
= symbols)
but else is quite clear.
Thanks in advance
but else is quite clear.
Thanks in advance
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750994#M15307
Mar 09, 2009
Mar 09, 2009
Copy link to clipboard
Copied
no.
the x-axis is a horizontal line that runs through the origin (0,0).
draw a line from 0,0 to Mx,My
draw a line from 0,Mx to Mx,My
that forms the relevant triangle. the relevant angle is the angle formed by the line from 0,0 to Mx,My and the x-axis.
the x-axis is a horizontal line that runs through the origin (0,0).
draw a line from 0,0 to Mx,My
draw a line from 0,Mx to Mx,My
that forms the relevant triangle. the relevant angle is the angle formed by the line from 0,0 to Mx,My and the x-axis.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
ARaza
AUTHOR
New Here
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750995#M15308
Mar 09, 2009
Mar 09, 2009
Copy link to clipboard
Copied
Is this right now?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
ARaza
AUTHOR
New Here
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750996#M15309
Mar 10, 2009
Mar 10, 2009
Copy link to clipboard
Copied
@kglad
Please Confirm it
As i cant trust on my personal judgment !
Thanks
Please Confirm it
As i cant trust on my personal judgment !
Thanks
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750997#M15310
Mar 10, 2009
Mar 10, 2009
Copy link to clipboard
Copied
1- looks ok
2- looks more like a line from Mx,0 to Mx,My
2- looks more like a line from Mx,0 to Mx,My
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
ARaza
AUTHOR
New Here
,
/t5/animate-discussions/math-atan2-function-explanation/m-p/750998#M15311
Mar 10, 2009
Mar 10, 2009
Copy link to clipboard
Copied
Thanks, ill come up with some sin cosin questions too
hopefully, ull help in those matters too 🙂
hopefully, ull help in those matters too 🙂
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/animate-discussions/math-atan2-function-explanation/m-p/750999#M15312
Mar 10, 2009
Mar 10, 2009
Copy link to clipboard
Copied
you're welcome,
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

