Setting position based on Quaternion rotation

Started by
1 comment, last by dsoltyka 14 years, 5 months ago
This question may be really simple, however I am fairly new to 3D math and have spent most of my time in the 2D world, as such certain things like quaternions are very new to me. Here is what I am trying to accomplish. I am making a simple tech demo using the Havok physics engine. Essentially I want to create a line of domino like objects that goes forward, turns 90 degrees, and continues until it ends. I am using an array of hkpRigidBody objects. Obviously, setting position in a straight line is easy, as I can just increment along an axis. However, when turning into the 90 degree angle, I need to make multiple dominoes that have slight rotations and slight alterations in position based upon their angle of rotation. Rotating the objects is easy, as I can just give them a quaternion rotation. However, I am not sure how to reposition the object based on this rotation. My assumption is that the best way to do this is to base the current objects position on the rotation of the previous object. My initial train of thought would be a unit vector indicating the new direction, then multiplying that unit vector by a scalar to get the final position, however I am not sure if I can do this with quaternions, or if this even the best way to approach the problem. Anyone have any insight they can share? Like I said I'm new to 3D math like this, but have a very strong math foundation and should be able to understand most explanations. Thank you.
Advertisement
I think you can actually use 2D math mostly, in this case. Dominoes stand on some platform, which is basically a 2D plane. I think angles, sine, cosine and a coordinate offset on that plane is enough to position the dominoes.

From your explanation it sounds like you want a 90 degree turn, but composed from multiple smaller turns in angles, along a small circle radius to get a quite smooth 90-degree corner.

Something like this:
1. Decide a circle radius.
2. Decide the corner's position (placed on the initial line of dominoes).
3. Place dominoes straight until you reach cornerPos - circleRadius
4. Divide the 90 degrees of the corner-circle into "cake" slices (so a domino can be placed on each slice)... The circle center is on the "inside" of the corner.
5. Increase the angle from 0 to 90 iteratively (for each slice), and use sin and cos to get an offset from the circle center to place each domino at.
* That angle (between 0 and 90) can be used to construct either a quaternion or rotation matrix if you need that to orient each domino model.
6. At 90 degree, the position should be on the second straight line.
Hmmm. Yeah that could work. Then potentially I could determine the actual position of said domino in world space based upon it's position on the perimeter of the circle and the distance from it's center.

That's food for thought, I'll give that a shot...

Thank you.

This topic is closed to new replies.

Advertisement