Beispiel #1
0
        //
        //
        // Given 1 side of a right triangle and an angle, calculate the other 2 sides.
        //
        //
        private List<KeyValuePair<Segment, double>> CalcSidesHypotenuseKnown(RightTriangle tri, Angle knownAngle, double knownAngleVal, Segment hypotenuse, double hypotVal)
        {
            List<KeyValuePair<Segment, double>> pairs = new List<KeyValuePair<Segment, double>>();

            double oppSideLength = hypotVal * Math.Sin(Angle.toRadians(knownAngleVal));
            pairs.Add(new KeyValuePair<Segment,double>(tri.GetOppositeSide(knownAngle), oppSideLength));

            double adjSideLength = hypotVal * Math.Cos(Angle.toRadians(knownAngleVal));
            pairs.Add(new KeyValuePair<Segment, double>(knownAngle.OtherRay(hypotenuse), adjSideLength));

            return pairs;
        }
Beispiel #2
0
        private List<KeyValuePair<Segment, double>> CalcSidesHypotenuseUnknown(RightTriangle tri, Angle knownAngle, double knownAngleVal, Segment knownSide, double sideVal)
        {
            List<KeyValuePair<Segment, double>> pairs = new List<KeyValuePair<Segment, double>>();

            Segment hypotenuse = tri.GetHypotenuse();
            Segment oppSideOfAngle = tri.GetOppositeSide(knownAngle);
            Segment adjacent = knownAngle.OtherRay(hypotenuse);

            if (oppSideOfAngle.StructurallyEquals(knownSide))
            {
                double adjVal = sideVal / Math.Tan(Angle.toRadians(knownAngleVal));

                pairs.Add(new KeyValuePair<Segment, double>(adjacent, adjVal));
                pairs.Add(new KeyValuePair<Segment, double>(hypotenuse, Math.Sqrt(sideVal * sideVal + adjVal * adjVal)));
            }
            else if (adjacent.StructurallyEquals(knownSide))
            {
                double oppVal = sideVal * Math.Tan(Angle.toRadians(knownAngleVal));

                pairs.Add(new KeyValuePair<Segment, double>(oppSideOfAngle, oppVal));
                pairs.Add(new KeyValuePair<Segment, double>(hypotenuse, Math.Sqrt(sideVal * sideVal + oppVal * oppVal)));
            }

            return pairs;
        }
        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;
        }