22. ‘‘Get the program
correct before trying to provide good output.’’
Henry F. Ledgard, ‘‘Programming Proverbs:
Principles of Good Programming with Numerous Examples to
Improve Programming Style and Proficiency’’,
(Hayden Computer Programming Series), Hayden Book Company,
1st edition, ISBN-13: 978-0810455221, December 1975.
2. Collision prediction between circles
de-tour
recall
we can predict the time a point travels a distance by:
s = distance
u = initial velocity
a = acceleration
t = time
3. De-tour
if we were to drop a small ball
bearing from 1 metre, how long would it take to hit the
ground?
initial velocity (u =
0)
acceleration approx (a = 10)
thus
t = 0.45
t = -0.45
we also note that for
more complicated quadratic equations we can use the formula:
for any equation matching:
4. Collision prediction between circles
each circle has a radius,
position, velocity and acceleration
radius is a scalar, all others are vectors
remember that when these circles collide the distance
between the two circle mid points will be
we know generally that the distance between the circles
can be calculated as:
so we need to find the time when:
using the formula for initial position, velocity
and acceleration:
it is also known that the position circle
at time,
, is:
correspondingly the position circle
at time,
, is:
recall Pythagorean theorem can be used to find the
length of the hypotenuse from the length of the base and
height of a right angled triangle
is the radius of circle 0 and circle 1
is the difference of the y-axis position of the circles
is the difference of the x-axis position of the circles
therefore we need to find the time at which the distance
between both circles is
which is: