public Parallel(Segment segment1, Segment segment2) : base() { this.segment1 = segment1; this.segment2 = segment2; if (!segment1.IsParallelWith(segment2)) { throw new ArgumentException("Given lines are not parallel: " + segment1 + " ; " + segment2); } }
public Parallelogram(Segment left, Segment right, Segment top, Segment bottom) : base(left, right, top, bottom) { if (!left.IsParallelWith(right)) { throw new ArgumentException("Given opposing segments are not parallel: " + left + " " + right); } if (!top.IsParallelWith(bottom)) { throw new ArgumentException("Given opposing segments are not parallel: " + top + " " + bottom); } }
public Trapezoid(Segment left, Segment right, Segment top, Segment bottom) : base(left, right, top, bottom) { if (left.IsParallelWith(right)) { if (left.Length > right.Length) { baseSegment = left; oppBaseSegment = right; leftLeg = top; rightLeg = bottom; } else { baseSegment = right; oppBaseSegment = left; leftLeg = top; rightLeg = bottom; } } else if (top.IsParallelWith(bottom)) { if (top.Length > bottom.Length) { baseSegment = top; oppBaseSegment = bottom; leftLeg = left; rightLeg = right; } else { baseSegment = bottom; oppBaseSegment = top; leftLeg = left; rightLeg = right; } } else { throw new ArgumentException("Quadrilateral does not define a trapezoid; no sides are parallel: " + this); } topLeftBaseAngle = GetAngle(new Angle(leftLeg, oppBaseSegment)); topRightBaseAngle = GetAngle(new Angle(rightLeg, oppBaseSegment)); bottomLeftBaseAngle = GetAngle(new Angle(leftLeg, baseSegment)); bottomRightBaseAngle = GetAngle(new Angle(rightLeg, baseSegment)); FindMedian(); }
// // Creates a basic S-Shape with standsOnEndpoints // // offThis ______ // | // offThat ______| // // Return <offThis, offThat> public KeyValuePair <Point, Point> CreatesBasicCShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } if (!this.StandsOnEndpoint()) { return(nullPair); } if (!thatInter.StandsOnEndpoint()) { return(nullPair); } // // Determine offThis and offThat // Segment transversal = this.AcquireTransversal(thatInter); Segment parallelThis = this.OtherSegment(transversal); Segment parallelThat = thatInter.OtherSegment(transversal); Point offThis = transversal.PointLiesOnAndBetweenEndpoints(parallelThis.Point1) ? parallelThis.Point2 : parallelThis.Point1; Point offThat = transversal.PointLiesOnAndBetweenEndpoints(parallelThat.Point1) ? parallelThat.Point2 : parallelThat.Point1; // Avoid S-shape scenario Segment crossingTester = new Segment(offThis, offThat); Point intersection = transversal.FindIntersection(crossingTester); // We may have parallel crossingTester and transversal; that's ok if (crossingTester.IsParallelWith(transversal)) { return(new KeyValuePair <Point, Point>(offThis, offThat)); } // S-shape if (transversal.PointLiesOnAndBetweenEndpoints(intersection)) { return(nullPair); } // C-Shape return(new KeyValuePair <Point, Point>(offThis, offThat)); }
/// <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; }
// // Creates a basic S-Shape with standsOnEndpoints // // offThis ______ // | // offThat ______| // // Return <offThis, offThat> public KeyValuePair<Point, Point> CreatesBasicCShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; if (!this.StandsOnEndpoint()) return nullPair; if (!thatInter.StandsOnEndpoint()) return nullPair; // // Determine offThis and offThat // Segment transversal = this.AcquireTransversal(thatInter); Segment parallelThis = this.OtherSegment(transversal); Segment parallelThat = thatInter.OtherSegment(transversal); Point offThis = transversal.PointLiesOnAndBetweenEndpoints(parallelThis.Point1) ? parallelThis.Point2 : parallelThis.Point1; Point offThat = transversal.PointLiesOnAndBetweenEndpoints(parallelThat.Point1) ? parallelThat.Point2 : parallelThat.Point1; // Avoid S-shape scenario Segment crossingTester = new Segment(offThis, offThat); Point intersection = transversal.FindIntersection(crossingTester); // We may have parallel crossingTester and transversal; that's ok if (crossingTester.IsParallelWith(transversal)) return new KeyValuePair<Point, Point>(offThis, offThat); // S-shape if (transversal.PointLiesOnAndBetweenEndpoints(intersection)) return nullPair; // C-Shape return new KeyValuePair<Point, Point>(offThis, offThat); }