math & physics
moe at September 24th, 2005 15:33 — #1
I have a plane given from a normal and the distance to the origin.
A ground plane would look like this:
normal = (0,1,0)
distance = 0
How would I find a transformation matrix witch would transform the plane or points from the ground plane on to a plane with arbitrary values?
I am not sure that was clear.
If I would actually want to render a ground plane I could use an identity matrix but for other planes I would need a transformation matrix so I can transform the ground plane into the plane represented trough an arbitrary normal and an arbitrary distance.
Side info: Nope this is not homework. I try to find a way so I can sync the results from the physics lib with the gfx output. I can construct point on the searched plane and build a vertex buffer. Then I just render the vertex buffer using an identity matrix. But I would like to know how to use it with meshes. Then I would have a mesh representing a ground plane and use a matrix to put it in place.
Thx for any input.
reedbeta at September 24th, 2005 17:43 — #2
The normal of your plane is 0,1,0; therefore your plane can be parameterized by the x axis and z axis (1,0,0) and (0,0,1). When you construct a 3x3 matrix, it maps (1,0,0) to the first column, (0,1,0) to the second column, and (0,0,1) to the third column; therefore, figure out two axes for your desired destination plane and stick them in the first and third columns of the matrix. Then let the second column be the cross product of the third and first (in that order). You probably want the two axes you choose to be orthogonal (perpendicular) and of unit length.
moe at September 24th, 2005 18:40 — #3
Thx for your reply.
I am not sure I can apply the same principle to a 4x4 matrix. Can I just set the fourth value to 1? And what about the fourth column, what should it contain?
jordan at September 24th, 2005 20:08 — #4
Thx for your reply. I am not sure I can apply the same principle to a 4x4 matrix. Can I just set the fourth value to 1? And what about the fourth column, what should it contain?
X X X 0
X X X 0
X X X 0
0 0 0 1
Where X is an entry in the 3x3 matrix.
moe at September 24th, 2005 20:41 — #5
moe at September 25th, 2005 03:06 — #6
Lol, I forgot to say it works like a charm