how would I rotate an object around an object, such as rotating an object in circles around another object? Preferably using GL.Rotate and as little math as possible!
Asked
Active
Viewed 1,150 times
1
-
Translate, rotate and translate back. – John Alexiou Apr 30 '21 at 23:53
-
When you add a tag, it is not necessary to also repeat it in the title and the post body. Just adding the tag is enough. The redundancy is just noise. – Ken White May 01 '21 at 00:43
1 Answers
1
GL.Rotate
defines a rotation matrix, that rotates a round 0.0. If you want to rotate around a pivot (pivotX
, pivotY
) you have to:
- Translate the object so that the pivot point is moved to (0, 0).
- Rotate the object.
- Move the object so that the pivot point moves in its original position.
e.g.:
GL.Translate(pivotX, pivotY, 0); // 3. move back
GL.Roatate(angle, 0, 0, 1); // 2. rotate
GL.Translate(-pivotX, -pivotY, 0); // 1. move pivot to (0, 0)

Rabbid76
- 202,892
- 27
- 131
- 174