Sharp3D's Plane differs from DirectX's Plane

Topics: User Forum
Aug 1, 2006 at 1:00 PM
I have made a test like following:
DirectX.Vector3 dxpoint = new Microsoft.DirectX.Vector3(52, 34, 78);
DirectX.Vector3 dxnormal = new Microsoft.DirectX.Vector3(23, 12, 65);

Sharp3D.Math.Core.Vector3F dnpoint = new Sharp3D.Math.Core.Vector3F(52, 34, 78);
Sharp3D.Math.Core.Vector3F dnnormal = new Sharp3D.Math.Core.Vector3F(23, 12, 65);

DirectX.Plane dxplane = Microsoft.DirectX.Plane.FromPointNormal(dxpoint, dxnormal);
Sharp3D.Math.Geometry3D.Plane dnplane = new Sharp3D.Math.Geometry3D.Plane(dnpoint, dnnormal);

Console.WriteLine("DirectX: " + dxplane.A + ", " + dxplane.B + ", " + dxplane.C + ", " + dxplane.D);
Console.WriteLine("Sharp3D: " + dnplane.Normal.X + ", " + dnplane.Normal.Y + ", " + dnplane.Normal.Z + ", " + dnplane.Constant);

The result:
DirectX: 23, 12, 65, -6674
Sharp3D: 52, 34, 78, 6674

Why is the Constant (D) of the DirectX plane negative and the Constant of the Sharp3D Plane not? Is DirectX's plane wrong or is it the Sharp3D's plane that is wrong?
Coordinator
Aug 19, 2006 at 8:34 PM
This is a matter of convention when calculating the constant in the following line on the Place class constructor:
_const = Vector3F.DotProduct(normal, point);

DirectX probably does Vector3F.DotProduct(point, normal); and that’s why the minus.
So, the math isn’t incorrect, it’s a simple matter of defining the equation. Sharp3D defines a place as (N dot Q)+D = 0.
When converting to DirectX you have to change the sign.

The difference might also be a result of the fact that DirectX use row vector as opposed to column vector like “real” mathematicians use (that’s why when converting a Matrix from Sharp3D to DirectX you have to transpose it).