-
Notifications
You must be signed in to change notification settings - Fork 2
/
GRAVITY.DOC
66 lines (33 loc) · 1.19 KB
/
GRAVITY.DOC
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
GRAVITY SIMULATION IN SCI
Standard gravitational acceleration is 9.8 m/s/s. To convert this to the
SCI simulation units of pixels/cycle/cycle, we use the following formula
g = 9.8 * h/(f ** 2)
where
h is the height, in pixels, of a one meter tall object
f is the frequency, in cycles/second, of the animation cycles
Normal animation speed is 10 animation cycles/second, so in general this
reduces to
g = .098 * h
A standard sized actor is about 33 pixels tall. Assuming that the actor is
a meter tall, we get a default g of
g = 3.23
= 3
JumpTo
The JumpTo motion class is designed to allow an actor to jump to a certain
point on the screen. This is done by assuming that, in the Jump class, the
horizontal and vertical speeds are related by the scale factor n. We then
solve for the magnitude which gets us where we want to go.
The x coordinate of the endpoint is given by
x1 = x0 + v * t
so that
t = (x1 - x0)/v
The y coordinate is given by
y1 = y0 + n * v * t + g * t**2/2
= y0 + n * v * (x1 - x0)/v + g * (x1 - x0)**2/(2 * v**2)
writing
dx = x1 - x0
dy = y1 - y0
we have
dy - n * dx = g * dx**2/(2 * v**2)
so that
v = sqrt(g * dx**2/(2 * (dy - dx)))