Projectile Simulation
Шаблон:Wiki Standards Projectile motion is a form of motion experienced by an object when it is launched near the surface of the Earth and moves along a curved path under the force of gravity. This path of motion can be shown by a parabola (symmetrical curved line), or by a straight line when launched straight upwards.
Forms of Use
Projectile motion can be used to calculate the path and distance an object travels on a 2D plane (left, right, up, down). These calculations can be used to create realistic games, simulations, animations, and more.
Tutorial
Equations
When calculating projectile motion, it is good to understand what equations to use, and why they are used. The two values the user will input are a speed and an angle. With these two inputs, the first variable that needs to be found is Time. The equation used to represent time is:
t = (vfy - viy) / ag
(time = [final velocity in y direction - initial velocity in y direction] / gravity)
After time has been solved, Distance Traveled needs to be solved. The equation used to solve the distance is:
Δx = vix * t
(displacement in x direction = initial velocity in x direction * time)
But, before these equations can be solved, the velocities in the x direction and y direction need to be found. This will be done after the user inputs the initial velocity and angle launched. Шаблон:Note
Scripts
Before anything can be done, these variables need to be created:
(init vel) (angle) (init vel x) (init vel y) (final vel y) (time) (displacement)
At the start, they need to be given some values:
when green flag clicked ask [Initial Launch Speed] and wait set [init vel v] to (answer) ask [Launch Angle] and wait set [angle v] to (answer)
Now that an initial velocity and angle have been given, the velocities in the x direction and y direction need to be calculated:
set [init vel x v] to ((init vel)*([cos v] of (angle))) set [init vel y v] to ((init vel)*([sin v] of (angle))) set [final vel y v] to ((0)-(init vel y))
With these values set, time and distance traveled can be calculated:
set [time v] to (((final vel y)-(init vel y))/(-9.81)) set [displacement v] to ((init vel x)*(time))
Once these values have been calculated, there are many different things that can be done with them. An example is a projectile launch simulation. A realistic game (provided other accurate physics is included).