-
Notifications
You must be signed in to change notification settings - Fork 31
/
Program.cs
100 lines (75 loc) · 2.9 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Symbolism;
using Physics;
namespace PSE_Example_4._3_The_Long_Jump
{
class Program
{
static void Main(string[] args)
{
// A long-jumper leaves the ground at an angle of 20.0° above
// the horizontal and at a speed of 11.0 m/s.
// (a) How far does he jump in the horizontal direction?
// (Assume his motion is equivalent to that of a particle.)
// (b) What is the maximum height reached?
// For the purposes of solving the problem, let's take
// point A as the initial position
// point B as the peak position
// point C as the final position.
// First we'll get the answer in a symbolic form.
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(new Integer(0), -g); // gravity vector
// An Obj representing the object at A:
var objA =
new Obj()
{
position = new Point(0, 0),
velocity = Point.FromAngle(thA, vA),
acceleration = _g,
time = new Integer(0)
};
var objB =
new Obj()
{
position = new Point(),
velocity = new Point(objA.velocity.x, new Integer(0)),
acceleration = _g
};
var timeB = Calc.Time(objA, objB);
var timeC = timeB * 2;
objB = objA.AtTime(timeB);
var objC = objA.AtTime(timeC);
Console.WriteLine("How far does he dump in the horizontal direction?");
Console.WriteLine(objC.position.x);
Console.WriteLine();
Console.WriteLine("What is the maximum height reached?");
Console.WriteLine(objB.position.y);
Console.WriteLine();
Console.WriteLine("Now for the numerical solutions:");
Console.WriteLine();
Console.WriteLine("Distance jumped: ");
Console.WriteLine(
objC.position.x
.Substitute(thA, Trig.ToRadians(20))
.Substitute(g, 9.8)
.Substitute(Trig.Pi, 3.14159)
.Substitute(vA, 11)
);
Console.WriteLine();
Console.WriteLine("Maximum height reached: ");
Console.WriteLine(
objB.position.y
.Substitute(g, 9.8)
.Substitute(thA, Trig.ToRadians(20))
.Substitute(Trig.Pi, 3.14159)
.Substitute(vA, 11)
);
Console.ReadLine();
}
}
}