I am trying to rotate a point say (20,6,30) around a point (10,6,10) at a radius of 2 and i have failed so far trying to do it. I know that to rotate a point around origin you just multiply rotation matrix with world matrix and to rotate a point around itself is translating the point to origin ,then rotating and translatingback, but not sure how to approach this problem.

**0**

# How to rotate an object around a fixed point at a particular radius?

###
#2
Members - Reputation: **429**

Posted 10 November 2013 - 12:59 PM

You can move your objects center of rotation by first translating before rotating.

So if you want to rotate about point p.

1. Translate your object to p

2. Do your rotation

3. Translate your object somewhere else

Good luck!

**Edited by DishSoap, 10 November 2013 - 01:00 PM.**

###
#3
Crossbones+ - Reputation: **5605**

Posted 10 November 2013 - 01:05 PM

I am trying to rotate a point say (20,6,30) around a point (10,6,10) at a radius of 2

The above requirement can be fulfilled if the axis of rotation passes through (10,6,10) and passes through a point that is 2 length units away from (20,6,30).

Think of the rotational axis as a ray emanating at the center of rotation **r**_{0} (here (10,6,10)) along a direction **d**:

**r**( t ) := **r**_{0} + t * **d**

The second point is at a distance t_{1} on this ray. The difference vector **v** from here to the point of interest **p** (here (20,6,30)) is:

**p** - **r**( t_{1} ) =: **v**

It is constrained because it is perpendicular to **d**

**v** x **d** == 0

and its length should be 2

|| **v** || == 2

Try to solve this, but you'll see that there is an infinite amount of solutions to this. ~~Think of a circle with radius 2 around ~~ EDIT: Ups, the figure isn't necessarily a circle, sorry. But it still may help as a gedanken experiment if thinking of a circle.**p**, and the 2nd point **r**( t_{1} ) on the ray may be any point of this circle. Whatever point you choose will have an influence on how the rotation looks like.

**Edited by haegarr, 10 November 2013 - 01:10 PM.**

###
#4
Members - Reputation: **394**

Posted 11 November 2013 - 11:54 AM

to rotate a point around itself is translating the point to origin ,then rotating and translatingback,

You almost have it. Instead of translating the point you want to rotate to the origin, translate the point you want to rotate around. (In fact this is exactly what is done in the algorithm you describe, but in that case the two points are identical.) So, given pointToRotate and rotateAround:

translation = (origin - rotateAround)

translation.applyTo(pointToRotate)

pointToRotate.rotate(angle)

translation *= -1

translation.applyTo(pointToRotate)

You can see that if pointToRotate and rotateAround are identical, this is precisely what you describe in your post.

###
#5
Crossbones+ - Reputation: **6013**

Posted 12 November 2013 - 11:38 AM

I did a tutorial about this exact subject in my math series. Rotating one object around another.

C++ with SFML. | Blender for Game Art | 2D Gamedev math | Moai | PlayStation Mobile | Getting Started Guide | Project Anarchy | Cocos2D HTML

###
#6
Members - Reputation: **103**

Posted 18 November 2013 - 05:48 PM

@ DishSoap

Translate your object somewhere else

How would you calculate the position to be translated to as the position would be changed all the time due to rotation.

@ KingofMen

translation = (origin - rotateAround)

translation.applyTo(pointToRotate)

pointToRotate.rotate(angle)

translation *= -1

translation.applyTo(pointToRotate)

This would result in rotating around a fixed point but i want to change the radius of rotation, in this case the radius would be distance from a given point to the point with respect to which the object is rotating.

Thanks all for the replies , I'l post an answer once i find and test its working.