Пример #1
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));
        }
Пример #2
0
        //
        // Attempt trapezoidal formulas; if they fail, call the base method: splitting into triangles.
        //
        public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            // Acquire the height of the trapezoid: if it's a known value.
            double height = GetHeight(known);

            if (height < 0)
            {
                return(-1);
            }

            double area = GetBaseBasedArea(height, known);

            if (area > 0)
            {
                return(area);
            }

            area = GetMedianBasedArea(height, known);
            if (area > 0)
            {
                return(area);
            }

            return(base.GetArea(known));
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
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));
        }
Пример #7
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));
        }
Пример #8
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));
        }
Пример #9
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);
        }
Пример #10
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));
        }
Пример #11
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);
        }
Пример #12
0
        private double ClassicArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
        {
            foreach (Segment side in orderedSides)
            {
                double sideLength = known.GetSegmentLength(side);

                if (sideLength > 0)
                {
                    return(Area(sideLength));
                }
            }

            return(-1);
        }
Пример #13
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);
        }
Пример #14
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);
        }
Пример #15
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));
        }
 public void SetKnowns(Area_Based_Analyses.KnownMeasurementsAggregator k)
 {
     this.known = k;
 }
Пример #17
0
 public override double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known)
 {
     return(SplitTriangleArea(known));
 }
Пример #18
0
 public override bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
 {
     return(SplitTriangleArea(known) > 0);
 }
Пример #19
0
 public virtual bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known) { return false; }
Пример #20
0
 public virtual double GetArea(Area_Based_Analyses.KnownMeasurementsAggregator known) { return -1; }
Пример #21
0
 public override bool CanAreaBeComputed(Area_Based_Analyses.KnownMeasurementsAggregator known)
 {
     // Radius / Circle
     return(theCircle.CanAreaBeComputed(known));
 }