PlayRho  1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
playrho::d2::Sweep Class Reference

Description of a "sweep" of motion in 2-D space. More...

#include <Sweep.hpp>

Collaboration diagram for playrho::d2::Sweep:
[legend]

Public Member Functions

 Sweep ()=default
 Default constructor.
 
constexpr Sweep (const Sweep &copy)=default
 Copy constructor.
 
constexpr Sweep (const Position p0, const Position p1, const Length2 lc=Length2{0_m, 0_m}, Real a0=0) noexcept
 Initializing constructor.
 
constexpr Sweep (const Position p, const Length2 lc=Length2{0_m, 0_m})
 Initializing constructor.
 
Length2 GetLocalCenter () const noexcept
 Gets the local center of mass position. More...
 
Real GetAlpha0 () const noexcept
 Gets the alpha 0 for this sweep. More...
 
void Advance0 (Real alpha) noexcept
 Advances the sweep by a factor of the difference between the given time alpha and the sweep's alpha 0. More...
 
void ResetAlpha0 () noexcept
 Resets the alpha 0 value back to zero. More...
 

Public Attributes

Position pos0
 Center world position and world angle at time "0".
 
Position pos1
 Center world position and world angle at time "1".
 

Private Attributes

Length2 localCenter = Length2{0_m, 0_m}
 Local center of mass position. More...
 
Real alpha0 = 0
 Fraction of the current time step in the range [0,1]. More...
 

Related Functions

(Note that these are not member functions.)

Sweep GetNormalized (Sweep sweep) noexcept
 Gets a sweep with the given sweep's angles normalized. More...
 
constexpr bool operator== (const Sweep &lhs, const Sweep &rhs)
 Equals operator.
 
constexpr bool operator!= (const Sweep &lhs, const Sweep &rhs)
 Not-equals operator.
 
template<>
constexpr bool IsValid (const d2::Sweep &value) noexcept
 Determines if the given value is valid.
 

Detailed Description

Description of a "sweep" of motion in 2-D space.

This describes the motion of a body/shape for TOI computation. Shapes are defined with respect to the body origin, which may not coincide with the center of mass. However, to support dynamics we must interpolate the center of mass position.

Note
This data structure is likely 36-bytes (at least on 64-bit platforms).
Examples
Body.cpp.

Member Function Documentation

◆ Advance0()

void playrho::d2::Sweep::Advance0 ( Real  alpha)
inlinenoexcept

Advances the sweep by a factor of the difference between the given time alpha and the sweep's alpha 0.

This advances position 0 (pos0) of the sweep towards position 1 (pos1) by a factor of the difference between the given alpha and the alpha 0.

Parameters
alphaValid new time factor in [0,1) to update the sweep to. Behavior is undefined if value is invalid.

Referenced by playrho::d2::Body::Advance(), and playrho::d2::Body::Advance0().

◆ GetAlpha0()

Real playrho::d2::Sweep::GetAlpha0 ( ) const
inlinenoexcept

Gets the alpha 0 for this sweep.

Returns
Value between 0 and less than 1.

Referenced by playrho::d2::GetToiViaSat(), and playrho::d2::operator==().

◆ GetLocalCenter()

Length2 playrho::d2::Sweep::GetLocalCenter ( ) const
inlinenoexcept

Gets the local center of mass position.

Note
This value can only be set via a sweep constructed using an initializing constructor.

Referenced by playrho::d2::operator==().

◆ ResetAlpha0()

void playrho::d2::Sweep::ResetAlpha0 ( )
inlinenoexcept

Resets the alpha 0 value back to zero.

Postcondition
Getting the alpha 0 value after calling this method will return zero.

Referenced by playrho::d2::Body::ResetAlpha0().

Friends And Related Function Documentation

◆ GetNormalized()

Sweep GetNormalized ( Sweep  sweep)
related

Gets a sweep with the given sweep's angles normalized.

Parameters
sweepSweep to return with its angles normalized.
Returns
Sweep with its position 0 angle to be between -2 pi and 2 pi and its position 1 angle reduced by the amount the position 0 angle was reduced by.

Member Data Documentation

◆ alpha0

Real playrho::d2::Sweep::alpha0 = 0
private

Fraction of the current time step in the range [0,1].

Note
pos0.linear and pos0.angular are the positions at alpha0.
4-bytes.

Referenced by GetAlpha0(), and ResetAlpha0().

◆ localCenter

Length2 playrho::d2::Sweep::localCenter = Length2{0_m, 0_m}
private

Local center of mass position.

Note
8-bytes.

Referenced by GetLocalCenter().


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