Skip to main content
GameDev.net gamedev.net
🔒 Locked

"Plane" math

Started by Galshin Nov 10, 2000 at 1:37 PM 3 replies 450+ views
Original Post
Galshin
Galshin
If I have a plane, represented by a normal n, and a distance d, how do I tranform that plane. In other words if I have this Plane, and a 4x4 transformation matrix, how do I transform the plane? On a side note... If anyone knows any good reference sites for 3D math that would be great. I have figured out a great deal of this stuff already, but it seems like there is an endless amount of stuff out there to figure out. Galshin
LilBudyWizer
LilBudyWizer
I believe you scale your normal by the distance, transform that and convert it back into a unit normal and distance. If the plane passes through the origin I think I would just apply the transform to the direction and skip the scaling. You still have to convert it back into a unit normal and distance since a generic transform could include a scaling so it may not be unit any more.
Keys to success: Ability, ambition and opportunity.
Galshin
Galshin
Working this out...

Just thinking, if you have a plane... and you transform it with a translation matrix (no rotation and no scaling), then only the distance should change and not the normal correct?

Here''s what I am doing.

class Plane
{
public:
Vector3 normal;
float d;


};



void Plane::transform( const Matrix4 &m )
{
Vector3 p = normal * d;
p = m * p;

normal = p;
normal.normalize();

setDistance( p );
}

If I do this, and pass a translation matrix, the normal is changing. I am probably doing something wrong with the normal however, but I am pretty sure the distance is coming out alright.

Galshin
LilBudyWizer
LilBudyWizer
Well, my math isn''t all that strong, but I believe that would correct even with rotation and scaling. The only part I have strong doubts about is the m*p. The order of a cross product does matter so m*p is not p*m. I''m not confident enough to say which one would be correct with certainity, but I would think it should be p*m. What makes me uncertain is not knowing the relationship between p*m and m*p.
Keys to success: Ability, ambition and opportunity.
VolkerG
VolkerG
Shouldn''t the normal be multiplied by the inverse transformation matrix (in the general case).

The diffence between M*p and p*M is that you have to transpose the vector and the matrix. Of course the resulting vector is transposed, too. Thus M of the first case is Transpose(M) of the second case (and the same holds for p).

You know: M*p = Transpose (Transpose (p) * Transpose (M))

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.