Link to home
Start Free TrialLog in
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

asked on

Rotate a 2d point around another point?

Hi,

I have two 2d points. I want to rotate one point around the other. How do I do this? Here is my input:

    Point pt1 = (100, 100);
    Point pt2 = (100, 130);

    Now rotate pt2 around pt1 by 17 degrees.

Yeah I basically need that to work with variable pt1 and pt2 and degrees of 0 to 360. Not sure how to do this,

Thanks
Avatar of aburr
aburr
Flag of United States of America image

Can you translate and rotate your coordinate system?
If so, translate your coordinate system so that pt1 = (0,0). Pt2 then = (0,30)
Rotate coord system 17 degrees. Translate coord system back to original location. You are done.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hey DJ_AM_Juicebox,

in addition, do you need the generalised matrix-form? its

m = m_trans_pt1 * m_rot(phi) * m_trans_pt1_inv

basically its the same as the above comments say..
tell us if you need help creating those matrices ..


ike