Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Angle to coordinates

How can coordinates be changed according to the current angle?



MySprite.Angle = 90; // (0-360)

MySprite.UpdateVelocity();



Can someone refer a book/tutorial on velocity/angle?


Comments

  • : How can coordinates be changed according to the current angle?

    :

    : MySprite.Angle = 90; // (0-360)

    : MySprite.UpdateVelocity();

    :

    : Can someone refer a book/tutorial on velocity/angle?



    Angle = Direction you want to go (0-360)

    M = Magnitude (how far you want to go in that direction)



    x = M*cos(angle);

    y = M*sin(angle);



    angle = arctan (y/x);



    -Xotor-


  • Don't you need to convert the degrees into radians?



    angle = angle between 0 and 360

    M = magnitude, speed or force (like xotor said)



    new_y = M*sin(angle*PI/180)

    new_x = M*cos(angle*PI/180)



    just a thought...



    / pelle


    URL:home.swipnet.se/wizard

  • Hey Pelle



    When using ArcTan you will *get* result

    in radians, and therefor you can just

    push it in to the other trig functions such

    as sin, cos.. etc. which expect the

    argument to be in RADIANs.



    bye


  • : Don't you need to convert the degrees into radians?



    Dunno, actually I wasn't referring to the cos(), etc. functions, just cosine in general. I don't normally use the trig functions().



    -Xotor-




Sign In or Register to comment.