示例#1
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;
        }
示例#2
0
        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);
            }
        }