//
        // With appending in this case, we choose the given segment to be the base.
        //
        public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments)
        {
            List <FigSynthProblem> composed = new List <FigSynthProblem>();

            //
            // Construct the triangles.
            //
            foreach (Segment seg in segments)
            {
                List <Triangle> tris;

                IsoscelesTriangle.MakeIsoscelesTriangles(seg, seg.Length, out tris);

                foreach (Triangle t in tris)
                {
                    FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, t);
                    if (prob != null)
                    {
                        composed.Add(prob);
                    }
                }
            }

            return(FigSynthProblem.RemoveSymmetric(composed));
        }
Exemple #2
0
        public static Figure ConstructDefaultShape(ShapeType type)
        {
            switch (type)
            {
            case ShapeType.TRIANGLE:               return(Triangle.ConstructDefaultTriangle());

            case ShapeType.ISOSCELES_TRIANGLE:     return(IsoscelesTriangle.ConstructDefaultIsoscelesTriangle());

            case ShapeType.RIGHT_TRIANGLE:         return(RightTriangle.ConstructDefaultRightTriangle());

            case ShapeType.EQUILATERAL_TRIANGLE:   return(EquilateralTriangle.ConstructDefaultEquilateralTriangle());

            case ShapeType.KITE:                   return(Kite.ConstructDefaultKite());

            case ShapeType.QUADRILATERAL:          return(Quadrilateral.ConstructDefaultQuadrilateral());

            case ShapeType.TRAPEZOID:              return(Trapezoid.ConstructDefaultTrapezoid());

            case ShapeType.ISO_TRAPEZOID:          return(IsoscelesTrapezoid.ConstructDefaultIsoscelesTrapezoid());

            case ShapeType.PARALLELOGRAM:          return(Parallelogram.ConstructDefaultParallelogram());

            case ShapeType.RECTANGLE:              return(Rectangle.ConstructDefaultRectangle());

            case ShapeType.RHOMBUS:                return(Rhombus.ConstructDefaultRhombus());

            case ShapeType.SQUARE:                 return(Square.ConstructDefaultSquare());

            case ShapeType.CIRCLE:                 return(Circle.ConstructDefaultCircle());

            case ShapeType.SECTOR:                 return(Sector.ConstructDefaultSector());
            }

            return(null);
        }
        public static List<EdgeAggregator> InstantiateTheorem(GroundedClause original, IsoscelesTriangle isoTri)
        {
            GeometricCongruentAngles newCongSegs = new GeometricCongruentAngles(isoTri.baseAngleOppositeLeg1, isoTri.baseAngleOppositeLeg2);

            List<GroundedClause> antecedent = Utilities.MakeList<GroundedClause>(original);

            return Utilities.MakeList<EdgeAggregator>(new EdgeAggregator(antecedent, newCongSegs, annotation));
        }
        public override bool Equals(Object obj)
        {
            IsoscelesTriangle triangle = obj as IsoscelesTriangle;

            if (triangle == null)
            {
                return(false);
            }
            return(base.Equals(obj));
        }
Exemple #5
0
        public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points)
        {
            // Possible triangles.
            List <Triangle> tris = null;

            if (outerShape is ConcavePolygon)
            {
                tris = Triangle.GetTrianglesFromPoints(outerShape as ConcavePolygon, points);
            }
            else
            {
                tris = Triangle.GetTrianglesFromPoints(points);
            }

            List <FigSynthProblem> composed = new List <FigSynthProblem>();

            foreach (Triangle tri in tris)
            {
                // Select only isosceles triangle that don't match the outer shape.
                if (tri.IsIsosceles() && !tri.StructurallyEquals(outerShape))
                {
                    IsoscelesTriangle isoTri = new IsoscelesTriangle(tri);

                    SubtractionSynth subSynth = new SubtractionSynth(outerShape, isoTri);

                    try
                    {
                        subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, isoTri.points, isoTri));
                        composed.Add(subSynth);
                    }
                    catch (Exception) { }
                }
            }

            return(FigSynthProblem.RemoveSymmetric(composed));
        }
Exemple #6
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;
        }
Exemple #7
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;
        }
        /// <summary>
        /// Figure out which triangles we can choose from before the window is shown.
        /// </summary>
        protected override void OnShow()
        {
            List<GroundedClause> givens = new List<GroundedClause>();
            //Populate list with applicable givens
            foreach (GroundedClause gc in currentGivens)
            {
                IsoscelesTriangle it = gc as IsoscelesTriangle;
                if (it != null)
                {
                    givens.Add(it);
                }
            }

            List<Triangle> isosTriangles = new List<Triangle>();
            //Populate list with possible choices
            foreach (Triangle t in parser.backendParser.implied.polygons[GeometryTutorLib.ConcreteAST.Polygon.TRIANGLE_INDEX])
            {
                if (isIsosceles(t))
                {
                    IsoscelesTriangle it = new IsoscelesTriangle(t);
                    if (!StructurallyContains(givens, it))
                    {
                        isosTriangles.Add(it);
                    }
                }
            }

            options.ItemsSource = null; //Makes sure the box is graphically updated.
            options.ItemsSource = isosTriangles;
        }
        private static List<EdgeAggregator> InstantiateDefinition(GroundedClause original, IsoscelesTriangle isoTri)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            GeometricCongruentSegments gcs = new GeometricCongruentSegments(isoTri.leg1, isoTri.leg2);

            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(original);

            newGrounded.Add(new EdgeAggregator(antecedent, gcs, annotation));

            return newGrounded;
        }
        public static new List<FigSynthProblem> SubtractShape(Figure outerShape, List<Connection> conns, List<Point> points)
        {
            // Possible triangles.
            List<Triangle> tris = null;

            if (outerShape is ConcavePolygon) tris = Triangle.GetTrianglesFromPoints(outerShape as ConcavePolygon, points);
            else tris = Triangle.GetTrianglesFromPoints(points);

            List<FigSynthProblem> composed = new List<FigSynthProblem>();
            foreach (Triangle tri in tris)
            {
                // Select only isosceles triangle that don't match the outer shape.
                if (tri.IsIsosceles() && !tri.StructurallyEquals(outerShape))
                {
                    IsoscelesTriangle isoTri = new IsoscelesTriangle(tri);

                    SubtractionSynth subSynth = new SubtractionSynth(outerShape, isoTri);

                    try
                    {
                        subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, isoTri.points, isoTri));
                        composed.Add(subSynth);
                    }
                    catch (Exception) { }
                }
            }

            return FigSynthProblem.RemoveSymmetric(composed);
        }