private void btn_Rectangle_Click(object sender, EventArgs e) { LoadValue(); var P1 = CAD.PickPoint(); var Line = CAD.CreateRectangle(P1, W, H); }
private void CreateRectangle(Curve2d C1, List <Curve2d> Cs) { var C2 = Cs.First(); var sp1 = C1.StartPoint; var ep1 = C1.EndPoint; var Ps1 = new List <Point2d> { sp1, ep1 }; var sp2 = C2.StartPoint; var ep2 = C2.EndPoint; var Ps2 = new List <Point2d> { sp2, ep2 }; var Ps = from p1 in Ps1 from p2 in Ps2 let d = p1.GetDistanceTo(p2) orderby d descending select new List <Point2d> { p1, p2 }; if (Ps.Any()) { var Points = Ps.First(); var Vec1 = CAD.GetVector(C1); var Vec2 = CAD.GetVector(Points[0], Points[1]); if (Vec1.GetAngleTo(Vec2) > Math.PI / 2) { Vec1 = -Vec1; } double Ang = Math.Abs(Vec1.GetAngleTo(Vec2)); var P1 = CAD.ToPoint3D(Points[0]); var P2 = CAD.ToPoint3D(Points[1]); CAD.CreateRectangle(P1, P2, Vec1, Ang); } }