Rotate a 2d point around another point?

Posted on 2009-04-22
Last Modified: 2012-06-21

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,

Question by:DJ_AM_Juicebox
    LVL 26

    Expert Comment

    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.
    LVL 84

    Accepted Solution

    x = pt1.x + (pt2.x-pt1.x)*cos(17*pi/180) - (pt2.y-pt1.y) * sin(17*pi/180)
    y = pt1.y + (pt2.y-pt1.y)*cos(17*pi/180) + (pt2.x-pt1.x) * sin(17*pi/180)
    LVL 15

    Expert Comment

    I hope this link will be helpful:
    LVL 20

    Expert Comment

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! How to Know You are Making a Difference at EE In August, 2013, one …
    This article seeks to propel the full implementation of geothermal power plants in Mexico as a renewable energy source.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now