Vertice(s) location after quaternion Rotation

This is a discussion on Vertice(s) location after quaternion Rotation within the C# Programming forums, part of the General Programming Boards category; To those more inclined to understand the math involved, Thank you in advance. I have a 3d Point in space. ...

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    6

    Vertice(s) location after quaternion Rotation

    To those more inclined to understand the math involved, Thank you in advance.

    I have a 3d Point in space. From this point I have vertices defind by(scale). I have a Quaternion representing the rotation of the object (lets say a block). So...

    (1) I know the point in local and world space and can translate.

    (2) I know the scale of the object and it's starting vertices intersections at zero rotation.

    (3) I have the quaternion which represents the 3d rotation and can translate that to degrees and Eulers.


    The Question is: How do i find the exact points of the vertices after the rotation. (what I'm attempting to do is plot points from vertice to vertice all along the sides/top/bottom of the object.)

    I have looked at Matrix4 transformations and Quaternions and still do not understand how to find the vertices after rotation.

    Again, thanks in advance.
    (its been bugging me for days.)

  2. #2
    Registered User
    Join Date
    Aug 2012
    Posts
    6
    Quote Originally Posted by dgubser View Post
    To those more inclined to understand the math involved, Thank you in advance.

    I have a 3d Point in space. From this point I have vertices defind by(scale). I have a Quaternion representing the rotation of the object (lets say a block). So...

    (1) I know the point in local and world space and can translate.

    (2) I know the scale of the object and it's starting vertices intersections at zero rotation.

    (3) I have the quaternion which represents the 3d rotation and can translate that to degrees and Eulers.


    The Question is: How do i find the exact points of the vertices after the rotation. (what I'm attempting to do is plot points from vertice to vertice all along the sides/top/bottom of the object.)

    I have looked at Matrix4 transformations and Quaternions and still do not understand how to find the vertices after rotation.

    Again, thanks in advance.
    (its been bugging me for days.)
    Never mind and thanks again if you were thinking about it.
    The best solution (so far determined) is to place the quat and vector information into a 4 X matrix which can be used repeatedly to calculate any vertices point chosen (from origin) to its new value. From that point (no pun intended) all the caculations needed to determine values between vertices is basic algebra. ie. Simple.

    This can be used to determin collision possibilities and or position in a self generated world matrx, both useful endevors.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    You begin with your vertices in local or model space. You then create your SRT frame (scale, rotate, translate). In this case your rotate is the quaternion rotation you are talking about. Once you do this you then transform your vertices by the 4x4 SRT matrix. In order to do this you will need to create a 4x4 rotation matrix from your quaternion. Regardless of how cool quaternions are you still have to bring them back down to 4x4 matrices or the video card will puke on them. Once you get the scale, rotation and translation matrices combine them in order SRT and transform all vertices by this matrix. Note that this must be done in every frame. All vertices always start in local space around 0,0,0 and a rotation of 0,0,0 on each axis. You cannot transform and then continue to transform the result or you will transform your vertices into oblivion.

    Local * SRT = World
    One 3D 'frame' is SRT.
    Last edited by VirtualAce; 08-20-2012 at 05:09 PM.

  4. #4
    Registered User
    Join Date
    Aug 2012
    Posts
    6
    Quote Originally Posted by VirtualAce View Post
    You begin with your vertices in local or model space. You then create your SRT frame (scale, rotate, translate). In this case your rotate is the quaternion rotation you are talking about. Once you do this you then transform your vertices by the 4x4 SRT matrix. In order to do this you will need to create a 4x4 rotation matrix from your quaternion. Regardless of how cool quaternions are you still have to bring them back down to 4x4 matrices or the video card will puke on them. Once you get the scale, rotation and translation matrices combine them in order SRT and transform all vertices by this matrix. Note that this must be done in every frame. All vertices always start in local space around 0,0,0 and a rotation of 0,0,0 on each axis. You cannot transform and then continue to transform the result or you will transform your vertices into oblivion.

    Local * SRT = World
    One 3D 'frame' is SRT.
    VirtualAce,

    Thanks for the input:

    I'm not worried about the video card, as it displays the object, scaled, rotated, transposed from object space...to world space just fine. I could place the object in world space and rotate it by the Quat around the fixed point (center) of the object and it rendered(renders) just fine. I know the vertice(s) locations, before Quat rotate, but for the life of me, couldn't figure out how to get the vertices of the object after the rotation. Since I knew the angles and scale before and after rotation, it would seem there would be a simpler way of getting the vertices after rotation. That appears not to be the case. I'm also not worried about trying to have this happen every frame. The blocks are static, once placed, and time to compute the new vertices is not time sensitive.
    Simply: I have world location: center point of object, scale of object, quaternion rotation of object. Center point and scale give me the object vertices. I "thought" there might be a simple way to garner the needed information. However, since i DO wish to plot points between vertices, not just the vertices themselves, it would appear that setting up 4X4 matrices would allow me to use a combo matrix to plot the points between the vertices required and MAY be faster overall.

    Any further insight or thoughts would be appriciated.

  5. #5
    Registered User
    Join Date
    Aug 2012
    Posts
    6

    Solved

    Quote Originally Posted by dgubser View Post
    VirtualAce,

    Thanks for the input:

    I'm not worried about the video card, as it displays the object, scaled, rotated, transposed from object space...to world space just fine. I could place the object in world space and rotate it by the Quat around the fixed point (center) of the object and it rendered(renders) just fine. I know the vertice(s) locations, before Quat rotate, but for the life of me, couldn't figure out how to get the vertices of the object after the rotation. Since I knew the angles and scale before and after rotation, it would seem there would be a simpler way of getting the vertices after rotation. That appears not to be the case. I'm also not worried about trying to have this happen every frame. The blocks are static, once placed, and time to compute the new vertices is not time sensitive.
    Simply: I have world location: center point of object, scale of object, quaternion rotation of object. Center point and scale give me the object vertices. I "thought" there might be a simple way to garner the needed information. However, since i DO wish to plot points between vertices, not just the vertices themselves, it would appear that setting up 4X4 matrices would allow me to use a combo matrix to plot the points between the vertices required and MAY be faster overall.

    Any further insight or thoughts would be appriciated.
    SOLVED:

    I though I might post the steps to find the vertices of an object (already created) after it is rotated so that others attempting to do the same could benefit.

    (1) Place the object at origin. (center point of the object at 0,0,0)
    (2) Scale the object. (width,height,depth) /2 from the object origin.
    (3) Get all Vertices from the scaled value >into an array.
    (4) Create a Transformation Matrix from the objects original location (origin)
    (5) Create a Transformation Matrix from your rotation. (use quat to matrix or eulers to matrix ... whatever your rotation is stored in...convert it to a transformation matrix.)
    FOR
    (6) Create a Translation Matrix for each vertices in a for / next loop
    (7) Transform your vertices matrix by your rotation matrix.
    (8) add your (4) matrix to your (7) matrix.
    LOOP

    Your Vertice(s) will appear in the last matrix (8)

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    You should really never need to know the screen location of your transformed vertices. But if you do you must project your vertices into screen space. Most APIs will provide methods to do this.

    Your steps to reproduce may not work on hierarchical transformations. The simple math is:

    SRT * SRT * SRT * SRT * Root = World

    World * View (Camera) * Projection = Screen (greatly simplified)

    Anything else that appears to work but does not follow this is most likely incorrect and will not work in all cases.

  7. #7
    Registered User
    Join Date
    Aug 2012
    Posts
    6
    VirtualAce...thanks again for the input.....But, I may not of conveyed what I "needed" to get. I do not need to know the screen locations. I don't need to translate them to project them. I simply needed the vertices after rotation AND points between vertices after rotation. < makeshift bounding box, in a manner of speaking, used for my own purposes. The APIs (both opensource and commercial) I tried did not have what i wanted to accomplish what i had in mind. I have my own large matrix which overlays the coordinates of the objects....I needed the vertices and points between the vertices (to my own scale) after the objects were rotated. I wrote my own unmanaged asm api to access the very large overlay matrix (locked it so no garbage collection...etc.) Although there are some very good APIs available, I would rather write EXACTLY what i need at any "scale" i choose. The new routines have mapped several hundred million objects (the way i wish them to be mapped at the scale I choose.) without a glitch or gotcha. Also, speed is not an objective, although my routines appear to be 8 to thousands of times faster than what i HAVE used in other APIs. So, I have an added bonus of speed AND i get the versatility I desired for MY purposes.

    Thanks again for your input.

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Create your bounding box in local space. After you transform your object to world space, create a new bounding box from world space or transform your bounding box to world space. Note that if you choose to transform your bounding box to world space from local space it will not be accurate in all cases.

  9. #9
    Registered User
    Join Date
    Aug 2012
    Posts
    6

    Vertice(s) location after Quaternion Rotation

    Quote Originally Posted by VirtualAce View Post
    Create your bounding box in local space. After you transform your object to world space, create a new bounding box from world space or transform your bounding box to world space. Note that if you choose to transform your bounding box to world space from local space it will not be accurate in all cases.
    Excellent advice VirtualAce. "bounding box to world space from local space...." Correct again. It will be "close" after transformation...but not right on the money. Once the coordinates of the vertice(s) (and points in between the vertice(s) have been transformed to world space everything appears accurate down to .00005 which gives me more accuracy than I need to "get" the box. Transforming the box from local can drop the accuracy down to .125 in relation to the scale I'm using, so there is a significant difference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-14-2011, 06:04 PM
  2. Quaternion fun... Is there a more efficient way to do this?
    By wallsocket in forum Game Programming
    Replies: 2
    Last Post: 10-12-2011, 04:20 PM
  3. Expressing a quaternion with zero rotation
    By shrink_tubing in forum C++ Programming
    Replies: 12
    Last Post: 08-18-2010, 03:44 AM
  4. Quaternion Rotation
    By psychopath in forum Game Programming
    Replies: 16
    Last Post: 07-23-2006, 03:28 PM
  5. Quaternion question
    By Mr Q in forum Game Programming
    Replies: 15
    Last Post: 04-21-2004, 09:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21