main/src/georegression/metric/ClosestPoint3D_F64.java
public static Point3D_F64 closestPoint( PlaneNormal3D_F64 plane , Point3D_F64 point , Point3D_F64 found ) {
		if( found == null )
			found = new Point3D_F64();

		double A = plane.n.x;
		double B = plane.n.y;
		double C = plane.n.z;
		double D = plane.n.x*plane.p.x + plane.n.y*plane.p.y + plane.n.z*plane.p.z;

		double top = A*point.x + B*point.y + C*point.z - D;

		double n2 = A*A + B*B + C*C;

		found.x = point.x - A*top/n2;
		found.y = point.y - B*top/n2;
		found.z = point.z - C*top/n2;

		return found;
	}
public static Point3D_F64 closestPoint( PlaneNormal3D_F64 plane , Point3D_F64 point , Point3D_F64 found ) {
		if( found == null )
			found = new Point3D_F64();

		double A = plane.n.x;
		double B = plane.n.y;
		double C = plane.n.z;
		double D = plane.n.x*plane.p.x + plane.n.y*plane.p.y + plane.n.z*plane.p.z;

		double top = A*point.x + B*point.y + C*point.z - D;

		double n2 = A*A + B*B + C*C;

		found.x = point.x - A*top/n2;
		found.y = point.y - B*top/n2;
		found.z = point.z - C*top/n2;

		return found;
	}
public static Point3D_F64 closestPoint ( PlaneNormal3D_F64 plane , Point3D_F64 point , Point3D_F64 found ) { if ( found == null ) found = new Point3D_F64 ( ) ; double A = plane . n . x ; double B = plane . n . y ; double C = plane . n . z ; double D = plane . n . x * plane . p . x + plane . n . y * plane . p . y + plane . n . z * plane . p . z ; double top = A * point . x + B * point . y + C * point . z - D ; double n2 = A * A + B * B + C * C ; found . x = point . x - A * top / n2 ; found . y = point . y - B * top / n2 ; found . z = point . z - C * top / n2 ; return found ; }
Finds the closest point on the plane to the specified point.

@param plane The plane
@param point The point
@param found (Optional) Storage for the closest point.  If null a new point is declared internally.
@return The closest point
Finds the closest point on the plane to the specified point .