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

x
Solved

# Rotate a 2d point around another point?

Posted on 2009-04-22
Medium Priority
1,211 Views
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
0
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.
0

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)
0

LVL 15

Expert Comment

ID: 24220884
http://en.wikipedia.org/wiki/Rotation_(mathematics)
0

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

ike
0

## Featured Post

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
Course of the Month20 days, 8 hours left to enroll