Projectile motion

You can model projectile motion with two quantities—velocity and acceleration.

Velocity is a vector that indicates an object's current speed and direction. You can store that value directly as a speed (in pixels per second or some other unit) and a direction (degrees or another unit), but it's usually easier to store it as X and Y velocity components. If the components are Vx and Vy, then the object moves the distance Vx in the horizontal direction and Vy in the vertical direction per unit of time. You can adjust the components' values and the time unit to change the object's speed and to control the simulation's speed.

Acceleration is a force that acts on the object to change its velocity. Depending on the simulation, acceleration may be due to many forces such as the Earth's gravity, gravitational attraction due to other objects such as planets, current (for example, if the object is a boat or a plane flying through wind), or the object's engines (for example, if the object is a spacecraft).

You can model an acceleration with components Ax and Ay much as you can model velocity. To apply acceleration to an object, simply add Ax to Vx and Ay to Vy. To apply multiple accelerations to the same object, just add them all to the object's velocity one at a time. Just as you can adjust the velocity components to change an object's speed, you can also adjust an acceleration's components to change the amount by which that acceleration affects the object.

The final thing you need to know for this problem is that the acceleration due to the Earth's gravity on a projectile always points in the downward direction. In other words, if you consider Y coordinates to increase downward as they normally do in C#, then Ax = 0 and Ay should be positive.

More complicated models might involve drag forces such as wind resistance, water resistance, or friction, but the information in the previous paragraphs should be enough to get you started. If you like, you can give the problem a try before you read the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset