General Discussion - How to Calculate The Centre of Rotation for a Moving Object?

User Image
Echo123123
Freeware Edition
Joined February 05, 2009
Bronze StarBronze Star Wednesday, July 14, 2010 10:26:19 AM
Hi Guys,
I just want some help in determining the centre of rotation for an object moving in the space. How can I calculate it? Note: The centre of rotation for this movning object isn't fixed, its chaning during motion.

Regards,
User Image
Funkas
Non-Commercial Pro Edition
Joined February 28, 2008
Coding Guru Award!Gold StarSilver StarSilver StarSilver StarBronze StarBronze StarBronze StarBronze Star Wednesday, July 14, 2010 11:15:52 AM
First you need to obtain x,y,z,w components from object's rotation

A quaternion (x, y, z, w) which represents a general rotation can be interpreted geometrically as follows.
x = X · sin( α / 2 )
y = Y · sin( α / 2 )
z = Z · sin( α / 2 )
w = cos( α / 2 )

Here (X, Y, Z) is the unit length axis of rotation in 3D space and α is the angle of rotation about the axis in radians.

Having this, you can calculate X, Y, Z coordinates of unit length rotation's axis.
User Image
Echo123123
Freeware Edition
Joined February 05, 2009
Bronze StarBronze Star Friday, July 16, 2010 1:25:02 AM
Thanx Funkas,

But can I estimate the instantanous centre of rotation for a moving body in 3D space using this?
User Image
Echo123123
Freeware Edition
Joined February 05, 2009
Bronze StarBronze Star Friday, July 16, 2010 1:27:00 AM
One more thing, am looking for world coordinate values
User Image
MiKo
Commercial Pro Edition
Joined September 07, 2008
Coding Guru Award!Community Medal Award!Beta King Award!Gold StarSilver StarSilver StarSilver StarBronze StarBronze Star Friday, July 16, 2010 7:25:44 PM
Echo123123, I reckon you want to see how the object is moving, then deduct a circle path from it and get the center of that path?
First, you would need some points of the object's path (like, "two sec ago", "one sec ago", "now"). If you got that, you could maybe use the equations shown here? http://local.wasp.uwa.edu.au/~pbourke/geometry/circlefrom3/
User Image
Funkas
Non-Commercial Pro Edition
Joined February 28, 2008
Coding Guru Award!Gold StarSilver StarSilver StarSilver StarBronze StarBronze StarBronze StarBronze Star Friday, July 16, 2010 7:28:08 PM
Rotation axis calculated above is always the one in object's pivot point. It's object's current rotation axis. It's enough to describe the current rotation. It is the rotation that causes object to change it's orientation in space, but not the position. To change the position you need velocity along the rotation.
That, what you are trying to calculate, is not as much rotation but rather transform, which consists of rotation and translation as well.

To calculate the center of such transform, you need to know the direction to it and the distance from traveling object. The direction is the vector which is perpendicular to two vectors. The current velocity vector and the vector calculated above. Just Vector cross product.

The distance (radius) is the quotient of posVelocity and rotVelocity.
User Image
Echo123123
Freeware Edition
Joined February 05, 2009
Bronze StarBronze Star Monday, July 19, 2010 3:24:34 PM
Thanks guys,
my problem is that I have an object moving in 3D space without preassigned or certain path. its centre of rotation isnt fixed and changing continously while moving based on the physics engine. I want to calculate the (x,y,z)coordinate of its centre of rotation as it moves.

Thanks,
User Image
Echo123123
Freeware Edition
Joined February 05, 2009
Bronze StarBronze Star Monday, July 19, 2010 3:37:02 PM
I just checked your link Miko, very helpful. I think this is what am looking for but for a 3D space. so I guess I will need to introduce z axes as well. Any help with scripting this?
User Image
Bach
Non-Commercial Std Edition
Joined June 26, 2010
Coding Guru Award!Silver StarBronze Star Monday, July 19, 2010 10:34:45 PM
Have a look at the bottom of the page MiKo linked to. There's a C sample code which actually includes 3 dimensions.

Cheers,
Bach
User Image
Echo123123
Freeware Edition
Joined February 05, 2009
Bronze StarBronze Star Wednesday, July 28, 2010 2:38:02 PM
Yeah but I will need in as a script in Dx Studio. Any help converting the math in the link into script.
User Image
Bach
Non-Commercial Std Edition
Joined June 26, 2010
Coding Guru Award!Silver StarBronze Star Wednesday, July 28, 2010 11:44:20 PM
Hey Echo,

just had a look at the sample code again.. it doesn't properly support a third dimension -> it simply expects that all points are on a plane somewhere in 3d space. Is that the case for you? I.e. is there one axis that doesn't change?

If not, I'm afraid the sample won't help you getting that figured out.

Are you able to give more specifics what it is you're trying to achieve? Maybe there is another way to get there..

Cheers,
Bach
User Image
Echo123123
Freeware Edition
Joined February 05, 2009
Bronze StarBronze Star Thursday, July 29, 2010 3:30:48 PM
Thanks Bach,

What am looking for is for 3D, but how about to consider (x,y) and then (y,z) or (z,x) so I will get the x,y,z for the centre of rotation?

What am trying to find is that I have an object moves irregularly in the 3D space. its centre of rotation changes instantanously, am about to find the centre of rotation for this object with each time frame. I have simplified the problem to be just a box moving in the (x,y,z) space (like a projectile motion) and I need to calculate the centre of rotation at each frame. (for example: a rigid bar is connected by a spring to the ground and it has some kind of non uniform articular motion)

regards,




If you'd like to post to this forum, just create an account on the website, or login with your existing details.

When posting to a forum, you can use limited HTML tags:- 'a' for links, 'b' for bold, 'i' for italic and 'script' to encase a block of DX Studio script.  All tags must be properly closed. e.g. <script>var i=1;</script>

Note: If there are any offensive comments in this topic, please let us know straight away at . Always follow the forum rules.