Permalink
Browse files

Edit PSE Example 4.7

  • Loading branch information...
1 parent c51408c commit 7531f1181ef0aacaf02d8ada0723a6f7b0016b43 @dharmatech committed Mar 9, 2013
Showing with 23 additions and 49 deletions.
  1. +21 −49 PSE 5E Example 4.7 The End of the Ski Jump/Program.cs
  2. +2 −0 Utils/Utils.cs
@@ -18,12 +18,15 @@ static void Main(string[] args)
// The landing incline below him falls off with a slope of 35.0°.
// Where does he land on the incline?
- var thA = new Symbol("thA"); // angle at point A
- var vA = new Symbol("vA"); // velocity at point A
+ var thA = new Symbol("thA"); // angle at point A
+
+ var vA = new Symbol("vA"); // velocity at point A
- var g = new Symbol("g"); // magnitude of gravity
+ var g = new Symbol("g"); // magnitude of gravity
- var _g = new Point(0, -g); // gravity vector
+ var _g = new Point(0, -g); // gravity vector
+
+ var th = new Symbol("th"); // angle of incline
var objA = new Obj()
{
@@ -33,15 +36,19 @@ static void Main(string[] args)
time = 0
};
- var th = new Symbol("th"); // angle of incline
+ Func<MathObject, MathObject> numeric = obj =>
+ obj
+ .Substitute(vA, 25)
+ .Substitute(thA, 0.0)
+ .Substitute(th, (-35).ToRadians())
+ .Substitute(Trig.Pi, 3.14159)
+ .Substitute(g, 9.8);
var intersection = objA.ProjectileInclineIntersection(th);
Action nl = () => "".Disp();
- "Where does he land on the incline?".Disp();
-
- "".Disp();
+ "Where does he land on the incline?".Disp(); nl();
"x position (symbolic):".Disp();
@@ -53,62 +60,33 @@ static void Main(string[] args)
"x position (numeric):".Disp();
- intersection.x
- .Substitute(vA, 25)
- .Substitute(thA, 0.0)
- .Substitute(th, (-35).ToRadians())
- .Substitute(Trig.Pi, 3.14159)
- .Substitute(g, 9.8)
- .Disp();
-
- nl();
+ numeric(intersection.x).Disp(); nl();
"y position (numeric):".Disp();
- intersection.y
- .Substitute(vA, 25)
- .Substitute(thA, 0.0)
- .Substitute(th, (-35).ToRadians())
- .Substitute(Trig.Pi, 3.14159)
- .Substitute(g, 9.8)
- .Disp();
-
- nl();
+ numeric(intersection.y).Disp(); nl();
var objB = new Obj()
{
position = intersection,
acceleration = _g
};
- "Determine how long the jumper is airborne".Disp();
-
- nl();
+ "Determine how long the jumper is airborne".Disp(); nl();
"symbolic:".Disp();
var timeB = Calc.Time(objA, objB, 1);
- timeB.Disp();
-
- nl();
+ timeB.Disp(); nl();
"numeric:".Disp();
- timeB
- .Substitute(vA, 25)
- .Substitute(thA, 0.0)
- .Substitute(th, (-35).ToRadians())
- .Substitute(Trig.Pi, 3.14159)
- .Substitute(g, 9.8)
- .Disp();
-
- nl();
+ numeric(timeB).Disp(); nl();
objB = objA.AtTime(timeB);
"Determine his vertical component of velocity just before he lands".Disp();
-
nl();
"symbolic:".Disp();
@@ -117,13 +95,7 @@ static void Main(string[] args)
"numeric:".Disp();
- objB.velocity.y
- .Substitute(vA, 25)
- .Substitute(thA, 0.0)
- .Substitute(th, (-35).ToRadians())
- .Substitute(Trig.Pi, 3.14159)
- .Substitute(g, 9.8)
- .Disp();
+ numeric(objB.velocity.y).Disp();
Console.ReadLine();
}
View
@@ -12,5 +12,7 @@ public static T Disp<T>(this T obj)
Console.WriteLine(obj);
return obj;
}
+
+
}
}

0 comments on commit 7531f11

Please sign in to comment.