Esempio n. 1
0
        public override bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Check side-squared.
            if (ClassicArea(known) > 0) return true;

            // If not side-squared, check the general quadrilateral split into triangles.
            return base.CanAreaBeComputed(known);
        }
Esempio n. 2
0
        public override bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Central Angle
            if (known.GetAngleMeasure(this.theArc.GetCentralAngle()) < 0) return false;

            // Radius / Circle
            return theArc.theCircle.CanAreaBeComputed(known);
        }
Esempio n. 3
0
        //
        // Attempt trapezoidal formulas; if they fail, call the base method: splitting into triangles.
        //
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            if (calculatedHeight > 0)
            {
                double area = GetBaseBasedArea(calculatedHeight, known);
            }

            return base.GetArea(known);
        }
Esempio n. 4
0
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Check side-squared.
            double area = ClassicArea(known);

            if (area > 0) return area;

            // If not side-squared, check the general quadrilateral split into triangles.
            return base.GetArea(known);
        }
Esempio n. 5
0
        //
        // Acquire the height of the isosceles trapezoid: h = Sqrt(c^2 - 1/4 (b - a)^2)
        //
        public void CalculateHeight(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Check if the height has already been calculated.
            if (calculatedHeight > 0) return;

            // Calculate the height.
            double base1Length = known.GetSegmentLength(this.baseSegment);
            double base2Length = known.GetSegmentLength(this.oppBaseSegment);

            double isoSideLength = known.GetSegmentLength(this.leftLeg);
            if (isoSideLength < 0) isoSideLength = known.GetSegmentLength(this.rightLeg);

            if (base1Length < 0 || base2Length < 0 || isoSideLength < 0) return;

            this.calculatedHeight = Math.Sqrt(isoSideLength * isoSideLength - Math.Pow(base1Length - base2Length, 2) / 4.0);
        }
Esempio n. 6
0
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            double[] sideVals = new double[orderedSides.Count];

            for (int s = 0; s < orderedSides.Count; s++)
            {
                sideVals[s] = known.GetSegmentLength(orderedSides[s]);
            }

            // One pair of adjacent sides is required for the area computation.
            for (int s = 0; s < sideVals.Length; s++)
            {
                double baseVal = sideVals[s];
                double heightVal = sideVals[(s+1) % sideVals.Length];

                if (baseVal > 0 && heightVal > 0) return Area(baseVal, heightVal);
            }

            return SplitTriangleArea(known);
        }
Esempio n. 7
0
 public virtual double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
 {
     return -1;
 }
Esempio n. 8
0
        //
        // As a general mechanism, can we split up this quadrilateral into two triangles and find those individual areas?
        // We must try two combinations of triangle splitting.
        //
        protected double SplitTriangleArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            //
            // Check the areas of each pairs, only if a diagonal is evident.
            //
            if (TopLeftDiagonalIsValid())
            {
                double area1 = triPairTLBR.Key.GetArea(known);
                double area2 = triPairTLBR.Value.GetArea(known);

                if (area1 > 0 && area2 > 0) return area1 + area2;
            }

            if (BottomRightDiagonalIsValid())
            {
                double area1 = triPairBLTR.Key.GetArea(known);
                double area2 = triPairBLTR.Value.GetArea(known);

                if (area1 > 0 && area2 > 0) return area1 + area2;
            }

            return -1;
        }
Esempio n. 9
0
 public virtual bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
 {
     return false;
 }
Esempio n. 10
0
        //
        // Compute the area of the trapezoid using the A = 1/2 * (b_1 + b_2) * h
        //
        public double GetBaseBasedArea(double height, Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            double baseLength1 = known.GetSegmentLength(baseSegment);
            if (baseLength1 < 0) return -1;

            double baseLength2 = known.GetSegmentLength(oppBaseSegment);
            if (baseLength2 < 0) return -1;

            return 0.5 * (baseLength1 + baseLength2) * height;
        }
Esempio n. 11
0
 public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
 {
     return SplitTriangleArea(known);
 }
Esempio n. 12
0
        //
        // Given known values, can the third side be determined: isosceles right triangle (with base known)
        //
        public List<KeyValuePair<Segment, double>> CalculateBaseOfIsosceles(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            List<KeyValuePair<Segment, double>> pairs = new List<KeyValuePair<Segment, double>>();

            if (!this.provenIsosceles || !(this is IsoscelesTriangle)) return pairs;

            //
            // Make an isosceles triangle to acquire segments.
            //
            IsoscelesTriangle isoTri = new IsoscelesTriangle(this);
            Segment baseSeg = isoTri.baseSegment;

            double baseVal = known.GetSegmentLength(baseSeg);
            if (baseVal > 0) return pairs;

            //
            // Get the other sides.
            //
            Segment otherSide1, otherSide2;
            isoTri.GetOtherSides(baseSeg, out otherSide1, out otherSide2);

            // If we know 1 we should know the other, check anyway
            double otherVal1 = known.GetSegmentLength(otherSide1);
            double otherVal2 = known.GetSegmentLength(otherSide2);

            if (otherVal1 < 0 && otherVal2 < 0) return pairs;

            //
            // Get the base angle.
            //
            double baseAngleVal = known.GetAngleMeasure(isoTri.baseAngleOppositeLeg1);
            if (baseAngleVal < 0) baseAngleVal = known.GetAngleMeasure(isoTri.baseAngleOppositeLeg2);

            if (baseAngleVal < 0) return pairs;

            //
            // Compute the value of the base
            //
            double baseSideVal = 2.0 * otherVal1 * Math.Cos(Angle.toRadians(baseAngleVal));

            pairs.Add(new KeyValuePair<Segment, double>(baseSeg, baseSideVal));

            return pairs;
        }
Esempio n. 13
0
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            double area = ClassicArea(known);
            if (area > 0) return area;

            area = TrigArea(known);
            if (area > 0) return area;

            return HeroArea(known);
        }
Esempio n. 14
0
        public List<KeyValuePair<Segment, double>> RightTriangleTrigApplies(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            List<KeyValuePair<Segment, double>> pairs = new List<KeyValuePair<Segment, double>>();

            if (!(this is RightTriangle) && !this.provenRight) return pairs;

            //
            // Make a right
            //
            RightTriangle rightTri = new RightTriangle(this);
            Angle otherAngle1, otherAngle2;
            Angle rightAngle = rightTri.rightAngle;
            rightTri.GetOtherAngles(rightAngle, out otherAngle1, out otherAngle2);

            double angleMeasure1 = known.GetAngleMeasure(otherAngle1);
            double angleMeasure2 = known.GetAngleMeasure(otherAngle2);

            // Need to know one side length
            if (angleMeasure1 < 0 && angleMeasure2 < 0) return pairs;

            double knownSegVal = -1;
            Segment knownSeg = null;
            foreach (Segment side in orderedSides)
            {
                knownSegVal = known.GetSegmentLength(side);
                if (knownSegVal > 0)
                {
                    knownSeg = side;
                    break;
                }
            }

            // Need to know one side length
            if (knownSegVal < 0) return pairs;

            // Need at least one measure.
            if (angleMeasure1 > 0) return CalcSides(rightTri, rightAngle, otherAngle1, angleMeasure1, knownSeg, knownSegVal);
            if (angleMeasure2 > 0) return CalcSides(rightTri, rightAngle, otherAngle2, angleMeasure2, knownSeg, knownSegVal);

            return pairs;
        }
Esempio n. 15
0
        // Does Hero's Formula apply?
        private double HeroArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            List<double> lengths = new List<double>();

            foreach (Segment side in orderedSides)
            {
                double leng = known.GetSegmentLength(side);

                if (leng < 0) return -1;

                lengths.Add(leng);
            }

            return HeroArea(lengths[0], lengths[1], lengths[2]);
        }
Esempio n. 16
0
        public double GetHeight(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            foreach (KeyValuePair<Segment, double> pair in known.GetKnownSegments())
            {
                if (this.IsHeight(pair.Key)) return pair.Value;
            }

            return -1;
        }
Esempio n. 17
0
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            if (theArc is Semicircle) return (theArc as Semicircle).GetArea(known);

            // Central Angle; this is minor arc measure by default
            double angleMeasure = Angle.toRadians(known.GetAngleMeasure(this.theArc.GetCentralAngle()));

            if (angleMeasure <= 0) return -1;

            // Make a major arc measure, if needed.
            if (theArc is MajorArc) angleMeasure = 2 * Math.PI - angleMeasure;

            // Radius / Circle
            double circArea = theArc.theCircle.GetArea(known);

            if (circArea <= 0) return -1;

            // The area is a proportion of the circle defined by the angle.
            return (angleMeasure / (2 * Math.PI)) * circArea;
        }
Esempio n. 18
0
 public override bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
 {
     // Radius / Circle
     return theCircle.CanAreaBeComputed(known);
 }
Esempio n. 19
0
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Radius / Circle
            double circArea = theCircle.GetArea(known);

            if (circArea <= 0) return -1;

            // The area is a proportion of the circle defined by the angle.
            return 0.5 * circArea;
        }
Esempio n. 20
0
        //
        // Compute the area of the trapezoid using the A = median * height
        //
        public double GetMedianBasedArea(double height, Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            if (!IsMedianValid()) return -1;

            double medianLength = known.GetSegmentLength(median);
            if (medianLength < 0) return -1;

            return medianLength * height;
        }
Esempio n. 21
0
        //
        // Given known values, can the third side be determined.
        //
        public KeyValuePair<Segment, double> PythagoreanTheoremApplies(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            KeyValuePair<Segment, double> nullPair = new KeyValuePair<Segment, double>(null, -1);

            if (!(this is RightTriangle) && !this.provenRight) return nullPair;

            // Acquire the known lengths and determine if 2 of 3 are known (1 unknown).
            Segment hypotenuse = GetHypotenuse();
            Segment otherSeg1, otherSeg2;
            Segment unknown = null;
            GetOtherSides(hypotenuse, out otherSeg1, out otherSeg2);

            int knownCount = 0;
            double hypLength = known.GetSegmentLength(hypotenuse);
            if (hypLength > 0) knownCount++;
            else unknown = hypotenuse;

            double other1Length = known.GetSegmentLength(otherSeg1);
            if (other1Length > 0) knownCount++;
            else unknown = otherSeg1;

            double other2Length = known.GetSegmentLength(otherSeg2);
            if (other2Length > 0) knownCount++;
            else unknown = otherSeg2;

            if (knownCount != 2) return nullPair;

            // Which side don't we know?
            // Hypotenuse unknown.
            if (hypLength < 0)
            {
                return new KeyValuePair<Segment, double>(unknown, Math.Sqrt(Math.Pow(other1Length, 2) + Math.Pow(other2Length, 2)));
            }
            else
            {
                double otherKnown = other1Length < 0 ? other2Length : other1Length;
                return new KeyValuePair<Segment, double>(unknown, Math.Sqrt(Math.Pow(hypLength, 2) - Math.Pow(otherKnown, 2)));
            }
        }
 public void SetKnowns(Area_Based_Analyses.KnownMeasurementsAggregator k)
 {
     this.known = k;
 }
Esempio n. 23
0
        // Does the included Trig Formula apply?
        private double ClassicArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Right triangle with height being one of the sides.
            if (this is RightTriangle || this.provenRight)
            {
                Segment hypotenuse = GetHypotenuse();
                Segment otherSeg1, otherSeg2;
                GetOtherSides(hypotenuse, out otherSeg1, out otherSeg2);

                double b = known.GetSegmentLength(otherSeg1);
                double h = known.GetSegmentLength(otherSeg2);

                return b > 0 && h > 0 ? Area(b, h) : -1;
            }

            for (int s = 0; s < orderedSides.Count; s++)
            {
                double b = known.GetSegmentLength(orderedSides[s]);

                //
                // How to handle heights? Need to have altitudes for this triangle saved.
                //
                int h = 0;

                if (b > 0 && h > 0)
                {
                    return Area(b, h);
                }
            }

            return -1;
        }
Esempio n. 24
0
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Acquire the diagonals.
            if (this.topLeftBottomRightDiagonal == null || this.bottomLeftTopRightDiagonal == null)
            {
                System.Diagnostics.Debug.WriteLine("No-Op");
            }

            double diag1Length = known.GetSegmentLength(this.bottomLeftTopRightDiagonal);
            double diag2Length = known.GetSegmentLength(this.topLeftBottomRightDiagonal);

            // Multiply base * height.
            double thisArea = -1;

            if (diag1Length < 0 || diag2Length < 0) thisArea = -1;
            else thisArea = 0.5 * diag1Length * diag2Length;

            return thisArea > 0 ? thisArea : SplitTriangleArea(known);
        }
Esempio n. 25
0
        // Does the included Trig Formula apply?
        private double TrigArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            for (int s = 0; s < orderedSides.Count; s++)
            {
                double a = known.GetSegmentLength(orderedSides[s]);
                double b = known.GetSegmentLength(orderedSides[(s+1) % orderedSides.Count]);

                double theta = known.GetAngleMeasure(new Angle(orderedSides[s], orderedSides[(s+1) % orderedSides.Count]));

                if (a > 0 && b > 0 && theta > 0)
                {
                    return TrigArea(a, b, theta);
                }
            }

            return -1;
        }
Esempio n. 26
0
        public override bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Any Radius known?
            foreach (Segment thisRadius in radii)
            {
                double length = known.GetSegmentLength(thisRadius);
                if (length > 0) return true;
            }

            return false;
        }
Esempio n. 27
0
        public override bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            if (ClassicArea(known) > 0) return true;

            if (TrigArea(known) > 0) return true;

            if (HeroArea(known) > 0) return true;

            return false;
        }
Esempio n. 28
0
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Any Radius known?
            double length = -1;
            foreach (Segment thisRadius in radii)
            {
                length = known.GetSegmentLength(thisRadius);
                if (length > 0) break;
            }

            if (length < 0) return -1;

            return Area(length);
        }
Esempio n. 29
0
        //
        // Given known values, can the third side be determined: isosceles right triangle (with base known)
        //
        public List<KeyValuePair<Segment, double>> IsoscelesRightApplies(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            List<KeyValuePair<Segment, double>> pairs = new List<KeyValuePair<Segment, double>>();

            if (!this.provenIsosceles || !this.provenRight) return pairs;

            //
            // Make an isosceles triangle to acquire segments.
            //
            IsoscelesTriangle isoTri = new IsoscelesTriangle(this);
            Segment baseSeg = isoTri.baseSegment;

            double baseVal = known.GetSegmentLength(baseSeg);

            if (baseVal < 0) return pairs;

            // Compute the value of the other sides.
            double otherSideVal = Math.Sqrt(Math.Pow(baseVal, 2) / 2.0);

            // Get the other sides.
            Segment otherSide1, otherSide2;
            isoTri.GetOtherSides(baseSeg, out otherSide1, out otherSide2);

            if (!Utilities.CompareValues(otherSide1.Length, otherSideVal))
            {
                System.Diagnostics.Debug.WriteLine("Error in known measurements.");
            }
            if (!Utilities.CompareValues(otherSide2.Length, otherSideVal))
            {
                System.Diagnostics.Debug.WriteLine("Error in known measurements.");
            }

            pairs.Add(new KeyValuePair<Segment,double>(otherSide1, otherSideVal));
            pairs.Add(new KeyValuePair<Segment, double>(otherSide2, otherSideVal));

            return pairs;
        }
Esempio n. 30
0
 public override bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
 {
     return SplitTriangleArea(known) > 0;
 }