计算两点连线与X轴正方向的夹角

 ///


        /// 计算两点连线与X轴正方向的夹角
        ///

        /// 三维点
        /// 三维点
        /// 两点连线与X轴正方向的夹角(弧度)
        public double GetRealAngle(Point3d startpt, Point3d endPt)
        {
            // 两点与X轴正向的夹角
            double angle = 0.0;
            if (endPt.Y >= startpt.Y)
            {
                Vector3d vec = new Vector3d(endPt.X - startpt.X, endPt.Y - startpt.Y, 0);
                angle = vec.GetAngleTo(Vector3d.XAxis);
                return angle;
            }
            else
            {
                Vector3d vec = new Vector3d(endPt.X - startpt.X, endPt.Y - startpt.Y, 0);
                angle = 2 * Math.PI - vec.GetAngleTo(Vector3d.XAxis);
                return angle;
            }
        }

#autocad二次开

你可能感兴趣的:(C#)