// The shortest distance of point to plane.
        public double DistanceTo(PointAdaptor point)
        {
            Debug.Assert(point != null);
            double distance = Normal.Dot(point - Point);

            return distance;
        }
Exemple #2
0
        // The shortest distance of point to line.
        public double DistanceTo(PointAdaptor pointProxy)
        {
            Debug.Assert(pointProxy != null);

            PointAdaptor pointOnLine = ClosestPointTo(pointProxy);
            double distance = pointOnLine.DistanceTo(pointProxy);

            return distance;
        }
Exemple #3
0
        public PointAdaptor ClosestPointTo(PointAdaptor pointProxy)
        {
            if (null == pointProxy) return null;

            PlaneAdaptor Plane = GetPerpendicularPlane(pointProxy);
            if (null == Plane) return null;

            PointAdaptor Intersect = GetIntersection(Plane);

            return Intersect;
        }
Exemple #4
0
        public bool Contains(PointAdaptor point)
        {
            if (null == point) return false;

            PointAdaptor PointOnLine = BasePoint + Direction.VectorAdaptor;

            VectorAdaptor P2S = MathAdaptorFactory.Instance.CreateVectorAdaptor(point, PointOnLine);
            VectorAdaptor P2E = MathAdaptorFactory.Instance.CreateVectorAdaptor(point, BasePoint);

            return P2S.IsParallelTo(P2E);
        }
        public bool Contains(PointAdaptor point)
        {
            if (null == point) return false;

            // Ax + By + Cz = D;
            double ret = Normal.X * point.X
                + Normal.Y * point.Y
                + Normal.Z * point.Z;

            return MathUtil.IsTwoDoubleEqual(ret, ConstNumber);
        }
        public virtual Matrix44Adaptor SetRotate(UnitVectorAdaptor fromDirection
            , UnitVectorAdaptor toDirection, PointAdaptor basePoint)
        {
            Debug.Assert(fromDirection != null && toDirection != null
                && basePoint != null);
            if (!(fromDirection != null && toDirection != null
                && basePoint != null)) return this;

            double angle = fromDirection.AngleTo(toDirection);
            VectorAdaptor axis = fromDirection.VectorAdaptor.Cross(toDirection.VectorAdaptor);

            SetRotate(angle, axis.UnitVectorAdaptor, basePoint);

            return this;
        }
Exemple #7
0
        public PlaneAdaptor GetPerpendicularPlane(PointAdaptor pointProxy)
        {
            if (null == pointProxy)
                pointProxy = BasePoint;

            PlaneAdaptor Plane = MathAdaptorFactory.Instance.CreatePlaneAdaptor(pointProxy, Direction);
            return Plane;
        }
        protected override PointAdaptor OperatorMultiply(Matrix44Adaptor trans, PointAdaptor point)
        {
            Debug.Assert(point != null && trans != null);
            if (null == point || null == trans) return null;

            double[,] data = new double[4, 1];
            data[0, 0] = point.X;
            data[1, 0] = point.Y;
            data[2, 0] = point.Z;
            data[3, 0] = 1;
            NativeMatrix44Adaptor nativeTrans = trans as NativeMatrix44Adaptor;
            NativeMatrix2dAdaptor pointMatrix = new NativeMatrix2dAdaptor(data);

            NativeMatrix2dAdaptor resulr = nativeTrans.GetNativeMatrix2dProxy() * pointMatrix;
            resulr = resulr / resulr[3, 0];

            return new NativePointAdaptor(resulr[0, 0], resulr[1, 0], resulr[2, 0]);
        }
        // Scale
        public override Matrix44Adaptor SetScaling(double allScale, PointAdaptor basePoint)
        {
            Debug.Assert(allScale > 0 && basePoint != null);
            if (!(allScale > 0 && basePoint != null)) return this;

            PointAdaptor origin = new NativePointAdaptor(0,0,0);
            if (basePoint.IsEqualTo(origin))
            {
                SetScaling(allScale);
            }
            else
            {
                // Transform the origin to the base point.
                NativeMatrix44Adaptor T = NativeMatrix44Adaptor.Identity;
                T.SetTranslation(origin - basePoint);

                // zoom
                NativeMatrix44Adaptor S = NativeMatrix44Adaptor.Identity;
                S.SetScaling(allScale);

                // Recover the coordinate of the base point
                NativeMatrix44Adaptor T_1 = T.Inverse as NativeMatrix44Adaptor;

                NativeMatrix44Adaptor R = (T_1 * S * T) as NativeMatrix44Adaptor;
                m_Matrix2d = new NativeMatrix2dAdaptor(R.m_Matrix2d);
            }

            return this;
        }
 // Rotate the angle is radian
 public override Matrix44Adaptor SetRotate(double AngleThita, UnitVectorAdaptor axis, PointAdaptor basePoint)
 {
     Debug.Assert(false, "NO IMP");
     return null;
 }
 public override double DistanceTo(PointAdaptor pointProxy)
 {
     Debug.Assert(false, "NO IMP");
     return 0;
 }
 public override PointAdaptor ClosestPointTo(PointAdaptor point)
 {
     Debug.Assert(false, "NO IMP");
     return null;
 }
Exemple #13
0
 public GePoint()
 {
     m_Proxy = MathAdaptorFactory.Instance.CreatePointAdaptor(0, 0, 0);
 }
 protected abstract PointAdaptor OperatorMultiply(Matrix44Adaptor trans, PointAdaptor point);
 // Scale
 public abstract Matrix44Adaptor SetScaling(double allScale, PointAdaptor basePoint);
 // Rotate the angle is radian
 public abstract Matrix44Adaptor SetRotate(double AngleThita, UnitVectorAdaptor axis, PointAdaptor basePoint);
 public override bool IsEqualTo(PointAdaptor pointProxy)
 {
     Debug.Assert(false, "NO IMP");
     return false;
 }
Exemple #18
0
 public abstract bool IsEqualTo(PointAdaptor pointProxy);
Exemple #19
0
 public GePoint(double xx, double yy, double zz)
 {
     m_Proxy = MathAdaptorFactory.Instance.CreatePointAdaptor(xx, yy, zz);
 }
 // Scale
 public override Matrix44Adaptor SetScaling(double allScale, PointAdaptor basePoint)
 {
     Debug.Assert(false, "NO IMP");
     return null;
 }
Exemple #21
0
 public abstract double DistanceTo(PointAdaptor pointProxy);
Exemple #22
0
 public GePoint(GePoint src)
 {
     m_Proxy = MathAdaptorFactory.Instance.CreatePointAdaptor(
         src.X, src.Y, src.Z);
 }
Exemple #23
0
 public abstract PointAdaptor ClosestPointTo(PointAdaptor point);
Exemple #24
0
 public GePoint(PointAdaptor proxy)
 {
     m_Proxy = proxy;
 }
        // Rotate the angle is radian
        public override Matrix44Adaptor SetRotate(double AngleThita, UnitVectorAdaptor axis, PointAdaptor basePoint)
        {
            Debug.Assert(axis != null && basePoint != null);
            if (!(axis != null && basePoint != null)) return this;

            UnitizeSubmatrixA();

            // Translation the origin to base point
            NativeMatrix44Adaptor TA = NativeMatrix44Adaptor.Identity;

            NativePointAdaptor origin = new NativePointAdaptor(0, 0, 0);
            TA.SetTranslation(origin - basePoint);

            // Rotate the axis by X'-axis to X'-Z' plane
            double CosAlpha = 0;
            double SinAlpha = 0;
            double v = System.Math.Sqrt(axis.Y * axis.Y
                 + axis.Z * axis.Z);
            if (MathUtil.IsTwoDoubleEqual(v, 0))
            {
                // The axis is parallel to X-axis
                CosAlpha = 1;
                SinAlpha = 0;
            }
            else
            {
                CosAlpha = axis.Z / v;
                SinAlpha = axis.Y / v;
            }

            NativeMatrix44Adaptor Rx = NativeMatrix44Adaptor.Identity;
            Rx[1, 1] = CosAlpha;
            Rx[1, 2] = -SinAlpha;
            Rx[2, 1] = SinAlpha;
            Rx[2, 2] = CosAlpha;

            // Rotate the axis by Y'-axis to Z'-axis
            double u = axis.Length();

            double CosBeta = v / u;
            double SinBeta = -axis.X / u;

            NativeMatrix44Adaptor Ry = NativeMatrix44Adaptor.Identity;
            Ry[0, 0] = CosBeta;
            Ry[0, 2] = SinBeta;
            Ry[2, 0] = -SinBeta;
            Ry[2, 2] = CosBeta;

            // Rotate by Z'
            double CosThita = System.Math.Cos(AngleThita);
            double SinThita = System.Math.Sin(AngleThita);
            NativeMatrix44Adaptor Rz = NativeMatrix44Adaptor.Identity;
            Rz[0, 0] = CosThita;
            Rz[0, 1] = -SinThita;
            Rz[1, 0] = SinThita;
            Rz[1, 1] = CosThita;

            // Get the inverse matrix of the above step
            NativeMatrix44Adaptor Ry_1 = Ry.Inverse as NativeMatrix44Adaptor;
            NativeMatrix44Adaptor Rx_1 = Rx.Inverse as NativeMatrix44Adaptor;
            NativeMatrix44Adaptor TA_1 = TA.Inverse as NativeMatrix44Adaptor;

            // The transform result
            Matrix44Adaptor R = TA_1 * Rx_1 * Ry_1 * Rz * Ry * Rx * TA;

            // Save the result
            for (int row = 0; row < 3; row++)
                for (int column = 0; column < 3; column++)
                    m_Matrix2d[row, column] = R[row, column];

            return this;
        }
 protected override PointAdaptor OperatorMultiply(Matrix44Adaptor trans, PointAdaptor point)
 {
     Debug.Assert(false, "NO IMP");
     return null;
 }