public override double GetArea(KnownMeasurementsAggregator known)
        {
            if (thisArea > 0) return thisArea;

            thisArea = shape.GetArea(known);

            return thisArea;
        }
        public override double GetArea(KnownMeasurementsAggregator known)
        {
            if (thisArea > 0)
            {
                return(thisArea);
            }

            thisArea = shape.GetArea(known);

            return(thisArea);
        }
        public override double EvaluateArea(KnownMeasurementsAggregator known)
        {
            double leftArea  = leftProblem.EvaluateArea(known);
            double rightArea = rightProblem.EvaluateArea(known);

            if (leftArea < 0 || rightArea < 0)
            {
                return(-1);
            }

            return(leftArea + rightArea);
        }
        //
        // Filter the list of unknowns by any new information.
        //
        private List <Segment> AcquireCurrentUnknowns(KnownMeasurementsAggregator known, List <Segment> unknowns)
        {
            List <Segment> newUnknowns = new List <Segment>();

            foreach (Segment unknown in unknowns)
            {
                if (known.GetSegmentLength(unknown) < 0)
                {
                    newUnknowns.Add(unknown);
                }
            }

            return(newUnknowns);
        }
        public override double GetArea(KnownMeasurementsAggregator known)
        {
            double outerArea = outerShape.GetArea(known);
            if (outerArea < 0) return -1;

            double innerArea = 0;
            foreach (AtomicRegion inner in innerShapes)
            {
                double thisInnerArea = inner.GetArea(known);
                if (thisInnerArea < 0) return -1;

                innerArea += thisInnerArea;
            }

            return outerArea - innerArea;
        }
        //
        // We have a set of constraints associated with the figure.
        // Also associated is a set of variables in which constraints are defined.
        // 1) Randomly choose one of the variables that defines the area formula, define it by its coordinate-based value.
        // 2) Push it through the constant propagator.
        // 3) From the list of variables, remove which of them that are now known.
        // 4) Repeat until the list of variables is empty.
        //
        public KnownMeasurementsAggregator AcquireKnowns()
        {
            // Acquire all unknown variables required to calculate the area.
            List <Segment> unknownAreaVars = this.GetAreaVariables();

            // The constraints for this problem.
            List <Constraint> constraints = this.GetConstraints();

            // The values we must state to the user in order to solve the problem.
            List <Segment> assumptions = new List <Segment>();

            //
            // Loop until all variables are known.
            //
            KnownMeasurementsAggregator known = new KnownMeasurementsAggregator();

            while (unknownAreaVars.Any())
            {
                // Acquire a new assumption.
                Segment newAssumption = unknownAreaVars[0];

                // remove that assumption since it is now known; add as an assumption.
                unknownAreaVars.RemoveAt(0);
                assumptions.Add(newAssumption);

                // Set this value as known with its intrinsic (corrdinate-based) length.
                known.AddSegmentLength(newAssumption, newAssumption.Length);

                // Propagate the new information through the constraints.
                ConstantPropagator.Propogate(known, constraints);

                // Check if any of the unknown variables are now known through constant propagation.
                unknownAreaVars = AcquireCurrentUnknowns(known, unknownAreaVars);
            }

            //
            // Create the known object.
            //
            KnownMeasurementsAggregator trueAssumptions = new KnownMeasurementsAggregator();

            foreach (Segment seg in assumptions)
            {
                trueAssumptions.AddSegmentLength(seg, seg.Length);
            }

            return(trueAssumptions);
        }
        public override double GetArea(KnownMeasurementsAggregator known)
        {
            double outerArea = outerShape.GetArea(known);

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

            double innerArea = 0;

            foreach (AtomicRegion inner in innerShapes)
            {
                double thisInnerArea = inner.GetArea(known);
                if (thisInnerArea < 0)
                {
                    return(-1);
                }

                innerArea += thisInnerArea;
            }

            return(outerArea - innerArea);
        }
Exemple #8
0
 //
 // Can the area of this region be calculated?
 //
 public virtual double GetArea(KnownMeasurementsAggregator known)
 {
     return(thisArea);
 }
Exemple #9
0
 //
 // Can the area of this region be calculated?
 //
 public virtual double GetArea(KnownMeasurementsAggregator known)
 {
     return thisArea;
 }
Exemple #10
0
 public override double EvaluateArea(KnownMeasurementsAggregator known)
 {
     return(figure.GetArea(known));
 }
Exemple #11
0
 public abstract double EvaluateArea(KnownMeasurementsAggregator known);