pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
Model::BodyProxy Class Reference

A proxy object that provides an AoS-like interface to a body stored in the Bodies SoA container. More...

#include <body.hpp>

Inheritance diagram for Model::BodyProxy:
Inheritance graph
Collaboration diagram for Model::BodyProxy:
Collaboration graph

Public Member Functions

 BodyProxy (Bodies &in_bodies, std::size_t in_index)
 Construct a new Body Proxy object. More...
 
 operator ConstBodyProxy () const
 Implicit conversion operator to a const proxy. More...
 
Vector3d & a ()
 Access to body accelerations. More...
 
Vector3d & alpha ()
 Access to body angular accelerations. More...
 
Vector3d & omega ()
 Access to body angular velocities. More...
 
void addToX (const Vector3d &correction)
 Add a displacement to a position. More...
 
Vector3d applyImpulse (const Vector3d &in_J, const Vector3d &in_r_vec)
 Apply an impulse to a body. More...
 
void setAcceleration (const Vector3d &new_a)
 Set the acceleration of a body. More...
 
void setAngularAcceleration (const Vector3d &new_alpha)
 Set the angular acceleration of a body. More...
 
void accumulateAcceleration (const Vector3d &accel)
 Accumulate an acceleration to a body. More...
 
void accumulateAngularAcceleration (const Vector3d &in_alpha)
 Accumulate an angular acceleration to a body. More...
 
void resetAccelerations ()
 Resets linear and angular accelerations to zero. More...
 
void resetTorque ()
 Resets the accumulated torque to zero. More...
 
void accumulateTorque (const Vector3d &torque)
 Accumulates a torque vector to the body's total torque. More...
 
void dampenVelocity (double linear_damping, double angular_damping)
 Applies damping to linear and angular velocities. More...
 
void updateAlphaFromTorque ()
 Updates angular acceleration based on the accumulated torque. More...
 
- Public Member Functions inherited from Model::BodyProxyBase< Bodies >
 BodyProxyBase (Bodies &in_bodies, std::size_t in_index)
 Construct a new Body Proxy Base object. More...
 
double m () const noexcept
 Access to body masses. More...
 
double getInverseMass () const
 Access to the inverse of the body masses. More...
 
double r () const noexcept
 Access to body radii. More...
 
double getInverseInertia () const
 Access to the inverse of the body's moment of inertia. More...
 
const Vector3d & x () const noexcept
 Access to body positions. More...
 
const Vector3d & v () const noexcept
 Access to body velocities. More...
 
const Quaterniond & q () const noexcept
 Access to body orientation. More...
 
const Vector3d & omega () const noexcept
 Access to body angular velocities. More...
 

Additional Inherited Members

- Protected Attributes inherited from Model::BodyProxyBase< Bodies >
Bodiesbodies_
 Reference to the main SoA container. More...
 
std::size_t index_
 The index of the body this proxy refers to. More...
 

Detailed Description

A proxy object that provides an AoS-like interface to a body stored in the Bodies SoA container.

Mutable proxy for accessing individual bodies in the Bodies container.

Definition at line 141 of file body.hpp.

Constructor & Destructor Documentation

◆ BodyProxy()

Model::BodyProxy::BodyProxy ( Bodies in_bodies,
std::size_t  in_index 
)
inline

Construct a new Body Proxy object.

Parameters
in_bodiesThe Bodies container to be accessed.
in_indexThe index of the body this proxy will access.

Definition at line 493 of file body.hpp.

Member Function Documentation

◆ a()

Vector3d & Model::BodyProxy::a ( )
inline

Access to body accelerations.

Returns
A mutable reference to the body's linear acceleration vector.

Definition at line 500 of file body.hpp.

◆ accumulateAcceleration()

void Model::BodyProxy::accumulateAcceleration ( const Vector3d &  accel)
inline

Accumulate an acceleration to a body.

Parameters
accelThe linear acceleration vector to add.

Definition at line 528 of file body.hpp.

◆ accumulateAngularAcceleration()

void Model::BodyProxy::accumulateAngularAcceleration ( const Vector3d &  in_alpha)
inline

Accumulate an angular acceleration to a body.

Parameters
in_alphaThe angular acceleration vector to add.

Definition at line 532 of file body.hpp.

◆ accumulateTorque()

void Model::BodyProxy::accumulateTorque ( const Vector3d &  torque)
inline

Accumulates a torque vector to the body's total torque.

Definition at line 544 of file body.hpp.

Here is the caller graph for this function:

◆ addToX()

void Model::BodyProxy::addToX ( const Vector3d &  correction)
inline

Add a displacement to a position.

Parameters
correctionCorrection to be applied.

Definition at line 510 of file body.hpp.

Here is the caller graph for this function:

◆ alpha()

Vector3d & Model::BodyProxy::alpha ( )
inline

Access to body angular accelerations.

Returns
A mutable reference to the body's angular acceleration vector.

Definition at line 502 of file body.hpp.

◆ applyImpulse()

Vector3d Model::BodyProxy::applyImpulse ( const Vector3d &  in_J,
const Vector3d &  in_r_vec 
)
inline

Apply an impulse to a body.

Parameters
in_JImpulse to be applied.
in_r_vecVector from the centre of mass to the contact point.
Returns
The torque vector generated by the impulse on this body.

Definition at line 514 of file body.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dampenVelocity()

void Model::BodyProxy::dampenVelocity ( double  linear_damping,
double  angular_damping 
)
inline

Applies damping to linear and angular velocities.

Parameters
linear_dampingThe damping factor for linear velocity.
angular_dampingThe damping factor for angular velocity.

Definition at line 552 of file body.hpp.

◆ omega()

Vector3d & Model::BodyProxy::omega ( )
inline

Access to body angular velocities.

Returns
A mutable reference to the body's angular velocity vector.

Definition at line 504 of file body.hpp.

Here is the caller graph for this function:

◆ operator ConstBodyProxy()

Model::BodyProxy::operator ConstBodyProxy ( ) const
inline

Implicit conversion operator to a const proxy.

Returns
A const proxy to the same body.

Definition at line 496 of file body.hpp.

◆ resetAccelerations()

void Model::BodyProxy::resetAccelerations ( )
inline

Resets linear and angular accelerations to zero.

Definition at line 537 of file body.hpp.

◆ resetTorque()

void Model::BodyProxy::resetTorque ( )
inline

Resets the accumulated torque to zero.

Definition at line 542 of file body.hpp.

◆ setAcceleration()

void Model::BodyProxy::setAcceleration ( const Vector3d &  new_a)
inline

Set the acceleration of a body.

Parameters
new_aThe new linear acceleration vector.

Definition at line 520 of file body.hpp.

◆ setAngularAcceleration()

void Model::BodyProxy::setAngularAcceleration ( const Vector3d &  new_alpha)
inline

Set the angular acceleration of a body.

Parameters
new_alphaThe new angular acceleration vector.

Definition at line 524 of file body.hpp.

◆ updateAlphaFromTorque()

void Model::BodyProxy::updateAlphaFromTorque ( )
inline

Updates angular acceleration based on the accumulated torque.

Definition at line 548 of file body.hpp.

Here is the call graph for this function:

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