Zephyr Scientific Library (zscilib)
Files | Functions
Gravitation

Gravitation functions. More...

Files

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

Functions

int zsl_phy_grav_orb_period (zsl_real_t mp, zsl_real_t msat, zsl_real_t r, zsl_real_t *t)
 Calculates the orbital period of a satelite orbiting another body in seconds based on the distance between the bodies (r) and their masses. More...
 
int zsl_phy_grav_esc_vel (zsl_real_t mp, zsl_real_t r, zsl_real_t *v)
 Calculates the velocity needed for an object to overcome the gravitational pull of the planet it is on in meters per second based on the mass (mp) and the radius (r) of the planet. More...
 
int zsl_phy_grav_acc (zsl_real_t m, zsl_real_t r, zsl_real_t *a)
 Calculates the gravitational acceleration at any point created by an object of mass 'm' in meters per second squared. More...
 
int zsl_phy_grav_orb_vel (zsl_real_t mp, zsl_real_t r, zsl_real_t *v)
 Calculates the velocity of an object moving about a planet describing a circular orbit in meters per second based on the mass of the planet (mp) and the radius (r) of the orbit. More...
 
int zsl_phy_grav_force (zsl_real_t m1, zsl_real_t m2, zsl_real_t r, zsl_real_t *f)
 Calculates the gravitational force between two objects in newtons based on their masses (m1 and m2) and the distance they are separeted (r). More...
 
int zsl_phy_grav_pot_ener (zsl_real_t m1, zsl_real_t m2, zsl_real_t r, zsl_real_t *u)
 Calculates the gravitational potential energy between two objects in kilojoules based on their masses (m1 and m2) and the distance they are separated (r). More...
 

Detailed Description

Gravitation functions.

Function Documentation

◆ zsl_phy_grav_acc()

int zsl_phy_grav_acc ( zsl_real_t  m,
zsl_real_t  r,
zsl_real_t a 
)

Calculates the gravitational acceleration at any point created by an object of mass 'm' in meters per second squared.

Parameters
mMass of the object in kilograms.
rDistance between the point and the object in meters.
aPointer to the output acceleration in meters per second squared. Will be set to NAN if the distance is zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_grav_esc_vel()

int zsl_phy_grav_esc_vel ( zsl_real_t  mp,
zsl_real_t  r,
zsl_real_t v 
)

Calculates the velocity needed for an object to overcome the gravitational pull of the planet it is on in meters per second based on the mass (mp) and the radius (r) of the planet.

Parameters
mpMass of the planet in kilograms.
rRadius of the planet in meters.
vPointer to the output escape velocity in meters per second. Will be set to NAN if the radius of the planet is zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_grav_force()

int zsl_phy_grav_force ( zsl_real_t  m1,
zsl_real_t  m2,
zsl_real_t  r,
zsl_real_t f 
)

Calculates the gravitational force between two objects in newtons based on their masses (m1 and m2) and the distance they are separeted (r).

Parameters
m1Mass of the first object in kilograms.
m2Mass of the second object in kilograms.
rDistance between the objects in meters.
fPointer to the output force in newtons. Will be set to NAN if the distance is zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_grav_orb_period()

int zsl_phy_grav_orb_period ( zsl_real_t  mp,
zsl_real_t  msat,
zsl_real_t  r,
zsl_real_t t 
)

Calculates the orbital period of a satelite orbiting another body in seconds based on the distance between the bodies (r) and their masses.

Parameters
mpMass of the central body in kilograms.
msatMass of the orbiting body in kilograms.
rSemimajor axis of the orbit in meters (if the orbit is circular, this will be equal to the radius of the orbit).
tPointer to the output orbital period in seconds. Will be set to NAN if the sum of both masses is zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_grav_orb_vel()

int zsl_phy_grav_orb_vel ( zsl_real_t  mp,
zsl_real_t  r,
zsl_real_t v 
)

Calculates the velocity of an object moving about a planet describing a circular orbit in meters per second based on the mass of the planet (mp) and the radius (r) of the orbit.

Parameters
mpMass of the planet in kilograms.
rRadius of the orbit in meters.
vPointer to the output velocity tangent to the orbit in meters per second. Will be set to NAN if the radius of the orbit is zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_grav_pot_ener()

int zsl_phy_grav_pot_ener ( zsl_real_t  m1,
zsl_real_t  m2,
zsl_real_t  r,
zsl_real_t u 
)

Calculates the gravitational potential energy between two objects in kilojoules based on their masses (m1 and m2) and the distance they are separated (r).

Parameters
m1Mass of the first object in kilograms.
m2Mass of the second object in kilograms.
rDistance between the objects in meters.
uPointer to the output potential energy in kilojoules. Will be set to NAN if the distance is zero.
Returns
0 if everything executed properly, error code on failure.