PDA

View Full Version : Transforming planes using matrices



chronozphere
24-12-2006, 02:42 PM
Hi 8)

I was trying to figure out how to transform a plane using a matrix.

A plane is (of course :) ) defined as follows:

nx,ny,nz,d

The vector (nx,ny,nz) is the plane's normal vector and b is the Z coordinate at which the plane intersects the Z-axis.

Now i like to know how to transform this data.
I think it's obvious that the normal vector must be multiplied with the matrix. ;)

But what happens to the d scalar??

Can someone tell me how to transform a plane using a matrix?? :?

Thank you.

dmantione
24-12-2006, 02:55 PM
Besides the normal vector plus y distance, a plane can also be defined using three points in the plane, not on a line. You can transform those three points with a matrix, and perhaps convert them back into a normal vector plus y distance again.

Using mathematics, you might be able to simplify the calculation.

chronozphere
24-12-2006, 03:37 PM
Ahh :razz: I know a better definition for a plane:

(x,y,z),(nx,ny,nz)

It's a point in space + a plane normal.
My first definition was not completely waterproof because it couldn't contain a plain which runs parallel to the Z-axis. My new definition can. :)
It's also i bit more compact than yours.

I think.. to transform a plane using this definition, you must multiply the matrix with the (x,y,z) vector and divide the normal vector with the matrix and normalize it afterwards. :)

Is this a correct way?? can someone confirm this.

dmantione
24-12-2006, 05:16 PM
Well, the problem with the direction vector is that you can't move the plane. Multiplying it with a matrix which moves a point will move the direction vector: the results will be interresting, but probably not what you want. I think rotating and scaling will work ok.

chronozphere
26-12-2006, 02:25 PM
owh.. damn i was wrong.the d variabele in my first definition is the distance between the plane and the origin, and not a z-coordinate.

I've also found this (http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dx81_c/directx_cpp/Graphics/Reference/CPP/D3DX/Functions/Math/MathFunctions.asp)

But i dont understand how D3DXPlane is defined. :(
Is it similar to the definition above or is it different??

BTW: merry christmas everyone 8)

dmantione
26-12-2006, 05:23 PM
According to the documentation there, it is defined by the plane equation: ax + by + cz + dw = 0

This is simlar to your definition. To get the exact way to it I think you will really have to do the math. Create three points, apply the transformation matrix them it and see what formula rolls out.

P.s. http://www.geometrictools.com/Documentation/Documentation.html is a gold mine of information regarding these topics. Alas, they don't handle this one...

grudzio
26-12-2006, 05:25 PM
The a, b and c coefficients of the D3DXPlane define the normal to the plane and d is a distance from the origin.

I am too late, as usual.