Ball and Spring Toy
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Private Attributes | List of all members
CSpring Class Reference

The spring. More...

#include <Spring.h>

Inheritance diagram for CSpring:
CCommon

Public Member Functions

 CSpring (eSprite, CPoint *, CPoint *, float)
 Constructor.
 
void draw ()
 Draw. More...
 
void Relax ()
 Gauss-Seidel relaxation. More...
 

Private Attributes

eSprite m_eSpriteType = eSprite::Size
 Sprite type.
 
CPointm_pV0
 Point at one end.
 
CPointm_pV1
 Point at the other end.
 
float m_fRestLength = 0
 Rest length.
 
float m_fRestitution = 0
 Springiness, between 0.0f and 1.0f.
 
float m_fAngle = 0
 Orientation.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 
static eBody m_eCurrentBody = (eBody)0
 Current body type.
 

Detailed Description

The spring class is the representation of an abstract spring or stick. It has flags that let you choose not to draw it and whether it should be drawn as a spring or a stick. The latter should be set according to the spring's restitution but at this level the two concepts can be independent of one another.

Member Function Documentation

◆ draw()

void CSpring::draw ( )

Draw the spring and the points at its ends.

◆ Relax()

void CSpring::Relax ( )

Perform a single iteration of Gauss-Seidel relaxation.