编程语言
首页 > 编程语言> > AutoCAD.Net/C#.Net QQ群:193522571 绘制椭圆及椭圆弧

AutoCAD.Net/C#.Net QQ群:193522571 绘制椭圆及椭圆弧

作者:互联网

这个椭圆好坑。

        /// <summary>
        /// 绘制椭圆及椭圆弧,注意当dX>dY时以X轴正方向为起始角,当dX<dY时以Y轴正方向为起始角
        /// </summary>
        /// <param name="db"></param>
        /// <param name="pt">椭圆中心点</param>
        /// <param name="dX">X轴轴长</param>
        /// <param name="dY">Y轴轴长</param>
        /// <param name="dStartAng">起始角(当dX>dY时以X轴正方向为起始角,当dX<dY时以Y轴正方向为起始角)</param>
        /// <param name="dEndAng">终止角(当dX>dY时以X轴正方向为起始角,当dX<dY时以Y轴正方向为起始角,注意方向为逆时针)</param>
        /// <returns></returns>
        public static ObjectId DrawEllipse(this Database db, Point3d pt,
                 double dX, double dY, double dStartAng = 0, double dEndAng = 360)
        {
            double dAngStart = dStartAng.DegreeToRadian();
            double dAngEnd = dEndAng.DegreeToRadian();

            //这个有点坑,长轴短轴要搞清楚
            Vector3d majorAxis = dX > dY ? new Vector3d(dX, 0, 0) : new Vector3d(0, dY, 0);
            //这个radio要弄清楚,必须小于1,不然就会出问题
            Ellipse ellipseArc = new Ellipse(pt, Vector3d.ZAxis, majorAxis, dX > dY ? dY / dX : dX / dY, dAngStart, dAngEnd);

            return db.AddToCurrentSpace(ellipseArc);
        }

 

标签:QQ,椭圆,时以,Vector3d,double,dX,dY,Net
来源: https://www.cnblogs.com/swtool/p/14975345.html