This Lua script models the motion of a projectile launched at a specific angle and initial velocity. It calculates key details of the parabolic trajectory, including:
- Maximum height
- Horizontal range
- Time of flight
- Simulates the projectile's motion with gravity and an optional initial height.
- Computes key points of the parabola, such as the vertex and roots.
- Measures execution time for performance analysis.
The script uses a quadratic equation to represent the trajectory: [ y = ax^2 + bx + c ] Where:
- ( a ): determined by gravity and initial velocity.
- ( b ): determined by the launch angle.
- ( c ): initial height.
Iterative calculations are performed to determine the point where the projectile hits the ground.
- Save the script as
projectile_motion.lua. - Ensure Lua is installed on your system.
- Run the script in your terminal:
lua projectile_motion.lua