Sunday, March 27, 2011

Converting polar coordinates to rectangular coordinates

Convert angle in degrees to a point

How could I convert an angle (in degrees/radians) to a point (X,Y) a fixed distance away from a center-point.

Like a point rotating around a center-point.

Exactly the opposite of atan2 which computes the angle of the point y/x (in radians).


Note: I kept the original title because that's what people who do not understand will be searching by!

From stackoverflow
  • Let the fixed distance be D, then X = D * cos(A) and Y = D * sin(A), where A is the angle.

  • t = angle
    r = radius (fixed distance)
    
    x = rcost
    y = rsint
    
  • What PolyThinker said.

    Also, if you need the distance from the origin, it's sqrt(x^2 + y^2).

  • If center-point (Xcp, Ycp) isn't the origin you also need to add it's coordinates to (X,Y) i.e. X = Xcp + D * cos(A) and Y = Ycp + D * sin(A)

0 comments:

Post a Comment