Zephyr Scientific Library (zscilib)
Files | Functions
Projectiles

Projectile functions. More...

Files

file  projectiles.h
 API header file for projectiles in zscilib.
 

Functions

int zsl_phy_proj_init_vel (zsl_real_t vi, zsl_real_t theta, zsl_real_t *vih, zsl_real_t *viv)
 Decomposes the initial velocity of an object under projectile motion into its horizontal and vertical components based on the angle (theta) it is launched at. More...
 
int zsl_phy_proj_time (zsl_real_t viv, zsl_real_t yi, zsl_real_t yf, zsl_real_t *t)
 Calculates the total time of travel in seconds of an object under projectile motion from an initial height (yi) and a final height (yf) given the vertical velocity at the starting point. Measurements are based on reaching yf on descent. More...
 
int zsl_phy_proj_time_first (zsl_real_t viv, zsl_real_t yi, zsl_real_t yf, zsl_real_t *t)
 Calculates the total time of travel in seconds of an object under projectile motion from an initial height (yi) and a final height (yf) given the vertical velocity at the starting point. Measurements are based on the first instance that yf is reached, which can occur during the ascent or descent stages depending on values provided. More...
 
int zsl_phy_proj_time2 (zsl_real_t viv, zsl_real_t vfv, zsl_real_t *t)
 Calculates the total time of travel in seconds of an object under projectile motion based on the vertical velocity at the starting and ending points. More...
 
int zsl_phy_proj_ver_motion (zsl_real_t viv, zsl_real_t t, zsl_real_t yi, zsl_real_t *yf)
 Calculates the height in meters of an object under projectile motion based on the initial vertical velocity (viv), the initial height (yi) and the time (t). More...
 
int zsl_phy_proj_ver_vel (zsl_real_t viv, zsl_real_t t, zsl_real_t *vfv)
 Calculates the vertical velocity in meters per second of an object under projectile motion based on the initial vertical velocity (viv), and the time (t). More...
 
int zsl_phy_proj_hor_motion (zsl_real_t vih, zsl_real_t t, zsl_real_t xi, zsl_real_t *xf)
 Calculates the horizontal position in meters of an object under projectile motion based on the horizontal velocity (vih), the time (t) and the initial horizontal position (xi). More...
 
int zsl_phy_proj_trajectory (zsl_real_t vih, zsl_real_t viv, zsl_real_t xi, zsl_real_t yi, zsl_real_t xf, zsl_real_t *yf)
 Calculates the vertical position in meters of an object under projectile motion at any given horizontal position, knowing the initial vertical velocity (viv), the horizontal velocity (vih) and the coordinates of the launching point (xi, yi). More...
 
int zsl_phy_proj_vel (zsl_real_t vfh, zsl_real_t vfv, zsl_real_t *vf)
 Calculates the module of the total velocity in meters per second of an object under projectile motion at any point, given the vertical (vfv) and horizontal (vfh) velocities at that point. More...
 
int zsl_phy_proj_angle (zsl_real_t vfh, zsl_real_t vfv, zsl_real_t *theta)
 Calculates the angle in radians between the floor and the total velocity of an object under projectile motion based on the vertical (vfv) and horizontal (vfh) velocities. More...
 
int zsl_phy_proj_range (zsl_real_t vih, zsl_real_t viv, zsl_real_t xi, zsl_real_t yi, zsl_real_t *dist)
 Calculates the horizontal distance in meters between the launching point of an object and the point where it reaches the ground based on the initial vertical velocity (viv), the horizontal velocity (vih) and the coordinates of the launching point (xi, yi). More...
 

Detailed Description

Projectile functions.

Function Documentation

◆ zsl_phy_proj_angle()

int zsl_phy_proj_angle ( zsl_real_t  vfh,
zsl_real_t  vfv,
zsl_real_t theta 
)

Calculates the angle in radians between the floor and the total velocity of an object under projectile motion based on the vertical (vfv) and horizontal (vfh) velocities.

Parameters
vfhHorizontal velocity of the object in meters per second.
vfvVertical velocity of the object in meters per second.
thetaPointer to the output angle in radians.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_proj_hor_motion()

int zsl_phy_proj_hor_motion ( zsl_real_t  vih,
zsl_real_t  t,
zsl_real_t  xi,
zsl_real_t xf 
)

Calculates the horizontal position in meters of an object under projectile motion based on the horizontal velocity (vih), the time (t) and the initial horizontal position (xi).

Parameters
vihHorizontal velocity of the object in meters per second.
tTime that has transcurred from the moment the object was launched, in seconds.
xiHorizontal initial position of the object in meters.
xfPointer to the output horizontal position in meters. If the time is negative, it will be set to NAN.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_proj_init_vel()

int zsl_phy_proj_init_vel ( zsl_real_t  vi,
zsl_real_t  theta,
zsl_real_t vih,
zsl_real_t viv 
)

Decomposes the initial velocity of an object under projectile motion into its horizontal and vertical components based on the angle (theta) it is launched at.

Parameters
viInitial velocity of the object in meters per second.
thetaAngle between the floor and the initial velocity in radians.
vihPointer to the output horizontal component of the initial velocity in meters per second.
vivPointer to the output vertical component of the initial velocity in meters per second.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_proj_range()

int zsl_phy_proj_range ( zsl_real_t  vih,
zsl_real_t  viv,
zsl_real_t  xi,
zsl_real_t  yi,
zsl_real_t dist 
)

Calculates the horizontal distance in meters between the launching point of an object and the point where it reaches the ground based on the initial vertical velocity (viv), the horizontal velocity (vih) and the coordinates of the launching point (xi, yi).

Parameters
vihHorizontal velocity of the object in meters per second.
vivInitial vertical velocity of the object in meters per second.
xiHorizontal initial position of the object in meters.
yiVertical initial position of the object in meters.
distPointer to the output distance in meters.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_proj_time()

int zsl_phy_proj_time ( zsl_real_t  viv,
zsl_real_t  yi,
zsl_real_t  yf,
zsl_real_t t 
)

Calculates the total time of travel in seconds of an object under projectile motion from an initial height (yi) and a final height (yf) given the vertical velocity at the starting point. Measurements are based on reaching yf on descent.

Parameters
vivInitial vertical velocity of the object at the starting point in meters per second.
yiInitial height in meters.
yfFinal height in meters.
tPointer to the output total time of flight of the object in seconds. Will be set to NAN if the object never reaches the final height.
Returns
0 if everything executed properly, -EINVAL if the final height is never reached in the projectile's trajectory.

◆ zsl_phy_proj_time2()

int zsl_phy_proj_time2 ( zsl_real_t  viv,
zsl_real_t  vfv,
zsl_real_t t 
)

Calculates the total time of travel in seconds of an object under projectile motion based on the vertical velocity at the starting and ending points.

Parameters
vivInitial vertical velocity of the object at the starting point in meters per second.
vfvFinal vertical velocity of the object at the ending point in meters per second.
tPointer to the output total time of flight of the object in seconds. If t is a negative value, it will be set to NAN.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_proj_time_first()

int zsl_phy_proj_time_first ( zsl_real_t  viv,
zsl_real_t  yi,
zsl_real_t  yf,
zsl_real_t t 
)

Calculates the total time of travel in seconds of an object under projectile motion from an initial height (yi) and a final height (yf) given the vertical velocity at the starting point. Measurements are based on the first instance that yf is reached, which can occur during the ascent or descent stages depending on values provided.

Parameters
vivInitial vertical velocity of the object at the starting point in meters per second.
yiInitial height in meters.
yfFinal height in meters.
tPointer to the output total time of flight of the object in seconds. If t is a negative value of if the projectile doesn't reach y2, it will be set to NAN.
Returns
0 if everything executed properly, -EINVAL if the time of flight is negative or complex.

◆ zsl_phy_proj_trajectory()

int zsl_phy_proj_trajectory ( zsl_real_t  vih,
zsl_real_t  viv,
zsl_real_t  xi,
zsl_real_t  yi,
zsl_real_t  xf,
zsl_real_t yf 
)

Calculates the vertical position in meters of an object under projectile motion at any given horizontal position, knowing the initial vertical velocity (viv), the horizontal velocity (vih) and the coordinates of the launching point (xi, yi).

Parameters
vihHorizontal velocity of the object in meters per second.
vivInitial vertical velocity of the object in meters per second.
xiHorizontal initial position of the object in meters.
yiVertical initial position of the object in meters.
xfHorizontal final position of the object in meters.
yfPointer to the output height in meters. If the horizontal velocity is zero it will be set to NAN.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_proj_vel()

int zsl_phy_proj_vel ( zsl_real_t  vfh,
zsl_real_t  vfv,
zsl_real_t vf 
)

Calculates the module of the total velocity in meters per second of an object under projectile motion at any point, given the vertical (vfv) and horizontal (vfh) velocities at that point.

Parameters
vfhHorizontal velocity of the object in meters per second.
vfvVertical velocity of the object in meters per second.
vfPointer to the output total velocity in meters per second.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_proj_ver_motion()

int zsl_phy_proj_ver_motion ( zsl_real_t  viv,
zsl_real_t  t,
zsl_real_t  yi,
zsl_real_t yf 
)

Calculates the height in meters of an object under projectile motion based on the initial vertical velocity (viv), the initial height (yi) and the time (t).

Parameters
vivInitial vertical velocity of the object when launched in meters per second.
tTime that has transcurred from the moment the object was launched, in seconds.
yiInitial height of the object in meters.
yfPointer to the output height of the object in meters. If the time is negative, it will be set to NAN.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_proj_ver_vel()

int zsl_phy_proj_ver_vel ( zsl_real_t  viv,
zsl_real_t  t,
zsl_real_t vfv 
)

Calculates the vertical velocity in meters per second of an object under projectile motion based on the initial vertical velocity (viv), and the time (t).

Parameters
vivInitial vertical velocity of the object when launched in meters per second.
tTime that has transcurred from the moment the object was launched, in seconds.
vfvPointer to the output vertical velocity in meters per second. If the time is negative, it will be set to NAN.
Returns
0 if everything executed properly, error code on failure.