Beispiel #1
0
        /// <summary>
        /// 计算 一个面和相关拟合面的平行度;
        /// </summary>
        /// <param name="coor3D"></param>
        /// <param name="xArray"></param>
        /// <param name="yArray"></param>
        /// <param name="zArray"></param>
        /// <returns></returns>
        public double MeasureParallelism(Plane3D coor3D, double[] xArray, double[] yArray, double[] zArray)
        {
            Trace.Assert(xArray.Length == yArray.Length && xArray.Length == zArray.Length);
            if (xArray.Length <= 0)
            {
                return(-1);
            }

            Plane3D plane1   = new Plane3D(0, 0, 0, 0);
            Plane3D plane2   = new Plane3D(0, 0, 0, 0);
            double  maxValue = Double.MinValue;
            double  minValue = Double.MaxValue;

            for (int t = 0; t < xArray.Length; t++)
            {
                //求垂线
                GetNormaline(xArray[t], yArray[t], zArray[t], ref plane1, ref plane2);
                double xCross = 0; double yCross = 0; double zCross = 0;
                //垂线与coorSurface的交点
                coor3D.CrossLine(plane1, plane2, ref xCross, ref yCross, ref zCross);

                double dist = GetDistance(xCross, yCross, zCross);
                if (dist < minValue)
                {
                    minValue = dist;
                }
                if (dist > maxValue)
                {
                    maxValue = dist;
                }
            }
            return(maxValue - minValue);
        }
Beispiel #2
0
        /// <summary>
        /// 根据一个点求取一个垂线:
        /// 垂线方程:plane1 plane2 相交组成
        /// </summary>
        /// <param name="xValue"></param>
        /// <param name="yValue"></param>
        /// <param name="zValue"></param>
        /// <param name="plane1"></param>
        /// <param name="plane2"></param>
        public bool GetNormaline(double xValue, double yValue, double zValue, ref Plane3D plane1, ref Plane3D plane2)
        {
            if (Math.Abs(A) < 1e-6 && Math.Abs(B) < 1e-6 && Math.Abs(C) < 1e-6)
            {
                return(false);
            }

            //垂线方程满足: A/(x-x0) = B/(y-y0) = C/(z-z0);
            plane1 = new Plane3D(B, -A, 0, (float)(B * xValue - A * yValue));
            plane2 = new Plane3D(C, 0, -A, (float)(C * xValue - A * zValue));
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// 计算直线与该平面的交点
        /// </summary>
        /// <param name="line1"></param>
        /// <param name="line2"></param>
        /// <param name="xCross"></param>
        /// <param name="yCross"></param>
        /// <param name="zCross"></param>
        /// <returns></returns>
        public void CrossLine(Plane3D line1, Plane3D line2, ref double xCross, ref double yCross,
                              ref double zCross)
        {
            List <double> matrix = new List <double>()
            {
                line1.A, line1.B, line1.C, line2.A, line2.B, line2.C, A, B, C
            };
            List <double> InvMatrix = null;
            List <double> result    = null;

            cyUCSMeasure.MatrixInv3X3(matrix, out InvMatrix);
            List <double> mutArray = new List <double>()
            {
                line1.D, line2.D, D
            };

            cyUCSMeasure.Matrix_Mult3X1(InvMatrix, mutArray, out result);
            xCross = result[0]; yCross = result[1]; zCross = result[2];
        }