Question

  • I got a Plane (Normal, d) and a Vector3 point (x, y, z).
  • I need to translate the plane to that point for X distance. How do I do that?

I'm coming up with this..

plane = Plane.Transform(plane, Matrix.CreateTranslation(

But can't figure what to place there. It has to be something with dot product, Plane.Normal and my Vector3.

EDIT:

I'm thinking of this.

public static Plane MoveTo(this Plane p, Vector3 point, float distance)
{
    Vector3 planeVector = p.Normal * p.D;

    Matrix matrix = Matrix.CreateTranslation(Vector3.Normalize(planeVector)) *
        distance * Math.Sign(Vector3.Dot(planeVector, point - planeVector))

    return Plane.Transform(p, matrix);
}

If someone considers this as wrong or particually wrong, please, note it.

Was it helpful?

Solution

The distance from a point P to the plane Pi is:

enter image description here

enter image description here

You should calc current d(P, pi), substract to that the amount X, and then only have to calculate D to get the new plane.

EDIT:

 // This line has no sense... is useless do that.
 Vector3 planeVector = p.Normal * p.D;  

To know the relation between a point and a plane, you only have to calculate its equation: R = Ax + By + Cz + D where (A,B,C) is the normal and (x,y,z) the point...

if (R == 0) the point is contained in the plane
if (R>0) the point is front // or viceversa
if (R<0) that point is back

R = plane.DotCoordinate(point);    
distance*=(R>0) ? 1 : -1; // or viceversa, i'm not sure now
Matrix matrix = Matrix.CreateTranslation(plane.Normal * distance);
return Plane.Transform(p, matrix);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top