Antkeeper  0.0.1
Public Types | Public Member Functions | List of all members
physics::numeric_spring< T, S > Class Template Reference

Numeric spring. More...

#include <spring.hpp>

Public Types

using value_type = T
 Value type. More...
 
using scalar_type = S
 Scalar type. More...
 

Public Member Functions

constexpr void solve (scalar_type dt) noexcept
 Solves the spring using the implicit Euler method. More...
 
constexpr void set_value (const value_type &value) noexcept
 Sets the current value of the spring. More...
 
constexpr void set_target_value (const value_type &value) noexcept
 Sets the target value of the spring. More...
 
constexpr void set_velocity (const value_type &velocity) noexcept
 Sets the velocity of the spring. More...
 
constexpr void set_damping_ratio (scalar_type ratio) noexcept
 Sets the damping ratio of the spring. More...
 
constexpr void set_angular_frequency (scalar_type angular_frequency) noexcept
 Sets the angular frequency of the spring oscillation. More...
 
constexpr void set_period (scalar_type period) noexcept
 Sets the oscillation period of the spring. More...
 
constexpr void set_frequency (scalar_type frequency) noexcept
 Sets the oscillation frequency of the spring. More...
 
constexpr const value_typeget_value () const noexcept
 Returns the current value of the spring. More...
 
constexpr const value_typeget_target_value () const noexcept
 Returns the target value of the spring. More...
 
constexpr const value_typeget_velocity () const noexcept
 Returns the velocity of the spring. More...
 
constexpr scalar_type get_damping_ratio () const noexcept
 Returns the damping ratio of the spring. More...
 
constexpr scalar_type get_angular_frequency () const noexcept
 Returns the angular frequency of the spring oscillation, in radians per second. More...
 
constexpr scalar_type get_period () const noexcept
 Returns the oscillation period of the spring, in seconds. More...
 
constexpr scalar_type get_frequency () const noexcept
 Returns the oscillation frequency of the spring, in hertz. More...
 

Detailed Description

template<class T, class S>
class physics::numeric_spring< T, S >

Numeric spring.

Template Parameters
TValue type.
SScalar type.

Definition at line 60 of file spring.hpp.

Member Typedef Documentation

◆ scalar_type

template<class T , class S >
using physics::numeric_spring< T, S >::scalar_type = S

Scalar type.

Definition at line 67 of file spring.hpp.

◆ value_type

template<class T , class S >
using physics::numeric_spring< T, S >::value_type = T

Value type.

Definition at line 64 of file spring.hpp.

Member Function Documentation

◆ get_angular_frequency()

template<class T , class S >
constexpr scalar_type physics::numeric_spring< T, S >::get_angular_frequency ( ) const
inlineconstexprnoexcept

Returns the angular frequency of the spring oscillation, in radians per second.

Definition at line 174 of file spring.hpp.

◆ get_damping_ratio()

template<class T , class S >
constexpr scalar_type physics::numeric_spring< T, S >::get_damping_ratio ( ) const
inlineconstexprnoexcept

Returns the damping ratio of the spring.

Definition at line 168 of file spring.hpp.

◆ get_frequency()

template<class T , class S >
constexpr scalar_type physics::numeric_spring< T, S >::get_frequency ( ) const
inlineconstexprnoexcept

Returns the oscillation frequency of the spring, in hertz.

Definition at line 186 of file spring.hpp.

◆ get_period()

template<class T , class S >
constexpr scalar_type physics::numeric_spring< T, S >::get_period ( ) const
inlineconstexprnoexcept

Returns the oscillation period of the spring, in seconds.

Definition at line 180 of file spring.hpp.

◆ get_target_value()

template<class T , class S >
constexpr const value_type& physics::numeric_spring< T, S >::get_target_value ( ) const
inlineconstexprnoexcept

Returns the target value of the spring.

Definition at line 156 of file spring.hpp.

◆ get_value()

template<class T , class S >
constexpr const value_type& physics::numeric_spring< T, S >::get_value ( ) const
inlineconstexprnoexcept

Returns the current value of the spring.

Definition at line 150 of file spring.hpp.

◆ get_velocity()

template<class T , class S >
constexpr const value_type& physics::numeric_spring< T, S >::get_velocity ( ) const
inlineconstexprnoexcept

Returns the velocity of the spring.

Definition at line 162 of file spring.hpp.

◆ set_angular_frequency()

template<class T , class S >
constexpr void physics::numeric_spring< T, S >::set_angular_frequency ( scalar_type  angular_frequency)
inlineconstexprnoexcept

Sets the angular frequency of the spring oscillation.

Parameters
wAngular frequency, in radians per second.

Definition at line 124 of file spring.hpp.

◆ set_damping_ratio()

template<class T , class S >
constexpr void physics::numeric_spring< T, S >::set_damping_ratio ( scalar_type  ratio)
inlineconstexprnoexcept

Sets the damping ratio of the spring.

Parameters
ratioDamping ratio, which can be undamped (0), underdamped (< 1), critically damped (1), or overdamped (> 1).

Definition at line 114 of file spring.hpp.

◆ set_frequency()

template<class T , class S >
constexpr void physics::numeric_spring< T, S >::set_frequency ( scalar_type  frequency)
inlineconstexprnoexcept

Sets the oscillation frequency of the spring.

Parameters
frequencyOscillation frequency, in hertz.

Definition at line 144 of file spring.hpp.

◆ set_period()

template<class T , class S >
constexpr void physics::numeric_spring< T, S >::set_period ( scalar_type  period)
inlineconstexprnoexcept

Sets the oscillation period of the spring.

Parameters
periodOscillation period, in seconds.

Definition at line 134 of file spring.hpp.

◆ set_target_value()

template<class T , class S >
constexpr void physics::numeric_spring< T, S >::set_target_value ( const value_type value)
inlineconstexprnoexcept

Sets the target value of the spring.

Parameters
valueTarget value.

Definition at line 94 of file spring.hpp.

◆ set_value()

template<class T , class S >
constexpr void physics::numeric_spring< T, S >::set_value ( const value_type value)
inlineconstexprnoexcept

Sets the current value of the spring.

Parameters
valueCurrent value.

Definition at line 84 of file spring.hpp.

◆ set_velocity()

template<class T , class S >
constexpr void physics::numeric_spring< T, S >::set_velocity ( const value_type velocity)
inlineconstexprnoexcept

Sets the velocity of the spring.

Parameters
velocitySpring velocity.

Definition at line 104 of file spring.hpp.

◆ solve()

template<class T , class S >
constexpr void physics::numeric_spring< T, S >::solve ( scalar_type  dt)
inlineconstexprnoexcept

Solves the spring using the implicit Euler method.

Parameters
dtDelta time, in seconds.

Definition at line 74 of file spring.hpp.


The documentation for this class was generated from the following file: