Rotation toward target vector, finding orientation of object?

• Aug 20th 2009, 05:06 PM
qwertygeek
Rotation toward target vector, finding orientation of object?
Okay, I'm by no means a mathematics wizard. I was required in college to get a math minor and every course was pretty brutal so bear with me if this seems remarkably obvious to some of you.

Here's my problem. I'm working on a graphics program. I'm doing a bit of 3D visualization programming (which I'm also not especially great at.. but whatareyagonnado..) in which I have a few 3D models moving through an open space.

Each model is represented by a 4x4 matrix: The first three rows of the matrix represent the rotation/orientation of the model relative to the absolute world XYZ axis.. first is the x orientation, second is y, third is z. The last row is the model's translation away from the absolute world origin (0,0,0).

(I'm assuming most of you found that really obvious but then again I'm really bad at explaining things, particularly in math, so excuse me while I go overboard..)

Thus if we have a model of a jet, and the wings are parallel to it's x-axis and the body is parallel to the y-axis, and at the moment the model's matrix was:
0 1 0 0
0 0 1 0
1 0 0 0
10 10 10 1

Then the model is at (10,10,10), with it's nose pointed straight up the x-axis and wings parallel to the y-axis.

(Alright that was probably far more explanation than need be but like I said, I tend to explain things poorly..)

Anyway... what I'm trying to do now is figure out how to orient the y-axis of the model toward a target XYZ location. Now, I know how to come up with a target vector... (targetXYZ-locationXYZ)/(magnitude). I was going to use that as the y-vector in the model matrix, but I can't figure out what to use as the x and z vectors. ie. the wings vector and the top of the plane vector.

Any help with this would be IMMENSELY appreciated. I've taken a linear algebra course, but obviously not a great deal of it stuck. Haha.
• Aug 25th 2009, 02:18 AM
nirax
as i understand you r probably trying to apply a affine transformation of the form Av+b, where A is an orthogonal isometry and b is some vector. assuimng that your orginal plane is aligned with the x-axis and you need to tilt its y-axis (called j vector) to (say) v direction. v is auusmed normalized. let us call the vector perp to the plane (j,v) as n.

find the matrix for this rotation -- axis is n and j rotates to v.