首页 > 编程知识 正文

判断两条直线的夹角大小,两条直线夹角的定义

时间:2023-05-06 08:23:14 阅读:195598 作者:1327

/// <summary>
        /// 判断要素是否平行
        /// </summary>
        /// <returns></returns>
        protected bool GeometryParallel(IFeature pFeat,out Lineside pSide)
        {
            //double angleOfLine = Math.Atan2((Y2 - Y1), (X2 - X1)) * 180 / Math.PI; 
            //angleOfLine =Math.Abs( angleOfLine % 90);



            pSide = LeftOfLine(pArea.Centroid);


            double horizontalAngle = 30;///平行判断角度


            //var a = Math.Atan2(a2.Y - a1.Y, a2.X - a1.X);
            //var b = Math.Atan2(b2.Y - b1.Y, b2.X - b1.X); 
            double startx = Convert.ToDouble(pFeat.get_Value(m_startx));
            double starty = Convert.ToDouble(pFeat.get_Value(m_starty));
            double endx = Convert.ToDouble(pFeat.get_Value(m_endx));
            double endy = Convert.ToDouble(pFeat.get_Value(m_endy));


            var A = Math.Atan2(EndY - StartY, EndX - StartX);
            var B = Math.Atan2(endy - starty, endx - startx);
            double angleOfLine = (180 * (float)(B - A)) / Math.PI;
            angleOfLine = Math.Abs(angleOfLine);


            //自身小角度
            if (angleOfLine < horizontalAngle)
                return true;


            //接近180平行
            if (Math.Abs(angleOfLine - 180) < horizontalAngle)
                return true;


            return false;
        }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。