Esempio n. 1
0
        //
        // Is this triangle encased in the given, larger triangle.
        // That is, two sides are defined by the larger triangle and one side by the altitude
        //
        public bool IsDefinedBy(RightTriangle rt, Altitude altitude)
        {
            // The opposite side of the smaller triangle has to be a side of the larger triangle.
            if (!rt.HasSegment(this.GetOppositeSide(this.rightAngle)))
            {
                return(false);
            }

            // The smaller triangle's right angle must have a ray collinear with the altitude segment
            Segment altSegment = null;

            if (this.rightAngle.ray1.IsCollinearWith(altitude.segment))
            {
                altSegment = this.rightAngle.ray1;
            }
            else if (this.rightAngle.ray2.IsCollinearWith(altitude.segment))
            {
                altSegment = this.rightAngle.ray2;
            }
            if (altSegment == null)
            {
                return(false);
            }

            // The last segment needs to be collinear with a side of the larger triangle
            return(rt.LiesOn(this.rightAngle.OtherRayEquates(altSegment)));
        }
Esempio n. 2
0
        public override bool Equals(Object obj)
        {
            Altitude alt = obj as Altitude;

            if (alt == null)
            {
                return(false);
            }
            return(triangle.Equals(alt.triangle) && segment.Equals(alt.segment) && base.Equals(obj));
        }
Esempio n. 3
0
        public override bool StructurallyEquals(Object obj)
        {
            Altitude alt = obj as Altitude;

            if (alt == null)
            {
                return(false);
            }
            return(triangle.StructurallyEquals(alt.triangle) && segment.StructurallyEquals(alt.segment));
        }
Esempio n. 4
0
        //
        // Is this triangle encased in the given, larger triangle.
        // That is, two sides are defined by the larger triangle and one side by the altitude
        //
        public bool IsDefinedBy(RightTriangle rt, Altitude altitude)
        {
            // The opposite side of the smaller triangle has to be a side of the larger triangle.
            if (!rt.HasSegment(this.GetOppositeSide(this.rightAngle))) return false;

            // The smaller triangle's right angle must have a ray collinear with the altitude segment
            Segment altSegment = null;
            if (this.rightAngle.ray1.IsCollinearWith(altitude.segment))
            {
                altSegment = this.rightAngle.ray1;
            }
            else if (this.rightAngle.ray2.IsCollinearWith(altitude.segment))
            {
                altSegment = this.rightAngle.ray2;
            }
            if (altSegment == null) return false;

            // The last segment needs to be collinear with a side of the larger triangle
            return rt.LiesOn(this.rightAngle.OtherRayEquates(altSegment));
        }
        public static List<EdgeAggregator> InstantiateRight(RightTriangle rt, Altitude altitude, GroundedClause original)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // The altitude must connect the vertex defining the right angle and the opposite side.
            if (!altitude.segment.HasPoint(rt.rightAngle.GetVertex())) return newGrounded;

            // The other point of the altitude must lie on the opposite side of the triangle
            Point altPointOppRightAngle = altitude.segment.OtherPoint(rt.rightAngle.GetVertex());

            Segment oppositeSide = rt.GetOppositeSide(rt.rightAngle);

            if (!Segment.Between(altPointOppRightAngle, oppositeSide.Point1, oppositeSide.Point2)) return newGrounded;

            //
            // Find the two smaller right triangles in the candidate list (which should be in the list at this point)
            //
            RightTriangle first = null;
            RightTriangle second = null;
            foreach (RightTriangle smallerRT in candRightTriangles)
            {
                if (smallerRT.IsDefinedBy(rt, altitude))
                {
                    if (first == null)
                    {
                        first = smallerRT;
                    }
                    else
                    {
                        second = smallerRT;
                        break;
                    }
                }
            }

            // CTA: We did not check to see points aligned, but these are the original triangles from the figure
            GeometricSimilarTriangles gsts1 = new GeometricSimilarTriangles(rt, first);
            GeometricSimilarTriangles gsts2 = new GeometricSimilarTriangles(rt, second);
            GeometricSimilarTriangles gsts3 = new GeometricSimilarTriangles(first, second);

            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(original);
            antecedent.Add(altitude);

            newGrounded.Add(new EdgeAggregator(antecedent, gsts1, annotation));
            newGrounded.Add(new EdgeAggregator(antecedent, gsts2, annotation));
            newGrounded.Add(new EdgeAggregator(antecedent, gsts3, annotation));

            return newGrounded;
        }
Esempio n. 6
0
        private static List<EdgeAggregator> InstantiateToAltitude(Triangle triangle, Perpendicular perp, GroundedClause original)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Acquire the side of the triangle containing the intersection point
            // This point may or may not be directly on the triangle side
            Segment baseSegment = triangle.GetSegmentWithPointOnOrExtends(perp.intersect);
            if (baseSegment == null) return newGrounded;

            // The altitude must pass through the intersection point as well as the opposing vertex
            Point oppositeVertex = triangle.OtherPoint(baseSegment);

            Segment altitude = new Segment(perp.intersect, oppositeVertex);

            // The alitude must alig with the intersection
            if (!perp.ImpliesRay(altitude)) return newGrounded;

            // The opposing side must align with the intersection
            if (!perp.OtherSegment(altitude).IsCollinearWith(baseSegment)) return newGrounded;

            //
            // Create the new Altitude object
            //
            Altitude newAltitude = new Altitude(triangle, altitude);

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(triangle);
            antecedent.Add(original);

            newGrounded.Add(new EdgeAggregator(antecedent, newAltitude, annotation));

            //
            // Check if this induces a second altitude for a right triangle (although we don't know this is a strengthened triangle)
            // The intersection must be on the vertex of the triangle
            if (triangle.HasPoint(perp.intersect))
            {
                Angle possRightAngle = new Angle(triangle.OtherPoint(new Segment(perp.intersect, oppositeVertex)), perp.intersect, oppositeVertex);

                if (triangle.HasAngle(possRightAngle))
                {
                    Altitude secondAltitude = new Altitude(triangle, new Segment(perp.intersect, oppositeVertex));
                    newGrounded.Add(new EdgeAggregator(antecedent, secondAltitude, annotation));
                }
            }

            return newGrounded;
        }
Esempio n. 7
0
        private static List<EdgeAggregator> InstantiateFromAltitude(Intersection inter, Altitude altitude)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // The intersection should contain the altitude segment
            if (!inter.HasSegment(altitude.segment)) return newGrounded;

            // The triangle should contain the other segment in the intersection
            Segment triangleSide = altitude.triangle.CoincidesWithASide(inter.OtherSegment(altitude.segment));
            if (triangleSide == null) return newGrounded;
            if (!inter.OtherSegment(altitude.segment).HasSubSegment(triangleSide)) return newGrounded;

            //
            // Create the Perpendicular relationship
            //
            Strengthened streng = new Strengthened(inter, new Perpendicular(inter));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(inter);
            antecedent.Add(altitude);

            newGrounded.Add(new EdgeAggregator(antecedent, streng, annotation));

            return newGrounded;
        }