Index
1. Programming Proverbs
 19. ‘‘Prettyprint 
format your code so that it looks nice.''
 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,
ISBN13: 9780810455221, December 1975.
2. Circle line collision
 assumes that we have a robust
solution to the circle circle problem which is fully
debugged and ready to be used :)

 at what time is the
earliest collision between the line and circle?
3. Step one
 is to consider the line as
stationary and only the circle as moving:
 hence we now have the
relative velocity, acceleration between the circle and line
 the radius of the circle is
4. Step two
 consider the line to be lying on the
X axis, say, with [
,
] on the point [0, 0]
 and [
,
] at [length(L) , 0]
 this involves translating
the line and circle by [
,
]
 it also involves rotating the line, circle and the
relative velocity and acceleration by
 we can redraw our diagram as:
5. Step 3
6. Step 4
 to answer both (i) and (ii) we
notice that:
 all we need to do is call our circle
circle algorithm and ask this question as whether the new
circle hits point (a circle with a radius of 0)
 to
answer (iii) we return to the diagram:
 we need to know at what
time,
, our point hits the X axis
 we only need to consider
the Y values of the velocity, position, acceleration vectors
 so:
 and solve for
 now we have a value for
we can find where about on the X axis the point will hit
using the same formula, but we plug in the X values of the
velocity, position, acceleration vectors
 let
be the new position
 if
and
 from
answering questions (i), (ii), (iii) we ignore any negative
time values, only remember the smallest time value >= 0
which tells us the next time of a collision
7. Calculating the Centre of Gravity of a polygon (centroid of polygon)
 clearly the centre of gravity for a
linear mass circle is its centre
 how do we calculate
the centre of gravity for a linear mass polygon?

centroid of a nonselfintersecting closed polygon defined
by a number of points (or vertices):

 each point or vertice must be presented in a
clockwise or anticlockwise order
 we need to find
position
which is the centre of gravity of this polygon

firstly we need to find the polygons area


 area
of box is:

 area =
8. Iteration 0.a of the area calculation
9. Iteration 0.b of the area calculation

 area
of red box  blue box = 1
10. Iteration 1.a of the area calculation
11. Iteration 1.b of the area calculation

 red
box  blue box = 2
 exercise for the reader, complete
the diagrams for the remaining iterations
12. Calculating the centre of gravity of a polygon

is calculated via:


is calculated via:

13. Calculating C of G in pge
 please see
c/twoDsim.c and the functions
calculateCofG and
calcArea
Index
1. Programming Proverbs
2. Circle line collision
3. Step one
4. Step two
5. Step 3
6. Step 4
7. Calculating the Centre of Gravity of a polygon (centroid of polygon)
8. Iteration 0.a of the area calculation
9. Iteration 0.b of the area calculation
10. Iteration 1.a of the area calculation
11. Iteration 1.b of the area calculation
12. Calculating the centre of gravity of a polygon
13. Calculating C of G in pge
Index
This document was
produced using
groff1.22.