Welcome to Phrogram Sign in | Join | Help
in Search


Calculating an Angle from a Vector

Last post 04-26-2008, 1:04 PM by The Dragon Rider. 0 replies.
Sort Posts: Previous Next
  •  04-26-2008, 1:04 PM 6580

    Calculating an Angle from a Vector

    Many users may find this function useful:

    http://phrogram.com/forums/permalink/6559/6579/ShowThread.aspx#6579

    I use this function to point a Polygon at a Point ( in this case, the mouse ):

     Var RotationVector as Vector

     RotationVector.X = Polygon.GetCenter().X - Mouse.X
     RotationVector.Y =  Polygon.GetCenter().Y - Mouse.Y
     Polygon.Rotation = AngleFromVector( RotationVector.X, RotationVector.Y ) 

     

    You may need to add or subtract a few degrees, depending on the polygon's shape. Tell me if you find any bugs.

    Happy Phrogramming! 

View as RSS news feed in XML