C# 计算两条相交线的角度和弧度

计算两条相交线的角度和弧度
            Point a1 = new Point(-1000, 0);
            Point a2 = new Point(1000, 0);
            Point b1 = new Point(30, 230);
            Point b2 = new Point(230, 330);
            using (Graphics g = this.CreateGraphics())
            {
                using (Pen p = new Pen(Color.Red, 2))
                {
                    g.DrawLine(p, a1, a2);
                    g.DrawLine(p, b1, b2);
                }
            }
            var a = Math.Atan2(a2.Y - a1.Y, a2.X - a1.X);
            var b = Math.Atan2(b2.Y - b1.Y, b2.X - b1.X);
            Console.WriteLine(180 * (b - a) / Math.PI);

 

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