Thread: Rotation Matrcies

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    41

    Rotation Matrcies

    Hi

    I have a 3D object.

    I would like to perform a 3D rotation about its COM (centre of mass), in terms of theta and phi. Not about the axes. I did have a piece of code to do this, but have lost the official reference for where I saw this worked out in more detail. I know it was a coupled combination of a rotation by theta and then phi for example.

    Can anyone point me to a good source of information on this.

    Thanks

    Dis

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Maybe I don't have a good enough imagination, but I don't know what it means to do a 3D-rotation about a point. You can do a rotation about any arbitrary axis (doesn't have to be a coordinate axis). Any slightly reasonable book titled "Mathematics for 3D Graphics" or similar will have a section on how to decompose rotations.

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Finding the center of mass in a game object is a simple process of averaging all the locations of the various point masses of your object. Note that you would use local or model coordinates for the calculation but for physics calculations you would use the world coordinates.

    If you think of this new point as a displacement from the origin then you have the axes you need for rotation. The axes extend from this point towards and away from zero to infinity.
    A point in 3D space should really be thought of as a displacement from the origin or moreso a vector. I would drop the notation of a point because it's misleading.

    For instance a point 2,2 is 2 units away from the x origin and 2 units away from the y origin. So even though 2,2 is said to be a point it could equally be expressed as a vector displacement from the origin.

    Since matrix transformations are cumulative you would translate in model space to the new vector that represents the center of mass of the object and then you would rotate. Since you have translated away from the origin and then rotated the rotation will now be about the center of mass. By translating you really have effectively moved the origin from 0,0,0 to your center of mass. Now all rotations done after this transformation will be relative to your translated location or more appropriately your new local origin.
    Last edited by VirtualAce; 01-16-2008 at 07:11 PM.

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    70
    The DirectX documentation has some good resources for transformation matrices, not as good as a book but as far as free resources go it's not bad.

  5. #5
    Registered User
    Join Date
    Jul 2005
    Posts
    41
    Thanks guys

    The problem is I have implemented code that I wrote 2.5 years ago and cannot find my reference to how I actually performed the COM part. Its quite involved and I suspect it involves rotating the co-ordinate axes. I am rather embarrassed because I cannot remember the reference... "Let this be a lesson to you all". I now my code words and use it, but cannot remember how I came by it in the first place and now hoping if you guys might know.

    Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. camera rotation matrix
    By Vick jr in forum Game Programming
    Replies: 5
    Last Post: 05-26-2009, 08:16 AM
  2. Image rotation - doesn't always work
    By ulillillia in forum C Programming
    Replies: 12
    Last Post: 05-03-2007, 12:46 PM
  3. Quaternion Rotation
    By psychopath in forum Game Programming
    Replies: 16
    Last Post: 07-23-2006, 03:28 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. one final problem with rotation
    By DavidP in forum Game Programming
    Replies: 3
    Last Post: 11-19-2003, 03:50 AM