// // Do these segments overlay this angle? // public bool IsIncludedAngle(Segment seg1, Segment seg2) { // Do not allow the same segment. if (seg1.StructurallyEquals(seg2)) { return(false); } // Check direct inclusion if (seg1.Equals(ray1) && seg2.Equals(ray2) || seg1.Equals(ray2) && seg2.Equals(ray1)) { return(true); } // Check overlaying angle Point shared = seg1.SharedVertex(seg2); if (shared == null) { return(false); } Angle thatAngle = new Angle(seg1.OtherPoint(shared), shared, seg2.OtherPoint(shared)); return(this.Equates(thatAngle)); }
/// <summary> /// Figure out what possible segment combinations are before showing the window. /// </summary> protected override void OnShow() { options = new Dictionary <GeometryTutorLib.ConcreteAST.Segment, List <GeometryTutorLib.ConcreteAST.Segment> >(); //Get a list of all congruent segment givens List <GroundedClause> psegs = new List <GroundedClause>(); foreach (GroundedClause gc in currentGivens) { GeometricParallel pseg = gc as GeometricParallel; if (pseg != null) { psegs.Add(pseg); } } //Pick a first segment... foreach (GeometryTutorLib.ConcreteAST.Segment ts1 in parser.backendParser.implied.segments) { List <GeometryTutorLib.ConcreteAST.Segment> possible = new List <GeometryTutorLib.ConcreteAST.Segment>(); GeometryTutorLib.ConcreteAST.Segment s1 = new GeometryTutorLib.ConcreteAST.Segment(ts1.Point1, ts1.Point2); //... and see what other segments are viable second options. foreach (GeometryTutorLib.ConcreteAST.Segment ts2 in parser.backendParser.implied.segments) { GeometryTutorLib.ConcreteAST.Segment s2 = new GeometryTutorLib.ConcreteAST.Segment(ts2.Point1, ts2.Point2); if (s1.IsParallelWith(s2)) { GeometricParallel pseg = new GeometricParallel(s1, s2); if (!s1.StructurallyEquals(s2) && !StructurallyContains(psegs, pseg)) { possible.Add(s2); } } } //If we found a possible list of combinations, add it to the dictionary if (possible.Count > 0) { options.Add(s1, possible); } } //Set the options of the segment1 combo box segment1.ItemsSource = null; //Graphical refresh segment1.ItemsSource = options.Keys; }
public void GetOtherSides(Segment s, out Segment outSeg1, out Segment outSeg2) { outSeg1 = null; outSeg2 = null; if (s.StructurallyEquals(SegmentA)) { outSeg1 = SegmentB; outSeg2 = SegmentC; } else if (s.StructurallyEquals(SegmentB)) { outSeg1 = SegmentA; outSeg2 = SegmentC; } else if (s.StructurallyEquals(SegmentC)) { outSeg1 = SegmentA; outSeg2 = SegmentB; } }
private List<KeyValuePair<Segment, double>> CalcSides(RightTriangle tri, Angle rightAngle, Angle knownAngle, double knownAngleVal, Segment knownSeg, double knownSegVal) { // // Determine the nature of the known Segment w.r.t. to the known angle. // Segment hypotenuse = tri.GetHypotenuse(); // Hypotenuse known if (knownSeg.StructurallyEquals(hypotenuse)) { return CalcSidesHypotenuseKnown(tri, knownAngle, knownAngleVal, hypotenuse, knownSegVal); } else { return CalcSidesHypotenuseUnknown(tri, knownAngle, knownAngleVal, knownSeg, knownSegVal); } }
public static Quadrilateral GenerateQuadrilateral(Segment s1, Segment s2, Segment s3, Segment s4) { // ____ // | // |____ // Check a C shape of 3 segments; the 4th needs to be opposite Segment top; Segment bottom; Segment left = AcquireMiddleSegment(s1, s2, s3, out top, out bottom); // Check C for the top, bottom, and right sides if (left == null) { return(null); } Segment right = s4; Segment tempOut1, tempOut2; Segment rightMid = AcquireMiddleSegment(top, bottom, right, out tempOut1, out tempOut2); // The middle segment we acquired must match the 4th segment if (!right.StructurallyEquals(rightMid)) { return(null); } // // The top / bottom cannot cross; bowtie or hourglass shape // A valid quadrilateral will have the intersections outside of the quad, that is defined // by the order of the three points: intersection and two endpts of the side // Point intersection = top.FindIntersection(bottom); // Check for parallel lines, then in-betweenness if (intersection != null && !double.IsNaN(intersection.X) && !double.IsNaN(intersection.Y)) { if (Segment.Between(intersection, top.Point1, top.Point2)) { return(null); } if (Segment.Between(intersection, bottom.Point1, bottom.Point2)) { return(null); } } // The left / right cannot cross; bowtie or hourglass shape intersection = left.FindIntersection(right); // Check for parallel lines, then in-betweenness if (intersection != null && !double.IsNaN(intersection.X) && !double.IsNaN(intersection.Y)) { if (Segment.Between(intersection, left.Point1, left.Point2)) { return(null); } if (Segment.Between(intersection, right.Point1, right.Point2)) { return(null); } } // // Verify that we have 4 unique points; And not different shapes (like a star, or triangle with another segment) // List <Point> pts = new List <Point>(); pts.Add(left.SharedVertex(top)); pts.Add(left.SharedVertex(bottom)); pts.Add(right.SharedVertex(bottom)); pts.Add(right.SharedVertex(top)); for (int i = 0; i < pts.Count - 1; i++) { for (int j = i + 1; j < pts.Count; j++) { if (pts[i].StructurallyEquals(pts[j])) { return(null); } } } return(new Quadrilateral(left, right, top, bottom)); }
// // Do these segments overlay this angle? // public bool IsIncludedAngle(Segment seg1, Segment seg2) { // Do not allow the same segment. if (seg1.StructurallyEquals(seg2)) return false; // Check direct inclusion if (seg1.Equals(ray1) && seg2.Equals(ray2) || seg1.Equals(ray2) && seg2.Equals(ray1)) return true; // Check overlaying angle Point shared = seg1.SharedVertex(seg2); if (shared == null) return false; Angle thatAngle = new Angle(seg1.OtherPoint(shared), shared, seg2.OtherPoint(shared)); return this.Equates(thatAngle); }
public double GetSegmentLength(Segment thatSeg) { if (thatSeg == null) { // throw new ArgumentException("Why is the angle null?"); return -1; } foreach (KeyValuePair<Segment, double> segPair in segments) { if (thatSeg.StructurallyEquals(segPair.Key)) return segPair.Value; } return -1; }