예제 #1
0
        public bool IsOnShortLine(clsPoint3d pt1, double aTol = 0, bool excludeEnds = false)
        {
            clsLine3d l1 = default(clsLine3d);
            clsLine3d l2 = default(clsLine3d);
            double    d  = 0;

            if (aTol == 0)
            {
                aTol = mdlGeometry.myTol;
            }
            if (Abs(DistanceToPoint(pt1)) > aTol)
            {
                return(false);
            }
            l1 = new clsLine3d(P1, pt1);
            l2 = Copy();
            l2.Normalise();
            d = l1.Dot(l2);
            if (d < -aTol)
            {
                return(false);
            }
            if (d > Length + aTol)
            {
                return(false);
            }
            if (excludeEnds && (P1 == pt1 | P2 == pt1))
            {
                return(false);
            }
            return(true);
        }
예제 #2
0
        public double Lambda(clsPoint3d pt1)
        {
            clsLine3d l1 = default(clsLine3d);
            clsLine3d l2 = default(clsLine3d);

            l1 = new clsLine3d(P1, pt1);
            l2 = Copy();
            l2.Normalise();
            return(l1.Dot(l2) / Length);
        }
예제 #3
0
        public static clsPoint3d ProjectPoint(clsPoint3d p1, clsLine3d l1)
        {
            double    d1 = 0;
            clsLine3d l2 = new clsLine3d();
            clsLine3d l3 = new clsLine3d();

            l2 = l1.Copy();
            l2.Normalise();
            l3        = new clsLine3d(l1.P1, p1);
            d1        = l2.Dot(l3);
            l2.Length = d1;
            return(l2.P2);
        }
예제 #4
0
        public double DistanceToPoint(clsPoint3d aPt)
        {
            double    d1 = 0;
            double    d2 = 0;
            clsLine3d l2 = default(clsLine3d);
            clsLine3d l3 = default(clsLine3d);

            l2 = Copy();
            l2.Normalise();
            l3 = new clsLine3d(P1, aPt);
            d1 = l2.Dot(l3);
            d2 = l3.Length;
            return(Sqrt(Pow(d2, 2) - Pow(d1, 2)));
        }
예제 #5
0
        public static double Dist3d(clsPoint3d p1, clsLine3d l1)
        {
            double    d1 = 0;
            double    d2 = 0;
            clsLine3d l2 = new clsLine3d();
            clsLine3d l3 = new clsLine3d();

            l2 = l1.Copy();
            l2.Normalise();
            l3 = new clsLine3d(l1.P1, p1);
            d1 = l2.Dot(l3);
            d2 = l3.Length;
            return(Sqrt(Pow(d2, 2) - Pow(d1, 2)));
        }
예제 #6
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));
        }