Ejemplo n.º 1
0
        /// <summary>
        /// 求被分割一部分的圆柱体表面每一圈的点
        /// </summary>
        /// <param name="divisionNumber">一圈的三角形的个数</param>
        /// <param name="surplsAngle">被切后圆截面所剩的角度</param>
        /// <param name="unitVectorU">下底圆所在平面上一个向量U</param>
        /// <param name="unitVectorV">下底圆所在平面上一个向量与U垂足的向量V</param>
        /// <returns></returns>
        private List <List <Point> > GetSurfaceDivisionTrianglePoints(int divisionNumber, double surplsAngle, SpectVector unitVectorU, SpectVector unitVectorV)
        {
            List <List <Point> > divisionTrianglePoints = new List <List <Point> >();
            RayInfo ZVectorRay = new RayInfo(this.bottomCirclePoint, this.topCirclePoint);
            double  H          = this.topCirclePoint.GetDistance(this.bottomCirclePoint);
            double  L          = surplsAngle / 360 * 2 * Math.PI * this.radius;
            double  a          = L / divisionNumber;
            double  h          = Math.Sqrt(3) * a / 2;
            int     j          = 0;
            double  sumd       = 0;
            double  beta       = (surplsAngle * Math.PI / 180) / (2 * divisionNumber);
            bool    flag       = true;
            Point   currentCenterPoint;

            while (flag)
            {
                if (sumd < H)
                {
                    currentCenterPoint = ZVectorRay.GetPointOnRayVector(j * h);
                }
                else
                {
                    flag = false;
                    currentCenterPoint = this.topCirclePoint;
                }
                List <Point> circlePoints = new List <Point>();
                //第一个点
                circlePoints.Add(this.GetPointInCircumference(currentCenterPoint, this.radius, unitVectorU, unitVectorV, 0.01));
                int i = 1;
                if (j % 2 == 0)//处于偶数层时
                {
                    while (i < divisionNumber)
                    {
                        circlePoints.Add(this.GetPointInCircumference(currentCenterPoint, this.radius, unitVectorU, unitVectorV, 2 * i * beta));
                        i++;
                    }
                }
                else//处于奇数层,奇数层要比偶数层多一个点
                {
                    while (i <= divisionNumber)
                    {
                        circlePoints.Add(this.GetPointInCircumference(currentCenterPoint, this.radius, unitVectorU, unitVectorV, (2 * i - 1) * beta));
                        i++;
                    }
                }
                //最后一个点
                circlePoints.Add(this.GetPointInCircumference(currentCenterPoint, this.radius, unitVectorU, unitVectorV, surplsAngle * Math.PI / 180 - 0.01));
                divisionTrianglePoints.Add(circlePoints);
                j++;
                sumd += h;
            }
            return(divisionTrianglePoints);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 求被分割一部分的圆台体表面的三角面单元
        /// </summary>
        /// <param name="divisionNumber">圆弧角的细分次数</param>
        /// <param name="surplsAngle">下底面所剩部分的角度</param>
        /// <param name="unitVectorU">下底圆所在平面上一个向量U</param>
        /// <param name="unitVectorV">下底圆所在平面上一个向量与U垂足的向量V</param>
        /// <returns></returns>
        public List <List <Triangle> > GetTruncatedSurfaceDivisionTriangles(int divisionNumber, double surplsAngle, SpectVector unitVectorU, SpectVector unitVectorV)
        {
            //参考论文:基本体素的三角形面单元剖分方法
            List <List <Triangle> > divisinTriangles = new List <List <Triangle> >();
            RayInfo circleCenterPointsRay            = new RayInfo(this.bottomCenterPoint, this.topCenterPoint);
            double  h                  = this.bottomCenterPoint.GetDistance(this.topCenterPoint);//圆台体的高
            double  l                  = Math.Sqrt((h * h + Math.Pow(this.bottomCircleRadius - this.topCircleRadius, 2)));
            double  L                  = this.bottomCircleRadius * l / (this.bottomCircleRadius - this.topCircleRadius);
            double  sinB               = h / l;
            double  theta              = 2 * Math.PI * this.bottomCircleRadius / L;//弧度制
            double  particalTheta      = surplsAngle / 360 * theta;
            int     j                  = 0;
            bool    flag               = true;
            double  alpha              = particalTheta / divisionNumber;
            double  triangleSideLength = 2 * L * Math.Sin(alpha / 2);//正三角形初始边长
            double  d                  = Math.Sqrt(3) * triangleSideLength / 2 + L - L * Math.Cos(alpha / 2);
            double  beta               = (surplsAngle * Math.PI / 180) / (2 * divisionNumber - 1);
            double  L1                 = L;
            double  sumd               = d;
            double  r1                 = L1 * theta / (2 * Math.PI);// 弧长除以2*PI
            Point   currentCenterPoint = this.bottomCenterPoint;

            while (flag)
            {
                double L2, r2, i = 0;
                Point  nextCenterPoint;
                if (sumd < l)
                {
                    L2 = L1 - d;
                    nextCenterPoint = circleCenterPointsRay.GetPointOnRayVector(sumd * sinB);
                }
                else
                {
                    L2              = L - l;
                    flag            = false;
                    nextCenterPoint = this.topCenterPoint;
                }
                r2 = L2 * theta / (2 * Math.PI);
                double k = 1, r3;
                Point  tempPoint;
                if (j % 2 == 0)//r1和r2交换
                {
                    r3                 = r1;
                    r1                 = r2;
                    r2                 = r3;
                    k                  = -1;
                    tempPoint          = currentCenterPoint;
                    currentCenterPoint = nextCenterPoint;
                    nextCenterPoint    = tempPoint;
                }
                List <Triangle> oneCircleTriangles = new List <Triangle>();
                while (i < 2 * divisionNumber)
                {
                    Point vertex1 = new Point(), vertex2 = new Point(), vertex3 = new Point(); //三角面的三个点
                    vertex1 = GetPointInCircumference(nextCenterPoint, r2, unitVectorU, unitVectorV, i * beta);
                    if (j % 2 == 1 && i == 0)                                                  //在单数的开始边界时
                    {
                        vertex2 = GetPointInCircumference(currentCenterPoint, r1, unitVectorU, unitVectorV, i * beta + 0.01);
                    }
                    else if (j % 2 == 1 && i == 2 * divisionNumber - 1)//在单数的结束边界时
                    {
                        vertex2 = GetPointInCircumference(currentCenterPoint, r1, unitVectorU, unitVectorV, i * beta - 0.01);
                    }
                    else
                    {
                        vertex2 = GetPointInCircumference(currentCenterPoint, r1, unitVectorU, unitVectorV, (i - k) * beta);
                    }
                    if (j % 2 == 0 && i == 0) //在双数开始边界时
                    {
                        vertex3 = GetPointInCircumference(currentCenterPoint, r1, unitVectorU, unitVectorV, i * beta + 0.01);
                    }
                    else if (j % 2 == 0 && i == 2 * divisionNumber - 1)//在双数结束边界时
                    {
                        vertex3 = GetPointInCircumference(currentCenterPoint, r1, unitVectorU, unitVectorV, i * beta - 0.01);
                    }
                    else
                    {
                        vertex3 = GetPointInCircumference(currentCenterPoint, r1, unitVectorU, unitVectorV, (i + k) * beta);
                    }
                    oneCircleTriangles.Add(new Triangle(vertex1, vertex2, vertex3));
                    r3                 = r1;
                    r1                 = r2;
                    r2                 = r3;
                    k                  = -k;
                    tempPoint          = currentCenterPoint;
                    currentCenterPoint = nextCenterPoint;
                    nextCenterPoint    = tempPoint;
                    i++;
                }
                divisinTriangles.Add(oneCircleTriangles);
                //
                if (this.bottomCenterPoint.GetDistance(currentCenterPoint) < this.bottomCenterPoint.GetDistance(nextCenterPoint))
                {
                    currentCenterPoint = nextCenterPoint;
                }
                L1 = Math.Min(L1, L2);
                r1 = L1 * theta / (Math.PI * 2);
                triangleSideLength = 2 * L1 * Math.Sin(alpha / 2);
                d     = Math.Sqrt(3) * triangleSideLength / 2 + L1 - L1 * Math.Cos(alpha / 2);
                sumd += d;
                j++;
            }

            return(divisinTriangles);
        }
Ejemplo n.º 3
0
        public Point GetCrossPointWithRay(RayInfo oneRay)
        {
            double       high        = this.bottomCirclePoint.GetDistance(this.topCirclePoint);
            List <Point> crossPoints = this.Intersect(this.bottomCirclePoint, this.topCirclePoint, this.radius, high, oneRay.Origin, oneRay.GetPointOnRayVector(1));

            if (crossPoints.Count == 1)
            {
                return(crossPoints[0]);
            }
            if (crossPoints.Count > 1)
            {
                Point nearestPoint = crossPoints[0];
                for (int j = 1; j < crossPoints.Count; j++)
                {
                    if (nearestPoint.GetDistance(oneRay.Origin) > crossPoints[j].GetDistance(oneRay.Origin))
                    {
                        nearestPoint = crossPoints[j];
                    }
                }
                return(nearestPoint);
            }
            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 求被分割一部分的圆台体表面每个分割圆上的点
        /// </summary>
        /// <param name="divisionNumber">圆弧角的细分次数</param>
        /// <param name="surplsAngle">下底面所剩部分的角度</param>
        /// <param name="unitVectorU">下底圆所在平面上一个向量U</param>
        /// <param name="unitVectorV">下底圆所在平面上一个向量与U垂足的向量V</param>
        /// <returns></returns>
        private List <List <Point> > GetConeSurfaceDivisionTrianglePoints(int divisionNumber, double surplsAngle, SpectVector unitVectorU, SpectVector unitVectorV)
        {
            //参考论文:基本体素的三角形面单元剖分方法-李鸿亮
            //现在每个圆上取点,再组成三角面
            List <List <Point> > divisionTrianglePoints = new List <List <Point> >();
            RayInfo circleCenterPointsRay = new RayInfo(this.bottomCenterPoint, this.topCenterPoint);
            double  h                  = this.bottomCenterPoint.GetDistance(this.topCenterPoint);//圆台体的高
            double  l                  = Math.Sqrt((h * h + Math.Pow(this.bottomCircleRadius - this.topCircleRadius, 2)));
            double  L                  = this.bottomCircleRadius * l / (this.bottomCircleRadius - this.topCircleRadius);
            double  sinB               = h / l;
            double  theta              = 2 * Math.PI * this.bottomCircleRadius / L;//弧度制
            double  particalTheta      = surplsAngle / 360 * theta;
            int     j                  = 0;
            int     I                  = 2 * divisionNumber + 1;
            bool    flag               = true;
            double  alpha              = particalTheta / divisionNumber;
            double  triangleSideLength = 2 * L * Math.Sin(alpha / 2);//正三角形初始边长
            double  d                  = Math.Sqrt(3) * triangleSideLength / 2 + L - L * Math.Cos(alpha / 2);
            double  beta               = (surplsAngle * Math.PI / 180) / (2 * divisionNumber);
            double  currentL           = L;
            double  sumd               = 0;
            double  r                  = currentL * theta / (2 * Math.PI);// 弧长除以2*PI

            while (flag)
            {
                Point currentCenterPoint;
                if (sumd < l)
                {
                    currentCenterPoint = circleCenterPointsRay.GetPointOnRayVector(sumd * sinB);
                }
                else
                {
                    flag = false;
                    currentCenterPoint = this.topCenterPoint;
                }
                List <Point> circlePoints = new List <Point>();
                int          i            = 1;
                //第一个点
                circlePoints.Add(this.GetPointInCircumference(currentCenterPoint, r, unitVectorU, unitVectorV, 0.01));
                if (j % 2 == 0)//处于偶数层时
                {
                    while (i < divisionNumber)
                    {
                        circlePoints.Add(this.GetPointInCircumference(currentCenterPoint, r, unitVectorU, unitVectorV, 2 * i * beta));
                        i++;
                    }
                }
                else//处于奇数层,奇数层要比偶数层多一个点
                {
                    while (i <= divisionNumber)
                    {
                        circlePoints.Add(this.GetPointInCircumference(currentCenterPoint, r, unitVectorU, unitVectorV, (2 * i - 1) * beta));
                        i++;
                    }
                }
                //最后一个点
                circlePoints.Add(this.GetPointInCircumference(currentCenterPoint, r, unitVectorU, unitVectorV, surplsAngle * Math.PI / 180 - 0.01));
                divisionTrianglePoints.Add(circlePoints);
                //
                sumd              += d;
                currentL           = currentL - d;
                r                  = currentL * theta / (Math.PI * 2);
                triangleSideLength = 2 * currentL * Math.Sin(alpha / 2);
                d                  = Math.Sqrt(3) * triangleSideLength / 2 + currentL - currentL * Math.Cos(alpha / 2);
                //   sumd += d;
                j++;
            }
            return(divisionTrianglePoints);
        }