[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Rotate a 2d point around another point?

Posted on 2009-04-22
Medium Priority
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 27

Expert Comment

ID: 24211962
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 85

Accepted Solution

ozo earned 2000 total points
ID: 24211988
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

ID: 24220884
I hope this link will be helpful:
LVL 20

Expert Comment

ID: 24231475
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 ..


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Complex Numbers are funny things.  Many people have a basic understanding of them, some a more advanced.  The confusion usually arises when that pesky i (or j for Electrical Engineers) appears and understanding the meaning of a square root of a nega…
Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

868 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