Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 mooni   Members   -  Reputation: 103

Like
0Likes
Like

Posted 10 November 2013 - 12:13 PM

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.



Sponsor:

#2 DishSoap   Members   -  Reputation: 361

Like
0Likes
Like

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 haegarr   Crossbones+   -  Reputation: 4332

Like
0Likes
Like

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 r0 (here (10,6,10)) along a direction d:

    r( t ) := r0 + t * d

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

    pr( t1 ) =: 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 p, and the 2nd point r( t1 ) on the ray may be any point of this circle. Whatever point you choose will have an influence on how the rotation looks like. EDIT: Ups, the figure isn't necessarily a circle, sorry. But it still may help as a gedanken experiment if thinking of a circle.


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


#4 King of Men   Members   -  Reputation: 391

Like
0Likes
Like

Posted 11 November 2013 - 11:54 AM

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

 

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. 


To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.

#5 Serapth   Crossbones+   -  Reputation: 5484

Like
0Likes
Like

Posted 12 November 2013 - 11:38 AM

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



#6 mooni   Members   -  Reputation: 103

Like
0Likes
Like

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS