Ejemplo n.º 1
0
        /*
         * Annotated scaffolding
         *
         */
        public static void FromPointsToLineSegment(LineSegmentSymbol lss)
        {
            var ls = lss.Shape as LineSegment;

            Debug.Assert(ls != null);
            var pt1Symbol = new PointSymbol(ls.Pt1);
            var pt2Symbol = new PointSymbol(ls.Pt2);

            string strategy;

            TraceStep ts00 = new TraceStep(null, pt1Symbol, null, PlottingRule.PlottingStrategy, PlottingRule.Plot(pt1Symbol));
            TraceStep ts01 = new TraceStep(null, pt2Symbol, null, PlottingRule.PlottingStrategy, PlottingRule.Plot(pt2Symbol));

            TraceStep ts02 = null;

            if (ls.Pt1.Concrete && ls.Pt2.Concrete)
            {
                ts02 = new TraceStep(null, lss, null, PlottingRule.PlottingStrategy, PlottingRule.Plot(lss));
            }
            strategy = "Plot a Line Segment passing through two points.";
            lss._innerLoop.Add(ts00);
            lss._innerLoop.Add(ts01);
            if (ts02 != null)
            {
                lss._innerLoop.Add(ts02);
            }
            lss.GenerateATrace(strategy);

/*            string stepMetaRule = "Consider draw a line segment passing through the two points.";
 *          string stepAppliedRule = String.Format("Draw the line segment passing through two points {0} and {1}",
 *              pt1Symbol, pt2Symbol);
 *
 *          var traceStep = new TraceStep(null, lss, stepMetaRule, stepAppliedRule);
 *          lss._innerLoop.Add(traceStep);*/
        }
        public static void FromPointsToMidPoint(PointSymbol ps1, PointSymbol ps2, PointSymbol midPoint)
        {
            //1. plot the ps1, ps2 and the line
            //2. generate x coordinate
            //3. generate y coordinate
            //4. generate point (x,y)

            string strategy;

            var ts00 = new TraceStep(null, ps1, null, PlottingRule.PlottingStrategy, PlottingRule.Plot(ps1));
            var ts01 = new TraceStep(null, ps2, null, PlottingRule.PlottingStrategy, PlottingRule.Plot(ps2));
            var ls   = LineBinaryRelation.Unify(ps1, ps2) as LineSymbol;
            var ts02 = new TraceStep(null, ls, null, PlottingRule.PlottingStrategy, PlottingRule.Plot(ls));

            strategy = "Plot the given two points and the connected line.";
            midPoint._innerLoop.Add(ts00);
            midPoint._innerLoop.Add(ts01);
            midPoint._innerLoop.Add(ts02);
            midPoint.GenerateATrace(strategy);
            ////////////////////////////////////////////////

            var xCoord = new Var("x");
            var pt1    = ps1.Shape as Point;

            Debug.Assert(pt1 != null);
            var pt2 = ps2.Shape as Point;

            Debug.Assert(pt2 != null);

            var term1 = new Term(Expression.Add, new List <object>()
            {
                pt1.XCoordinate, pt2.XCoordinate
            });
            var term2 = new Term(Expression.Divide, new List <object>()
            {
                term1, 2
            });
            var eq = new Equation(xCoord, term2);

            /////////////////////////////////////////////////

            object obj;
            bool   result = eq.IsEqGoal(out obj);
            EqGoal goal1  = null;

            if (result)
            {
                goal1 = obj as EqGoal;
                Debug.Assert(goal1 != null);
                Debug.Assert(goal1.Traces.Count == 1);
                var currentTrace = goal1.Traces.ToList()[0];
                strategy = "Generate x coordinate of midpoint.";
                var newTrace = new Tuple <object, object>(strategy, currentTrace.Item2);
                midPoint.Traces.Add(newTrace);
            }

            //////////////////////////////////////////////////

            var yCoord = new Var("y");

            term1 = new Term(Expression.Add, new List <object>()
            {
                pt1.YCoordinate, pt2.YCoordinate
            });
            term2 = new Term(Expression.Divide, new List <object>()
            {
                term1, 2
            });
            var eq1 = new Equation(yCoord, term2);

            result = eq1.IsEqGoal(out obj);
            EqGoal goal2 = null;

            if (result)
            {
                goal2 = obj as EqGoal;
                Debug.Assert(goal2 != null);
                Debug.Assert(goal2.Traces.Count == 1);
                var currentTrace1 = goal2.Traces.ToList()[0];
                strategy = "Generate y coordinate of midpoint.";
                var newTrace = new Tuple <object, object>(strategy, currentTrace1.Item2);
                midPoint.Traces.Add(newTrace);
            }

            //////////////////////////////////////////////////////

            var ps   = new Point(xCoord, yCoord);
            var psym = new PointSymbol(ps);

            var mid = midPoint.Shape as Point;

            Debug.Assert(mid != null);
            var ps_inter1   = new Point(mid.XCoordinate, yCoord);
            var psym_inter1 = new PointSymbol(ps_inter1);
            var metaRule    = "Consider substitute generate x coordinate into the point form.";
            var appliedRule = SubstitutionRule.ApplySubstitute(goal1, psym);

            var ts1 = new TraceStep(psym, psym_inter1, null, metaRule, appliedRule);

            metaRule    = "Consider substitute generate y coordinate into the point form.";
            appliedRule = SubstitutionRule.ApplySubstitute(goal2, psym_inter1);
            var ts2 = new TraceStep(psym_inter1, midPoint, null, metaRule, appliedRule);

            strategy = "Generate point (x,y) by subsitute generated x and y.";
            midPoint._innerLoop.Add(ts1);
            midPoint._innerLoop.Add(ts2);
            midPoint.GenerateATrace(strategy);
        }
Ejemplo n.º 3
0
        /*
         * given m=2, k=3, y=3x+2
         */
        public static void FromSlopeInterceptToLineSlopeIntercept(EqGoal slopeGoal, EqGoal interceptGoal, LineSymbol ls)
        {
            //1. Substitute slope and intercept properties into the line slope-intercept form y=mx+b.
            ////////////////////////////////////////////////////////


            var ts0 = new TraceStep(null, slopeGoal, GeometryScaffold.KC_LineSlopeForm, PlottingRule.PlottingStrategy, PlottingRule.Plot(slopeGoal));
            var ts1 = new TraceStep(null, interceptGoal, GeometryScaffold.KC_LineInterceptForm, PlottingRule.PlottingStrategy, PlottingRule.Plot(interceptGoal));

            ls._innerLoop.Add(ts0);

            var abstractLs  = new Line(ls.Shape.Label, slopeGoal.Lhs, interceptGoal.Lhs);
            var abstractLss = new LineSymbol(abstractLs);
            var internalLs  = new Line(ls.Shape.Label, ls.SymSlope, interceptGoal.Lhs);
            var internalLss = new LineSymbol(internalLs);

            var traceStep1 = new TraceStep(abstractLss, internalLss, SubstitutionRule.SubstituteKC(), SubstitutionRule.SubstitutionStrategy, SubstitutionRule.ApplySubstitute(abstractLss, slopeGoal));

            ls._innerLoop.Add(traceStep1);

            ls._innerLoop.Add(ts1);

            /*
             *          var rule = "Substitute given property to line slope-intercept form.";
             *          var appliedRule1 = string.Format("Substitute slope={0} into y=mx+b", ls.SymSlope);
             *          var appliedRule2= string.Format("Substitute intercept={0} into y=mx+b", ls.SymIntercept);*/
            var traceStep2 = new TraceStep(internalLss, ls, SubstitutionRule.SubstituteKC(), SubstitutionRule.SubstitutionStrategy, SubstitutionRule.ApplySubstitute(internalLss, interceptGoal));

            ls._innerLoop.Add(traceStep2);

            string strategy = "Substitute slope and intercept properties into the line slope-intercept form y = mx + b.";

            ls.GenerateATrace(strategy);
        }
Ejemplo n.º 4
0
        public static void LineSlopeIntercepToGraph(LineSymbol ls)
        {
            string strategy = strategy_graphing;

            //Plotting shapes
            //1. plotting Y-Intercept
            //2. plotting X-Intercept
            //3. plotting the line

            //////////////////////////////////////////////////////////////
            // Step 1:
            var pt    = new Point(0, ls.SymIntercept);
            var ptSym = new PointSymbol(pt);

            var ts0 = new TraceStep(null, ptSym, null, PlottingRule.PlottingStrategy, PlottingRule.Plot(ptSym));

            ls._innerLoop.Add(ts0);
            //////////////////////////////////////////////////////////////
            // Step 2:

            var line = ls.Shape as Line;

            Debug.Assert(line != null);

            Equation eq;

            if (line.B == null)
            {
            }
            else
            {
                var x = new Var("x");
                //step 2.1
                var term = new Term(Expression.Multiply, new List <object>()
                {
                    line.Slope, x
                });
                var term1 = new Term(Expression.Add, new List <object>()
                {
                    term, line.Intercept
                });
                eq = new Equation(term1, 0);
                object obj;
                EqGoal gGoal  = null;
                bool   result = eq.IsEqGoal(out obj);
                if (result)
                {
                    gGoal = obj as EqGoal;
                }
                if (gGoal != null)
                {
                    double dX;
                    LogicSharp.IsDouble(gGoal.Rhs, out dX);
                    var pt1    = new Point(dX, 0);
                    var ptSym1 = new PointSymbol(pt1);
                    var ts1    = new TraceStep(null, ptSym1, null, PlottingRule.PlottingStrategy, PlottingRule.Plot(ptSym1));
                    ls._innerLoop.Add(ts1);
                }
            }

            /////////////////////////////////////////////////////////////////

            const string step1MetaRule    = "Given the line slope-intercept form y=mx+b, plot the line by passing points (0,b) and (-b/m,0).";
            string       step1AppliedRule = String.Format("Plotting the line passing through (0,{0}) and ({1},0) ", ls.SymIntercept, ls.SymC);
            //var ts = new TraceStep(null, ls.SlopeInterceptForm, step1MetaRule, step1AppliedRule);


            string kc = GeometryScaffold.KC_LineGraphing;

            var ts = new TraceStep(null, ls, kc, step1MetaRule, step1AppliedRule);

            ls._innerLoop.Add(ts);

            //////////////////////////////////////////////////////////////////

            ls.GenerateATrace(strategy);
        }