NTRT Simulator
Version: Master
|
#include <tgBulletCompressionSpring.h>
Public Member Functions | |
tgBulletCompressionSpring (const std::vector< tgBulletSpringCableAnchor * > &anchors, bool isFreeEndAttached, double coefK, double coefD, double restLength) | |
virtual | ~tgBulletCompressionSpring () |
virtual void | step (double dt) |
virtual const double | getCurrentAnchorDistance () const |
virtual const double | getCurrentSpringLength () const |
virtual const btVector3 | getAnchorDirectionUnitVector () const |
virtual const btVector3 | getSpringEndpoint () const |
virtual const double | getSpringForce () const |
virtual const double | getCoefK () const |
virtual const double | getCoefD () const |
virtual const double | getVelocity () const |
virtual const double | getDampingForce () const |
virtual const double | getRestLength () const |
virtual const bool | isFreeEndAttached () const |
virtual const std::vector < const tgSpringCableAnchor * > | getAnchors () const |
Protected Member Functions | |
virtual void | calculateAndApplyForce (double dt) |
Protected Attributes | |
std::vector < tgBulletSpringCableAnchor * > | m_anchors |
tgBulletSpringCableAnchor *const | anchor1 |
tgBulletSpringCableAnchor *const | anchor2 |
double | m_dampingForce |
double | m_velocity |
bool | m_isFreeEndAttached |
const double | m_coefK |
const double | m_coefD |
double | m_restLength |
double | m_prevLength |
This class defines the passive dynamics of a compression spring system, with damping, in the Bullet physics engine.
Definition at line 48 of file tgBulletCompressionSpring.h.
tgBulletCompressionSpring::tgBulletCompressionSpring | ( | const std::vector< tgBulletSpringCableAnchor * > & | anchors, |
bool | isFreeEndAttached, | ||
double | coefK, | ||
double | coefD, | ||
double | restLength | ||
) |
The only constructor. Takes a list of anchors, a coefficient of stiffness, a coefficent of damping, and rest length of the spring.
[in] | anchors | - a list of this spring cable's attachements |
[in] | isFreeEndAttached | - boolean flag. If no, the spring only provides compression force. If yes, the spring is "attached" to both anchors, and provides a tension force too when the distance between anchors is greater than rest length. |
[in] | coefK | - the stiffness of the spring. Must be positive |
[in] | dampingCoefficient | - the damping in the spring. Must be non-negative. |
[in] | restLength | - the length of the compression spring when unloaded. |
The main constructor for this class
Definition at line 40 of file tgBulletCompressionSpring.cpp.
|
virtual |
The virtual destructor. Deletes all of the anchors including anchor1 and anchor2
Definition at line 87 of file tgBulletCompressionSpring.cpp.
|
protectedvirtual |
Calculates the current forces that need to be applied to the rigid bodies, and applies them to the bodies of anchor1 and anchor2
This is the method that does the heavy lifting in this class. Called by step, it calculates what force the spring is experiencing, and applies that force to the rigid bodies it connects to.
Reimplemented in tgBulletUnidirComprSpr.
Definition at line 247 of file tgBulletCompressionSpring.cpp.
|
virtual |
Return the unit vector in the direction of this spring
Returns the unit vector in the direction of this spring.
Definition at line 181 of file tgBulletCompressionSpring.cpp.
|
virtual |
Returns a const vector of const anchors. Currently casts from tgBulletSpringCableAnchors, which makes it impossible to return a reference
Definition at line 296 of file tgBulletCompressionSpring.cpp.
|
inlinevirtual |
Get the coefficent of damping
Definition at line 124 of file tgBulletCompressionSpring.h.
|
inlinevirtual |
Get the coefficent of stiffness
Definition at line 116 of file tgBulletCompressionSpring.h.
|
virtual |
Finds the distance between anchor1 and anchor2, and returns the length between them
Returns the distance between the two anchors. This is similar to the getActualLength function in tgBulletSpringCable.
Definition at line 139 of file tgBulletCompressionSpring.cpp.
|
virtual |
Returns either restLength or current anchor distance, depending on isFreeEndAttached.
Returns the current length of the spring. If isFreeEndAttached, this can be either greater or less than m_restLength. If not, then spring can only exist in compression (less than m_restLength).
Reimplemented in tgBulletUnidirComprSpr.
Definition at line 151 of file tgBulletCompressionSpring.cpp.
|
inlinevirtual |
Get the last value of the damping force
Definition at line 140 of file tgBulletCompressionSpring.h.
|
inlinevirtual |
Get the rest length of the spring (we're using these accessor functions per C++ style guidelines.)
Definition at line 149 of file tgBulletCompressionSpring.h.
|
virtual |
Return the location of the free end of the spring. This is used, in particular, for rendering. See tgBulletRenderer.
Returns the location of the endpoint of the spring in space. The renderer uses this to draw lines more easily.
Reimplemented in tgBulletUnidirComprSpr.
Definition at line 201 of file tgBulletCompressionSpring.cpp.
|
virtual |
Returns the force currently in the spring, either compression only / a positive force only (if isFreeEndAttached is false), or potentially either + or - force (if isFreeEndAttached == true).
Returns the current force in the spring. If ~isFreeEndAttached, this is zero if the distance between anchors is larger than restLength. Note that this does NOT include the force due to the damper, since that force is only temporary and isn't reallyt "the force in the spring" per se.
Reimplemented in tgBulletUnidirComprSpr.
Definition at line 217 of file tgBulletCompressionSpring.cpp.
|
inlinevirtual |
Get the last change in length / time
Definition at line 132 of file tgBulletCompressionSpring.h.
|
inlinevirtual |
Return the boolean: is the free end attached?
Definition at line 157 of file tgBulletCompressionSpring.h.
|
virtual |
Updates this object. Calls calculateAndApplyForce(dt)
[in] | dt,must | be positive |
Reimplemented in tgBulletUnidirComprSpr.
Definition at line 116 of file tgBulletCompressionSpring.cpp.
|
protected |
The first attachement point for this spring cable. Storing it seperately makes a number of functions easier
Definition at line 186 of file tgBulletCompressionSpring.h.
|
protected |
The other permanent attachment for this spring cable.
Definition at line 191 of file tgBulletCompressionSpring.h.
|
protected |
The list of contact points. tgBulletSpringCable typically has two whereas tgBulletContactSpringCable will have more. Needs to be stored here for consistent rendering. Vector has the convienence of tgCast functions, and we used to need a random iterator to sort
Definition at line 180 of file tgBulletCompressionSpring.h.
|
protected |
The damping coefficient. Units of mass / sec. Must be non-negative
Definition at line 222 of file tgBulletCompressionSpring.h.
|
protected |
The stiffness coefficient Units of mass / sec ^2 Must be positive
Definition at line 215 of file tgBulletCompressionSpring.h.
|
protected |
The force in the spring due to damping, at the last update step. Stored so we can get it without passing a dt
Definition at line 197 of file tgBulletCompressionSpring.h.
|
protected |
Boolean flag controlling the application of either tension forces or not.
Definition at line 208 of file tgBulletCompressionSpring.h.
|
protected |
The previous actual length of the spring. Used when calculating force and velocity
Definition at line 233 of file tgBulletCompressionSpring.h.
|
protected |
The rest length of the spring. Must be non negative
Definition at line 227 of file tgBulletCompressionSpring.h.
|
protected |
The velocity of the spring tip at the last update step. Stored so we can get it without passing a dt
Definition at line 203 of file tgBulletCompressionSpring.h.