Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test for PSE 5E EXAMPLE 4.6

  • Loading branch information...
commit f16630168b6c13121eb2ca07b5f9c88aa1299f82 1 parent 6ba32ec
@dharmatech authored
View
2  PSE 5E Example 4.6 The Stranded Explorers/Program.cs
@@ -87,7 +87,7 @@ static void Main(string[] args)
.Substitute(g, 9.8)
.Disp(); "".Disp();
- "symbolic velocity.y:".Disp();
+ "numeric velocity.y:".Disp();
objB.velocity.y
.Substitute(xA, 0)
View
129 Tests/Tests.cs
@@ -332,6 +332,135 @@ static void Main(string[] args)
}
#endregion
+ #region PSE 5E EXAMPLE 4.6
+ {
+ // An Alaskan rescue plane drops a package of emergency rations
+ // to a stranded party of explorers, as shown in Figure
+ // 4.13. If the plane is traveling horizontally at 40.0 m/s and is
+ // 100 m above the ground, where does the package strike the
+ // ground relative to the point at which it was released?
+
+ var xA = new Symbol("xA"); // position.x at point A
+
+ var yA = new Symbol("yA"); // position.y 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 Point(0, -g); // gravity vector
+
+ var objA = new Obj() // obj at the initial position
+ {
+ position = new Point(xA, yA),
+ velocity = Point.FromAngle(thA, vA),
+ acceleration = _g,
+ time = 0
+ };
+
+ var objB = new Obj() // obj at the final position
+ {
+ position = new Point(null, 0),
+ velocity = new Point(objA.velocity.x, null),
+ acceleration = _g
+ };
+
+ var timeB = Calc.Time(objA, objB, 1);
+
+ objB = objA.AtTime(timeB);
+
+ //"Where does the package strike the ground relative to the point at which it was released?".Disp(); "".Disp();
+
+ //"symbolic:".Disp();
+
+ //objB.position.x.Disp(); "".Disp();
+
+ AssertIsTrue(
+ objB.position.x
+ ==
+ xA - cos(thA) / g * vA * (-sin(thA) * vA - (((sin(thA) ^ 2) * (vA ^ 2) + 2 * g * yA) ^ new Integer(1) / 2)));
+
+ //"numeric:".Disp();
+
+ //objB.position.x
+ // .Substitute(xA, 0)
+ // .Substitute(yA, 100)
+ // .Substitute(vA, 40)
+ // .Substitute(thA, 0.0)
+ // .Substitute(g, 9.8)
+ // .Disp();
+
+ AssertEqual(
+ objB.position.x
+ .Substitute(xA, 0)
+ .Substitute(yA, 100)
+ .Substitute(vA, 40)
+ .Substitute(thA, 0.0)
+ .Substitute(g, 9.8),
+ 180.70158058105025);
+
+ //"".Disp();
+
+ //("What are the horizontal and vertical components " +
+ // "of the velocity of the package just before it hits the ground?").Disp(); "".Disp();
+
+ //"symbolic velocity.x:".Disp();
+
+ //objB.velocity.x.Disp(); "".Disp();
+
+ AssertIsTrue(objB.velocity.x == cos(thA) * vA);
+
+ //"symbolic velocity.y:".Disp();
+
+ //objB.velocity.y.Disp(); "".Disp();
+
+ AssertIsTrue(
+ objB.velocity.y
+ ==
+ -1 * (((sin(thA) ^ 2) * (vA ^ 2) + 2 * g * yA) ^ (new Integer(1) / 2)));
+
+ //"numeric velocity.x:".Disp();
+
+ //objB.velocity.x
+ // .Substitute(xA, 0)
+ // .Substitute(yA, 100)
+ // .Substitute(vA, 40)
+ // .Substitute(thA, 0.0)
+ // .Substitute(g, 9.8)
+ // .Disp(); "".Disp();
+
+ AssertEqual(
+ objB.velocity.x
+ .Substitute(xA, 0)
+ .Substitute(yA, 100)
+ .Substitute(vA, 40)
+ .Substitute(thA, 0.0)
+ .Substitute(g, 9.8),
+ 40);
+
+ //"numeric velocity.y:".Disp();
+
+ //objB.velocity.y
+ // .Substitute(xA, 0)
+ // .Substitute(yA, 100)
+ // .Substitute(vA, 40)
+ // .Substitute(thA, 0.0)
+ // .Substitute(g, 9.8)
+ // .Disp(); "".Disp();
+
+ AssertEqual(
+ objB.velocity.y
+ .Substitute(xA, 0)
+ .Substitute(yA, 100)
+ .Substitute(vA, 40)
+ .Substitute(thA, 0.0)
+ .Substitute(g, 9.8),
+ -44.271887242357316);
+ }
+ #endregion
+
#region PSE 5E EXAMPLE 4.7
{
Please sign in to comment.
Something went wrong with that request. Please try again.