dcsimg
A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: [RESOLVED] Angle from 0,0 to x,y

  1. #1
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61

    resolved [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.

  2. #2
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    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>

  3. #3
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61

    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.

  4. #4
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    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>

  5. #5
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    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...

  6. #6
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    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>

  7. #7
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    Quote 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...

  8. #8
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    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>

  9. #9
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    Quote Originally Posted by Eager Beaver
    I think you prefer to pick up an argument on this subject.
    no- just lulz
    Quote 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?
    Quote Originally Posted by Eager Beaver
    I have already agreed with your suggestion.
    the above would indicate otherwise, but time will tell!

  10. #10
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    Quote 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>

  11. #11
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61
    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.

  12. #12
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center