# Rotate point around line

This topic is 3630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

If I have a line defined by two points, how do I rotate a point around that line by X degrees?

##### Share on other sites
Create the rotation vector by subtracting one point from the other (and normalize).

Then use the Axis Angle rotation solution.

##### Share on other sites
In addition, you need to make a correction step, since the axis of the axis/angle rotation is defined to pass through [0 0 0]. Hence, choose any point on the line, e.g. one of the both directly given points, as temporary origin. If p1 and p2 are the 2 given points, then a transformation like
T(p1) * R(p2-p1,alpha) * T(-p1)
is suitable, where T denotes a translation matrix and R the rotation matrix as suggested by Mike nl. (Notice please that I've used column vectors (e.g. OpenGL) in the formula above; reverse the order if you use row vectors (e.g. D3D) instead.)

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631778
• Total Posts
3002310
×