-
[RESOLVED] Angle from 0,0 to x,y
As a beginner I'm thrashing out an application and I want to figure most of it out on my own. But being a math dork I can't figure out the equation (or function) that yields the angle of the line from 0,0 to the mouse x,y.
I want to click and drag the minute hand around a clock face.
Thanks.
-
When in doubt ask
Please see the attached FLA (F8).
Hope this is what you asked.
Last edited by Eager Beaver; 10-25-2007 at 02:01 PM.
<signature removed by admin>
-
Thank you
Nice, just what I was looking for.
This is the part that is a little mysterious to me. Why choose "th" as a variable name? I guess I should pull a trig text and brush up on this. The whole radian to angle thing confuses me.
th=Math.atan2(yl,xl);
an=th*180/Math.PI;
Now to struggle with the rest.
-
When in doubt ask
For calculating the trigonometric functions FLASH requires that the angle should be in radians (th).
0 radians=0 degrees.
PI (3.141592654) radians=180 degrees.
For using the _rotation function FLASH requires that the angle should be in degrees (an).
an=th*180/Math.PI;
I hope I could it make clear, otherwise please read a good book on trigonometry, and flash programming.
<signature removed by admin>
-
Eager Beaver-
Creative Action was confused by your variables' names. i assume by 'th' you're truncating 'theta' and by 'an' you're truncating 'angle.' It never hurts to be overly descriptive in your variable name- especially when the goal is to help someone out...
-
When in doubt ask
Thank you for your suggestion.
Yes, you are correct:
th==theta (radians).
an==angle (degrees).
There are many abbreviations in the net nowadays.
LOL: Laugh Out Loud.
OMG: Oh My God.
ASAP: As Soon As Possible.
And so on.
<signature removed by admin>
-
 Originally Posted by Eager Beaver
Thank you for your suggestion.
Yes, you are correct:
th==theta (radians).
an==angle (degrees).
There are many abbreviations in the net nowadays.
LOL: Laugh Out Loud.
OMG: Oh My God.
ASAP: As Soon As Possible.
And so on.
abbreviation has its place...
-
When in doubt ask
I think you prefer to pick up an argument on this subject.
I thought there were no rules not to assign names such as, th, an, to variables.
I have already agreed with your suggestion.
Last edited by Eager Beaver; 10-10-2007 at 02:18 AM.
<signature removed by admin>
-
 Originally Posted by Eager Beaver
I think you prefer to pick up an argument on this subject.
no- just lulz
 Originally Posted by Eager Beaver
I thought there were no rules not to assign names such as, th, an, to variables.
of course not- but if you want your code to be comprehensible, it's a different story. i mean why th? why stop there? why not t?
 Originally Posted by Eager Beaver
I have already agreed with your suggestion.
the above would indicate otherwise, but time will tell!
-
When in doubt ask
 Originally Posted by newblack
no- just lulz
of course not- but if you want your code to be comprehensible, it's a different story. i mean why th? why stop there? why not t?
the above would indicate otherwise, but time will tell!
Yes you can use t or th or the or thet or theta, and the FLA works without any problem.
I have already agreed with your suggestion to use variable names theta and angle so that Creative Action understands the CODE with ease.
<signature removed by admin>
-
Thank you Eager Beaver and newblack, th being Theta is exactly what I was looking for. The other abreviations were apparent to me. And I plead guilty to needing to read a Trig Text. Can you suggest a really good AS2 book? I'm considering Lynda.coms AS3 DVD, what do you think? Basically, I am always guilty of coming up with some overly complex project and then beating my head against it until I learn the program. My very first 3D modeling project was a pirate ship with everything.
-
When in doubt ask
I suggest for flash8, and AS2, flash bible.
I don't know AS3.
<signature removed by admin>
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
|