Skip to content

Commit

Permalink
Edit PSE Example 4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmatech committed Mar 9, 2013
1 parent c51408c commit 7531f11
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 49 deletions.
70 changes: 21 additions & 49 deletions PSE 5E Example 4.7 The End of the Ski Jump/Program.cs
Expand Up @@ -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()
{
Expand All @@ -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();

Expand All @@ -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();
Expand All @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions Utils/Utils.cs
Expand Up @@ -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.