示例#1
0
        public static clsPoint3d ProjectPointOntoPlaneAlongZ(clsPoint p, clsLine3d l1)
        {
            clsLine3d  v1 = new clsLine3d();
            double     u  = 0;
            double     r  = 0;
            double     z  = 0;
            clsPoint3d p1 = new clsPoint3d();

            v1 = new clsLine3d(new clsPoint3d(0, 0, 0), new clsPoint3d(0, 0, 1));
            u  = v1.Dot(l1);
            //This is the length of the normal vector, measured in the vertical direction

            p1 = new clsPoint3d(p.X - l1.X1, p.Y - l1.Y1, 0 - l1.Z1);
            r  = p1.Dot(l1.DP());
            //r is the distance of our point to the nearest point on the plane
            //r = v1.Dot(myV)
            z = r / u;
            //z is the vertical distance of our point to the plane. It is sign sensitive - positive is above the plane.

            return(new clsPoint3d(p.X, p.Y, -z));
        }