Fx2D
A C++20 2D rigid-body physics engine
Loading...
Searching...
No Matches
FxDistanceJoint Class Reference

#include <Joints.h>

Inheritance diagram for FxDistanceJoint:
Collaboration diagram for FxDistanceJoint:

Public Member Functions

 FxDistanceJoint (const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &anchor1={0.0f, 0.0f}, const FxVec2f &anchor2={0.0f, 0.0f}, float min_length=-1.0f, float max_length=-1.0f)
bool is_distance () const override
void set_limits (float min_length, float max_length)
float get_min_length () const
float get_max_length () const
void set_compliance (double compliance)
void set_link_stiffness (double stiffness)
void set_length (float length, bool instant=true)
void set_rate (float rate, bool instant=true)
void set_force (float force)
float get_length () const
float get_rate () const
void set_max_force (float max_force)
float get_max_force () const
void apply_controls (double dt) override
Public Member Functions inherited from FxJoint
 FxJoint (const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2)
virtual ~FxJoint ()=default
const std::string & get_name () const
void reset ()
const std::shared_ptr< FxEntity > & get_entity1 () const
const std::shared_ptr< FxEntity > & get_entity2 () const
std::string get_entity1_name () const
std::string get_entity2_name () const
const std::vector< std::shared_ptr< FxConstraint > > & get_constraints () const
void set_pid (const FxVec3f &pid)
FxVec3f get_pid () const
void set_p (float p)
void set_i (float i)
void set_d (float d)
float get_p () const
float get_i () const
float get_d () const
void set_instant (bool instant)
bool get_instant () const
void set_effort (float effort)
float get_effort () const
void set_max_effort (float max_effort)
float get_max_effort () const
void set_control_mode (ControlMode mode)
ControlMode get_control_mode () const
virtual bool is_revolute () const
virtual bool is_prismatic () const

Additional Inherited Members

Public Attributes inherited from FxJoint
bool enabled = true
bool entities_collide = false
Protected Member Functions inherited from FxJoint
void namespace_constraints ()
void reset_pid_state ()
void wake_entities ()
float eval_pid (float error, double dt)
float clamp_effort (float effort) const
Protected Attributes inherited from FxJoint
std::shared_ptr< FxEntity > entity1
std::shared_ptr< FxEntity > entity2
std::string m_name
std::vector< std::shared_ptr< FxConstraint > > m_constraints
FxVec3f m_pid {1.0f, 0.0f, 0.0f}
float m_integral = 0.0f
float m_previous_error = 0.0f
float m_target_effort = 0.0f
bool m_instant = true

Detailed Description

Definition at line 129 of file Joints.h.

Constructor & Destructor Documentation

◆ FxDistanceJoint()

FxDistanceJoint::FxDistanceJoint ( const std::string & name,
const std::shared_ptr< FxEntity > & e1,
const std::shared_ptr< FxEntity > & e2,
const FxVec2f & anchor1 = {0.0f, 0.0f},
const FxVec2f & anchor2 = {0.0f, 0.0f},
float min_length = -1.0f,
float max_length = -1.0f )

Member Function Documentation

◆ apply_controls()

void FxDistanceJoint::apply_controls ( double dt)
overridevirtual

Implements FxJoint.

◆ get_length()

float FxDistanceJoint::get_length ( ) const

◆ get_max_force()

float FxDistanceJoint::get_max_force ( ) const
inline

Definition at line 167 of file Joints.h.

◆ get_max_length()

float FxDistanceJoint::get_max_length ( ) const
inline

Definition at line 152 of file Joints.h.

◆ get_min_length()

float FxDistanceJoint::get_min_length ( ) const
inline

Definition at line 151 of file Joints.h.

◆ get_rate()

float FxDistanceJoint::get_rate ( ) const

◆ is_distance()

bool FxDistanceJoint::is_distance ( ) const
inlineoverridevirtual

Reimplemented from FxJoint.

Definition at line 146 of file Joints.h.

◆ set_compliance()

void FxDistanceJoint::set_compliance ( double compliance)
inline

Definition at line 155 of file Joints.h.

◆ set_force()

void FxDistanceJoint::set_force ( float force)

◆ set_length()

void FxDistanceJoint::set_length ( float length,
bool instant = true )

◆ set_limits()

void FxDistanceJoint::set_limits ( float min_length,
float max_length )

◆ set_link_stiffness()

void FxDistanceJoint::set_link_stiffness ( double stiffness)
inline

Definition at line 156 of file Joints.h.

◆ set_max_force()

void FxDistanceJoint::set_max_force ( float max_force)
inline

Definition at line 166 of file Joints.h.

◆ set_rate()

void FxDistanceJoint::set_rate ( float rate,
bool instant = true )

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