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

A sliding joint with limits and motor control. More...

#include <Joints.h>

+ Inheritance diagram for FxPrismaticJoint:
+ Collaboration diagram for FxPrismaticJoint:

Public Member Functions

 FxPrismaticJoint (const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &local_axis, float position_min=-1000.0f, float position_max=1000.0f)
 
bool is_prismatic () const override
 
void set_position (float position, bool instant=true)
 
void set_velocity (float velocity, bool instant=true)
 
void set_force (float force)
 
float get_position () const
 
float get_velocity () 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
 

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

A sliding joint with limits and motor control.

Definition at line 126 of file Joints.h.

Constructor & Destructor Documentation

◆ FxPrismaticJoint()

FxPrismaticJoint::FxPrismaticJoint ( const std::string &  name,
const std::shared_ptr< FxEntity > &  e1,
const std::shared_ptr< FxEntity > &  e2,
const FxVec2f &  local_axis,
float  position_min = -1000.0f,
float  position_max = 1000.0f 
)

Member Function Documentation

◆ apply_controls()

void FxPrismaticJoint::apply_controls ( double  dt)
overridevirtual

Implements FxJoint.

◆ get_max_force()

float FxPrismaticJoint::get_max_force ( ) const
inline

Definition at line 153 of file Joints.h.

◆ get_position()

float FxPrismaticJoint::get_position ( ) const

◆ get_velocity()

float FxPrismaticJoint::get_velocity ( ) const

◆ is_prismatic()

bool FxPrismaticJoint::is_prismatic ( ) const
inlineoverridevirtual

Reimplemented from FxJoint.

Definition at line 142 of file Joints.h.

◆ set_force()

void FxPrismaticJoint::set_force ( float  force)

◆ set_max_force()

void FxPrismaticJoint::set_max_force ( float  max_force)
inline

Definition at line 152 of file Joints.h.

◆ set_position()

void FxPrismaticJoint::set_position ( float  position,
bool  instant = true 
)

◆ set_velocity()

void FxPrismaticJoint::set_velocity ( float  velocity,
bool  instant = true 
)

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