// // Can this relationship can strengthened to a Midpoint? // public Strengthened CanBeStrengthened() { if (Utilities.CompareValues(Point.calcDistance(point, segment.Point1), Point.calcDistance(point, segment.Point2))) { return(new Strengthened(this, new Midpoint(this))); } return(null); }
private bool VerifyCongruentTriangles(out List <Point> orderedTriOnePts, out List <Point> orderedTriTwoPts) { // Ensure the points are ordered appropriately. // CongruentTriangle ensures points are mapped. List <Angle> triOneAngles = ct1.angles; List <Angle> triTwoAngles = ct2.angles; orderedTriOnePts = new List <Point>(); orderedTriTwoPts = new List <Point>(); bool[] marked = new bool[3]; // // Check angles correspondence // for (int i = 0; i < triOneAngles.Count; i++) { for (int j = 0; j < triTwoAngles.Count; j++) { if (!marked[j]) { if (Utilities.CompareValues(triOneAngles[i].measure, triTwoAngles[j].measure)) { orderedTriOnePts.Add(triOneAngles[i].GetVertex()); orderedTriTwoPts.Add(triTwoAngles[j].GetVertex()); marked[j] = true; break; } } } } // Similarity has failed if (marked.Contains(false)) { return(false); } // // The established correspondence can now be verified with segment lengths // for (int v = 0; v < 2; v++) { double seg1Distance = Point.calcDistance(orderedTriOnePts[v], orderedTriOnePts[v + 1 < 3 ? v + 1 : 0]); double seg2Distance = Point.calcDistance(orderedTriTwoPts[v], orderedTriTwoPts[v + 1 < 3 ? v + 1 : 0]); if (!Utilities.CompareValues(seg1Distance, seg2Distance)) { return(false); } } return(true); }
/// <summary> /// Create a new ConcreteSegment. /// </summary> /// <param name="p1">A point defining the segment.</param> /// <param name="p2">Another point defining the segment.</param> public Segment(Point p1, Point p2) : base() { Point1 = p1; Point2 = p2; Length = Point.calcDistance(p1, p2); Slope = (p2.Y - p1.Y) / (p2.X - p1.X); Utilities.AddUniqueStructurally(Point1.getSuperFigures(), this); Utilities.AddUniqueStructurally(Point2.getSuperFigures(), this); collinear = new List <Point>(); // We add the two points arbitrarily since this list is vacuously ordered. collinear.Add(p1); collinear.Add(p2); }
// // Is thatSegment a bisector of this segment in terms of the coordinatization from the UI? // public Point CoordinateBisector(Segment thatSegment) { // Do these segments intersect within both sets of stated endpoints? Point intersection = this.FindIntersection(thatSegment); if (!this.PointLiesOnAndExactlyBetweenEndpoints(intersection)) { return(null); } if (!thatSegment.PointLiesOnAndBetweenEndpoints(intersection)) { return(null); } // Do they intersect in the middle of this segment return(Utilities.CompareValues(Point.calcDistance(this.Point1, intersection), Point.calcDistance(this.Point2, intersection)) ? intersection : null); }
public static Circle ConstructCircle(Point p1, Point p2, Point p3) { // // Find the center of the circle. // Segment chord1 = new Segment(p1, p2); Segment chord2 = new Segment(p2, p3); Segment perpBis1 = chord1.GetPerpendicular(chord1.Midpoint()); Segment perpBis2 = chord2.GetPerpendicular(chord2.Midpoint()); Point center = perpBis1.FindIntersection(perpBis2); // // Radius is the distance between the circle and any of the original points. // return(new Circle(center, Point.calcDistance(center, p1))); }
// // The center lies inside the polygon and there are no intersection points with the sides. // private bool ContainsCircle(Circle that) { // Center lies (strictly) inside of this sector if (!this.PointLiesInside(that.center)) { return(false); } // As a simple heuristic, the radii lengths must support inclusion. if (Point.calcDistance(this.theArc.theCircle.center, that.center) + that.radius > this.theArc.theCircle.radius) { return(false); } // // Any intersections between the sides of the sector and the circle must be tangent. // Point pt1 = null; Point pt2 = null; that.FindIntersection(radius1, out pt1, out pt2); if (pt2 != null) { return(false); } that.FindIntersection(radius2, out pt1, out pt2); if (pt2 != null) { return(false); } that.FindIntersection(this.theArc, out pt1, out pt2); if (pt2 != null) { return(false); } return(true); }
/// <summary> /// Find the measure of the angle (in radians) specified by the three points. /// </summary> /// <param name="a">A point defining the angle.</param> /// <param name="b">A point defining the angle. This is the point the angle is actually at.</param> /// <param name="c">A point defining the angle.</param> /// <returns>The measure of the angle (in radians) specified by the three points.</returns> public static double findAngle(Point a, Point b, Point c) { double v1x = a.X - b.X; double v1y = a.Y - b.Y; double v2x = c.X - b.X; double v2y = c.Y - b.Y; double dotProd = v1x * v2x + v1y * v2y; double cosAngle = dotProd / (Point.calcDistance(a, b) * Point.calcDistance(b, c)); // Avoid minor calculation issues and retarget the given value to specific angles. // 0 or 180 degrees if (Utilities.CompareValues(Math.Abs(cosAngle), 1)) { cosAngle = cosAngle < 0 ? -1 : 1; } // 90 degrees if (Utilities.CompareValues(cosAngle, 0)) { cosAngle = 0; } return(Math.Acos(cosAngle)); }
public static bool LooseBetween(Point M, Point A, Point B) { return(Utilities.LooseCompareValues(Point.calcDistance(A, M) + Point.calcDistance(M, B), Point.calcDistance(A, B))); }