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

A pivot joint with angular limits and motor control. More...

#include <Joints.h>

Inheritance diagram for FxRevoluteJoint:
Collaboration diagram for FxRevoluteJoint:

Public Member Functions

 FxRevoluteJoint (const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &anchor_point, float angle_min=-3.14159f, float angle_max=3.14159f)
bool is_revolute () const override
void set_theta (float angle, bool instant=true)
void set_omega (float omega, bool instant=true)
void set_torque (float torque)
float get_theta () const
float get_omega () const
void set_max_torque (float max_torque)
float get_max_torque () 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_prismatic () const
virtual bool is_distance () 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 pivot joint with angular limits and motor control.

Definition at line 94 of file Joints.h.

Constructor & Destructor Documentation

◆ FxRevoluteJoint()

FxRevoluteJoint::FxRevoluteJoint ( const std::string & name,
const std::shared_ptr< FxEntity > & e1,
const std::shared_ptr< FxEntity > & e2,
const FxVec2f & anchor_point,
float angle_min = -3.14159f,
float angle_max = 3.14159f )

Member Function Documentation

◆ apply_controls()

void FxRevoluteJoint::apply_controls ( double dt)
overridevirtual

Implements FxJoint.

◆ get_max_torque()

float FxRevoluteJoint::get_max_torque ( ) const
inline

Definition at line 120 of file Joints.h.

◆ get_omega()

float FxRevoluteJoint::get_omega ( ) const

◆ get_theta()

float FxRevoluteJoint::get_theta ( ) const

◆ is_revolute()

bool FxRevoluteJoint::is_revolute ( ) const
inlineoverridevirtual

Reimplemented from FxJoint.

Definition at line 109 of file Joints.h.

◆ set_max_torque()

void FxRevoluteJoint::set_max_torque ( float max_torque)
inline

Definition at line 119 of file Joints.h.

◆ set_omega()

void FxRevoluteJoint::set_omega ( float omega,
bool instant = true )

◆ set_theta()

void FxRevoluteJoint::set_theta ( float angle,
bool instant = true )

◆ set_torque()

void FxRevoluteJoint::set_torque ( float torque)

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