/* * 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); }
public static void FromPointPointToLine(PointSymbol ps1, PointSymbol ps2, LineSymbol ls) { var m = new Var("m"); var k = new Var("k"); var x = new Var("x"); var y = new Var("y"); var term = new Term(Expression.Multiply, new List <object>() { m, x }); var term1 = new Term(Expression.Add, new List <object>() { term, k }); var eqPattern = new Equation(y, term1); var term2 = new Term(Expression.Multiply, new List <object>() { m, ps1.SymXCoordinate }); var term22 = new Term(Expression.Add, new List <object>() { term2, k }); var eqPattern1 = new Equation(ps1.SymYCoordinate, term22); var term3 = new Term(Expression.Multiply, new List <object>() { m, ps2.SymXCoordinate }); var term33 = new Term(Expression.Add, new List <object>() { term3, k }); var eqPattern2 = new Equation(ps2.SymYCoordinate, term33); string strategy = "Generate a line by substituting two given points into the line slope-intercept form y=mx+k."; var ts0 = new TraceStep(eqPattern, eqPattern1, SubstitutionRule.SubstituteKC(), SubstitutionRule.SubstitutionStrategy, SubstitutionRule.ApplySubstitute(eqPattern, ps1)); var ts1 = new TraceStep(eqPattern, eqPattern2, SubstitutionRule.SubstituteKC(), SubstitutionRule.SubstitutionStrategy, SubstitutionRule.ApplySubstitute(eqPattern, ps2)); string kc = GeometryScaffold.KC_LineSlopeForm; var ts2 = new TraceStep(null, ls, kc, "calculate m and k through the above two linear equations.", "calculate m and k through linear equation and retrieve y=mx+k line form."); ls._innerLoop.Add(ts0); ls._innerLoop.Add(ts1); ls._innerLoop.Add(ts2); ls.GenerateATrace(strategy); }
public static void FromLineSlopeIntercetpToLineGeneralForm(LineSymbol ls) { var line = ls.Shape as Line; Debug.Assert(line != null); Debug.Assert(ls.OutputType == LineType.GeneralForm); string step1metaRule = "Given the line slope-intercept from y=mx+b, move y term to the right side of equation."; string step1AppliedRule = String.Format("Move y to the right side of equation"); string kc = GeometryScaffold.KC_LinePatternsTransform; var ts = new TraceStep(ls.SlopeInterceptForm, ls.GeneralForm, kc, step1metaRule, step1AppliedRule); string strategy = strategy_si_general; ls._innerLoop.Add(ts); ls.GenerateATrace(strategy); }
/// <summary> /// Trace from Line General Form to Slope-Intercept Form /// ax+by+c=0 => y=mx+b /// </summary> /// <param name="target"></param> /// <returns></returns> public static void FromLineGeneralFormToSlopeIntercept(LineSymbol ls) { string strategy = "Given a general form line ax+by+c=0, the slope-intercept form of it is y = -(a/b)x-c/b."; var line = ls.Shape as Line; Debug.Assert(line != null); var newLS = new LineSymbol(line); newLS.OutputType = LineType.SlopeIntercept; var x = new Var("x"); var y = new Var("y"); var xTerm = new Term(Expression.Multiply, new List <object>() { line.A, x }); var yTerm = new Term(Expression.Multiply, new List <object>() { line.B, y }); var oldEqLeft = new Term(Expression.Add, new List <object>() { xTerm, yTerm, line.C }); var oldEq = new Equation(oldEqLeft, 0); var invertXTerm = new Term(Expression.Multiply, new List <object>() { -1, xTerm }); var intertZ = new Term(Expression.Multiply, new List <object>() { -1, line.C }); var internalRight = new Term(Expression.Add, new List <object>() { invertXTerm, intertZ }); var internalEq = new Equation(yTerm, internalRight); var finalXTerm = new Term(Expression.Multiply, new List <object>() { line.Slope, x }); var finalRight = new Term(Expression.Add, new List <object>() { finalXTerm, line.Intercept }); var lastEq = new Equation(yTerm, finalRight); string step1metaRule = "Given the line general form ax+by+c=0, move x term and Constant term to the right side of equation."; string step1AppliedRule = String.Format("Move {0}x and {1} to right side of equation.", ls.SymA, ls.SymC); string kc = EquationsRule.RuleConcept(EquationsRule.EquationRuleType.Transitive); var ts0 = new TraceStep(null, internalEq, kc, step1metaRule, step1AppliedRule); ls._innerLoop.Add(ts0); string appliedRule = string.Format("divide coefficient b in both side of equation."); kc = EquationsRule.RuleConcept(EquationsRule.EquationRuleType.Inverse); var ts1 = new TraceStep(null, lastEq, kc, AlgebraRule.AlgebraicStrategy, appliedRule); ls._innerLoop.Add(ts1); ls.GenerateATrace(strategy); }
public static void FromPointSlopeToLine(PointSymbol ps, EqGoal goal, LineSymbol ls) { string strategy = "Substitute point and slope property into line form."; // 1. Substitute slope property into the line slope-intercept form. // 2. Calculate the line intercept by substituting the point into line pattern. ////////////////////////////////////////////////////////////////////// string strategy1 = "Substitute slope property into the line slope-intercept form."; var m = new Var("m"); var k = new Var("k"); var x = new Var("x"); var y = new Var("y"); var term = new Term(Expression.Multiply, new List <object>() { m, x }); var term1 = new Term(Expression.Add, new List <object>() { term, k }); var eqPattern = new Equation(y, term1); var term2 = new Term(Expression.Multiply, new List <object>() { goal.Rhs, x }); var term3 = new Term(Expression.Add, new List <object>() { term2, k }); var eqInternal1 = new Equation(y, term3); var appliedRule1 = SubstitutionRule.ApplySubstitute(eqPattern, goal); var ts0 = new TraceStep(eqPattern, eqInternal1, SubstitutionRule.SubstituteKC(), strategy1, appliedRule1); ls._innerLoop.Add(ts0); ////////////////////////////////////////////////////////////////////// var point = ps.Shape as Point; Debug.Assert(point != null); string strategy2 = "Calculate the line intercept by substituting the point into line pattern."; var term4 = new Term(Expression.Multiply, new List <object>() { goal.Rhs, point.XCoordinate }); var term5 = new Term(Expression.Add, new List <object>() { term4, k }); var eqinternal2 = new Equation(point.YCoordinate, term5); object obj; bool result = eqinternal2.IsEqGoal(out obj); var eqGoal = obj as EqGoal; Debug.Assert(eqGoal != null); var gTuple = eqGoal.Traces[0]; var gLst = gTuple.Item2 as List <TraceStep>; Debug.Assert(gLst != null); ls._innerLoop.AddRange(gLst); var appliedRule2 = SubstitutionRule.ApplySubstitute(eqInternal1, ps); var ts = new TraceStep(eqInternal1, ls, SubstitutionRule.SubstituteKC(), strategy2, appliedRule2); ls._innerLoop.Add(ts); ls.GenerateATrace(strategy); }
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); }
/// <summary> /// Trace from Line General Form to Slope-Intercept Form /// ax+by+c=0 => y=mx+b /// </summary> /// <param name="target"></param> /// <returns></returns> public static void FromLineGeneralFormToSlopeIntercept(LineSymbol ls) { string strategy = "Given a general form line ax+by+c=0, the slope-intercept form of it is y = -(a/b)x-c/b."; var line = ls.Shape as Line; Debug.Assert(line != null); var newLS = new LineSymbol(line); newLS.OutputType = LineType.SlopeIntercept; var x = new Var("x"); var y = new Var("y"); var xTerm = new Term(Expression.Multiply, new List<object>() { line.A, x }); var yTerm = new Term(Expression.Multiply, new List<object>() { line.B, y }); var oldEqLeft = new Term(Expression.Add, new List<object>() { xTerm, yTerm, line.C }); var oldEq = new Equation(oldEqLeft, 0); var invertXTerm = new Term(Expression.Multiply, new List<object>() { -1, xTerm }); var intertZ = new Term(Expression.Multiply, new List<object>() { -1, line.C }); var internalRight = new Term(Expression.Add, new List<object>() { invertXTerm, intertZ }); var internalEq = new Equation(yTerm, internalRight); var finalXTerm = new Term(Expression.Multiply, new List<object>() { line.Slope, x }); var finalRight = new Term(Expression.Add, new List<object>() { finalXTerm, line.Intercept }); var lastEq = new Equation(yTerm, finalRight); string step1metaRule = "Given the line general form ax+by+c=0, move x term and Constant term to the right side of equation."; string step1AppliedRule = String.Format("Move {0}x and {1} to right side of equation.", ls.SymA, ls.SymC); string kc = EquationsRule.RuleConcept(EquationsRule.EquationRuleType.Transitive); var ts0 = new TraceStep(null, internalEq, kc, step1metaRule, step1AppliedRule); ls._innerLoop.Add(ts0); string appliedRule = string.Format("divide coefficient b in both side of equation."); kc = EquationsRule.RuleConcept(EquationsRule.EquationRuleType.Inverse); var ts1 = new TraceStep(null, lastEq, kc, AlgebraRule.AlgebraicStrategy, appliedRule); ls._innerLoop.Add(ts1); ls.GenerateATrace(strategy); }
public static void FromPointSlopeToLine(PointSymbol ps, EqGoal goal, LineSymbol ls) { string strategy = "Substitute point and slope property into line form."; // 1. Substitute slope property into the line slope-intercept form. // 2. Calculate the line intercept by substituting the point into line pattern. ////////////////////////////////////////////////////////////////////// string strategy1 = "Substitute slope property into the line slope-intercept form."; var m = new Var("m"); var k = new Var("k"); var x = new Var("x"); var y = new Var("y"); var term = new Term(Expression.Multiply, new List<object>() {m, x}); var term1 = new Term(Expression.Add, new List<object>() {term, k}); var eqPattern = new Equation(y, term1); var term2 = new Term(Expression.Multiply, new List<object>() {goal.Rhs,x}); var term3 = new Term(Expression.Add, new List<object>() {term2, k}); var eqInternal1 = new Equation(y, term3); var appliedRule1 = SubstitutionRule.ApplySubstitute(eqPattern, goal); var ts0 = new TraceStep(eqPattern, eqInternal1, SubstitutionRule.SubstituteKC(), strategy1, appliedRule1); ls._innerLoop.Add(ts0); ////////////////////////////////////////////////////////////////////// var point = ps.Shape as Point; Debug.Assert(point != null); string strategy2 = "Calculate the line intercept by substituting the point into line pattern."; var term4 = new Term(Expression.Multiply, new List<object>() { goal.Rhs, point.XCoordinate}); var term5 = new Term(Expression.Add, new List<object>() {term4, k}); var eqinternal2 = new Equation(point.YCoordinate, term5); object obj; bool result = eqinternal2.IsEqGoal(out obj); var eqGoal = obj as EqGoal; Debug.Assert(eqGoal != null); var gTuple = eqGoal.Traces[0]; var gLst = gTuple.Item2 as List<TraceStep>; Debug.Assert(gLst != null); ls._innerLoop.AddRange(gLst); var appliedRule2 = SubstitutionRule.ApplySubstitute(eqInternal1, ps); var ts = new TraceStep(eqInternal1, ls, SubstitutionRule.SubstituteKC(), strategy2, appliedRule2); ls._innerLoop.Add(ts); ls.GenerateATrace(strategy); }
public static void FromPointPointToLine(PointSymbol ps1, PointSymbol ps2, LineSymbol ls) { var m = new Var("m"); var k = new Var("k"); var x = new Var("x"); var y = new Var("y"); var term = new Term(Expression.Multiply, new List<object>() { m, x }); var term1 = new Term(Expression.Add, new List<object>() { term, k }); var eqPattern = new Equation(y, term1); var term2 = new Term(Expression.Multiply, new List<object>() {m, ps1.SymXCoordinate}); var term22 = new Term(Expression.Add, new List<object>() {term2, k}); var eqPattern1 = new Equation(ps1.SymYCoordinate, term22); var term3 = new Term(Expression.Multiply, new List<object>() {m, ps2.SymXCoordinate}); var term33 = new Term(Expression.Add, new List<object>() { term3, k }); var eqPattern2 = new Equation(ps2.SymYCoordinate, term33); string strategy = "Generate a line by substituting two given points into the line slope-intercept form y=mx+k."; var ts0 = new TraceStep(eqPattern, eqPattern1, SubstitutionRule.SubstituteKC(),SubstitutionRule.SubstitutionStrategy, SubstitutionRule.ApplySubstitute(eqPattern, ps1)); var ts1 = new TraceStep(eqPattern, eqPattern2, SubstitutionRule.SubstituteKC(),SubstitutionRule.SubstitutionStrategy, SubstitutionRule.ApplySubstitute(eqPattern, ps2)); string kc = GeometryScaffold.KC_LineSlopeForm; var ts2 = new TraceStep(null, ls, kc, "calculate m and k through the above two linear equations.", "calculate m and k through linear equation and retrieve y=mx+k line form."); ls._innerLoop.Add(ts0); ls._innerLoop.Add(ts1); ls._innerLoop.Add(ts2); ls.GenerateATrace(strategy); }
/* * 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); }
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); }
public static void FromLineSlopeIntercetpToLineGeneralForm(LineSymbol ls) { var line = ls.Shape as Line; Debug.Assert(line != null); Debug.Assert(ls.OutputType == LineType.GeneralForm); string step1metaRule = "Given the line slope-intercept from y=mx+b, move y term to the right side of equation."; string step1AppliedRule = String.Format("Move y to the right side of equation"); string kc = GeometryScaffold.KC_LinePatternsTransform; var ts = new TraceStep(ls.SlopeInterceptForm, ls.GeneralForm, kc, step1metaRule, step1AppliedRule); string strategy = strategy_si_general; ls._innerLoop.Add(ts); ls.GenerateATrace(strategy); }