Antkeeper  0.0.1
Namespaces | Classes | Enumerations | Functions
physics Namespace Reference

Physics. More...

Namespaces

 constants
 Physical constants.
 
 gas
 
 light
 Gas-related functions.
 
 orbit
 Orbital mechanics.
 
 planck
 Various forms of Planck's law.
 
 time
 Time-related functions.
 

Classes

class  collider_material
 Describes the collision response of a collider. More...
 
class  collider
 Abstract base class for collision objects. More...
 
class  box_collider
 Box collision object. More...
 
class  capsule_collider
 Capsule collision object. More...
 
class  mesh_collider
 Mesh collision object. More...
 
class  plane_collider
 Plane collision object. More...
 
class  sphere_collider
 Sphere collision object. More...
 
struct  collision_contact
 Point of contact between two colliding bodies. More...
 
struct  collision_manifold
 Collection of contact points between two colliding bodies. More...
 
class  constraint
 Abstract base class for rigid body constraints. More...
 
class  spring_constraint
 Spring constraint. More...
 
class  rigid_body
 Rigid body. More...
 
class  numeric_spring
 Numeric spring. More...
 

Enumerations

enum class  collider_type : std::uint8_t {
  plane , sphere , box , capsule ,
  mesh
}
 Collider types. More...
 
enum class  friction_combine_mode : std::uint8_t { average , minimum , multiply , maximum }
 Specifies how coefficients of friction should be calculated. More...
 
enum class  restitution_combine_mode : std::uint8_t { average , minimum , multiply , maximum }
 Specifies how coefficients of restitution should be calculated. More...
 

Functions

template<class T >
constexpr T hz_to_rads (T f) noexcept
 Converts frequency to angular frequency. More...
 
template<class T >
constexpr T rads_to_hz (T w) noexcept
 Converts angular frequency to frequency. More...
 
template<class T >
constexpr T s_to_rads (T t) noexcept
 Converts oscillation period to angular frequency. More...
 
template<class T >
constexpr T rads_to_s (T w) noexcept
 Converts angular frequency to oscillation period. More...
 
float combine_friction (float a, float b, friction_combine_mode mode) noexcept
 Combines two friction values into a coefficient of friction. More...
 
float combine_restitution (float a, float b, restitution_combine_mode mode) noexcept
 Combines two restitution values into a coefficient of restitution. More...
 
template<class T >
number_density (T c)
 Calculates the number density of a substance. More...
 
template<class T , class S >
constexpr void solve_spring (T &x, T &v, const T &xt, S z, S w, S dt) noexcept
 Solves a numeric spring using the implicit Euler method. More...
 

Detailed Description

Physics.

Enumeration Type Documentation

◆ collider_type

enum physics::collider_type : std::uint8_t
strong

Collider types.

Enumerator
plane 

Plane collider.

sphere 

Sphere collider.

box 

Box collider.

capsule 

Capsule collider.

mesh 

Mesh collider.

Definition at line 30 of file collider-type.hpp.

◆ friction_combine_mode

enum physics::friction_combine_mode : std::uint8_t
strong

Specifies how coefficients of friction should be calculated.

A coefficient of friction is calculated from two collider material friction values (a and b).

Enumerator
average 

Coefficient of friction is calculated as (a + b) / 2.

minimum 

Coefficient of friction is calculated as min(a, b).

Note
Takes priority over friction_combine_mode::average
multiply 
maximum 

Definition at line 32 of file friction.hpp.

◆ restitution_combine_mode

enum physics::restitution_combine_mode : std::uint8_t
strong

Specifies how coefficients of restitution should be calculated.

A coefficient of restitution is calculated from two collider material restitution values (a and b).

Enumerator
average 

Coefficient of restitution is calculated as (a + b) / 2.

minimum 

Coefficient of restitution is calculated as min(a, b).

Note
Takes priority over restitution_combine_mode::average
multiply 
maximum 

Definition at line 32 of file restitution.hpp.

Function Documentation

◆ combine_friction()

float physics::combine_friction ( float  a,
float  b,
friction_combine_mode  mode 
)
noexcept

Combines two friction values into a coefficient of friction.

Parameters
aFirst friction value.
bSecond friction value.
modeFriction combine mode.
Returns
Coefficient of friction of a and b.

Definition at line 25 of file friction.cpp.

◆ combine_restitution()

float physics::combine_restitution ( float  a,
float  b,
restitution_combine_mode  mode 
)
noexcept

Combines two restitution values into a coefficient of restitution.

Parameters
aFirst restitution value.
bSecond restitution value.
modeRestitution combine mode.
Returns
Coefficient of restitution of a and b.

Definition at line 25 of file restitution.cpp.

◆ hz_to_rads()

template<class T >
constexpr T physics::hz_to_rads ( f)
inlineconstexprnoexcept

Converts frequency to angular frequency.

Template Parameters
TScalar type.
Parameters
fFrequency, in hertz.
Returns
Angular frequency, in radians per second.

Definition at line 37 of file frequency.hpp.

◆ number_density()

template<class T >
T physics::number_density ( c)

Calculates the number density of a substance.

Parameters
cMolar concentration, in mol/m-3.
Returns
Number density, in m-3.
See also
https://en.wikipedia.org/wiki/Number_density

Definition at line 36 of file number-density.hpp.

◆ rads_to_hz()

template<class T >
constexpr T physics::rads_to_hz ( w)
inlineconstexprnoexcept

Converts angular frequency to frequency.

Template Parameters
TScalar type.
Parameters
wAngular frequency, in radians per second.
Returns
Frequency, in hertz.

Definition at line 52 of file frequency.hpp.

◆ rads_to_s()

template<class T >
constexpr T physics::rads_to_s ( w)
inlineconstexprnoexcept

Converts angular frequency to oscillation period.

Template Parameters
TScalar type.
Parameters
wAngular frequency, in radians per second.
Returns
Oscillation period, in seconds.

Definition at line 82 of file frequency.hpp.

◆ s_to_rads()

template<class T >
constexpr T physics::s_to_rads ( t)
inlineconstexprnoexcept

Converts oscillation period to angular frequency.

Template Parameters
TScalar type.
Parameters
tOscillation period, in seconds.
Returns
Angular frequency, in radians per second.

Definition at line 67 of file frequency.hpp.

◆ solve_spring()

template<class T , class S >
constexpr void physics::solve_spring ( T &  x,
T &  v,
const T &  xt,
z,
w,
dt 
)
constexprnoexcept

Solves a numeric spring using the implicit Euler method.

Template Parameters
TValue type.
SScalar type.
Parameters
[in,out]xCurrent value of the spring.
[in,out]vCurrent velocity of the spring.
[in]xtTarget value of the spring.
[in]zDamping ratio of the spring, which can be undamped (0), underdamped (< 1), critically damped (1), or overdamped (> 1).
[in]wAngular frequency of the spring oscillation, in radians per second.
[in]dtDelta time, in seconds.

Definition at line 42 of file spring.hpp.