Transcript Lab 7: More Projectiles
◦ ◦ ◦ Last week we dealt with projectile physics Examined the gravity-only model Coded drag affecting projectiles Used Runge-Kutta for approximating integration Coded wind effect This week we will add the last effect…
◦ First of all, open up a completed version of last week’s lab If neither you nor your partner have it, you will have to code it again. Refer to last week’s instructions.
◦ ◦ ◦ ◦ So that we have a common starting ground, set the parameters for the following… Initial position: (0.0, 0.0, 0.0) Initial Velocity: (15.0, 20.0, 1.0) Drag Coefficient: 0.05 Mass: 10.0 Radius: 1.2
Wind Velocity: (5.0, 2.0, 0.0)
◦ Compile it and run the following scenarios IMPORTANT: Limit your simulations by either time (i.e. 5 seconds) or by position (when y position is at 0) Gravity-only model Gravity and Drag Model Gravity, Drag, and Wind Model ◦ Start outputting the magnitude of the velocity to the screen for each model sqrt (v x 2 + v y 2 + v z 2 ) ◦ Capture these outputs in separate files Use > on the command-line
◦ ◦ Spin is a very common occurrence when dealing with projectile physics.
A bullet leaving a gun will have spin A golf ball will also have spin when hit by the club Spinning objects generate force
◦ ◦ First of all, a spinning object generates lift This is called the Magnus effect (also known as Robin’s effect) The direction of the force will be perpendicular to the velocity and spin direction ◦ If the object has backspin… Then the Magnus force will be positive in the vertical direction, propelling the object upwards ◦ On the other hand, if the object has topspin… The resulting force will be in the opposite direction, thus pushing the object down
Here we can see all the forces interacting with our ball (minus the wind) ◦ ◦ ◦ ◦ ◦ ◦ Glossary: C L (lift coefficient) p (fluid density) Greek letter rho v (velocity magnitude) A (characteristic area) R (spin axis vector) w (rotation velocity) Greek letter omega
◦ ◦ We need to create some variables in our class We will need the following doubles… Spin axis components: X-axis rotation, Y-axis rotation, Z-axis rotation Angular/Rotational velocity (omega) And some way of setting/initializing them You can either have them be public and manually set them, or create get/set functions (better) ◦ ◦ Create a spin_wind_drag function It will need to take delta time as a parameter HINT: We will be using Runge-Kutta
◦ ◦ For a sphere, the force F M is defined as… F M = ½ C L * p * v 2 * A For p and A, you can just use the values calculated in the main driver function C L = (radius * rotational velocity) / v ◦ ◦ ◦ Solve the following in terms of acceleration (remember F = ma) and add them to their corresponding acceleration components.
F Mx F My = - (v = - (v = 0 y x /v) * R /v) * R y z * F M * F M F Mz Because we will rotate the sphere along the Z-axis, this component will be 0 (e.g. 0,0,1 for the spin axis vector)
Hopefully, you have now added the acceleration components to each step of Runge-Kutta.
Be sure to add your k’s appropriately to the new accelerations you added.
Let’s set the spin axis to 0,0,1 Add the appropriate line of code to the driver Compile and run
◦ What if our spin axis is on a multiple axes?
Let’s get the general form of the Magnus force F Mx F My F Mz = ((v z = ((v x = - ((v x / v) * R y / v) * R z / v) * R y – (v y – (v z – (v y / v) *R z ) * F M / v) *R x ) * F M / v) *R x ) * F M Use these forces to get your acceleration now instead of the old forces.
◦ Compile and run the with a spin axis of (0.5 ,0.5, 0.0)
◦ Use a spin axis of (0.75, 1.0, 0.0) Default values on the rest If you have completed the first exercise, you already have your data for the first three models.
Collect the data for the drag_wind_spin
◦ Plot a graph showing the differences velocity magnitude vs. time of all four models.
Bonus point(s) for the models not explicitly mentioned If you wish to use a constant delta time (instead of a timer), you may do so by replacing the measure_reset call with a flat value (i.e. 0.5)