This is an assessed exercise and should be handed in
next week for quick feedback. It will be returned the following week.
Objectives
To program a simple physics problem.
To pratice writing functions and passing pointers to them.
Task
Vector product
Revise the definition of the vector cross product in three dimensions.
Given two vectors of length three you should have the formula to
calculate their cross-product.
Write a function that takes three vectors as its arguments
and sets one to the cross-product of the other two.
Call it from main() and do a few simple tests by hand.
Keep a copy of this.
Angular momentum
Revise the vector definition of angular momentum in terms of
the cross-product of position and momentum.
Define a structure to store the mass, position, velocity and angular
momentum of a particle.
Modify your cross-product function to take a pointer to a stucture
as its argument and to calculate and store the particle's angular momentum.
Call it from main().
Now progress the particle forward in time (i.e. velocity is
unchanged but position has changed by dt *
velocity. Recalculate the angular momentum. Has it changed? Does this
surprise you?
Hand in both programs and some representative output.
When things go wrong
If you've gone 15 minutes without making progress (outside of lab
time) ask me for help, either in person or by email. Always show me
the complete, latest code.