![]() |
The Shapes Library
Game Physics with Bespoke Code
|
Line segment shape. More...
#include <LineSeg.h>


Public Member Functions | |
| CLineSeg (CLineSegDesc &) | |
| Constructor. | |
| const bool | CollisionDetected (CContactDesc &) const |
| Collision detection. | |
| void | GetEndPts (Vector2 &, Vector2 &) const |
| Get end points. | |
| void | GetTangents (Vector2 &, Vector2 &) const |
| Get tangents. | |
| const Vector2 & | GetNormal () const |
| Get normal. | |
Public Member Functions inherited from Shapes::CLine | |
| CLine (const Vector2 &, float) | |
| Constructor. | |
Public Member Functions inherited from Shapes::CShape | |
| CShape (const CShapeDesc &) | |
| Constructor. | |
| virtual | ~CShape () |
| Destructor. | |
| const eShape | GetShapeType () const |
| Get shape type. | |
| const eMotion | GetMotionType () const |
| Get motion type. | |
| const CAabb2D & | GetAABB () const |
| Get AABB. | |
| const bool | GetSensor () const |
| Is this shape a sensor? | |
| const Vector2 & | GetPos () const |
| Get position. | |
| void | SetPos (const Vector2 &) |
| Set position. | |
| void | SetAABBPoint (const Vector2 &) |
| Set AABB point. | |
| void | AddAABBPoint (const Vector2 &) |
| Add AABB point. | |
| void | SetCanCollide (bool=true) |
| Turn collisions on or off. | |
| const bool | GetCanCollide () const |
| Get whether shape can collide. | |
| const bool | GetRotating () const |
| Get whether rotating. | |
| void | SetRotating (bool) |
| Start or stop rotating. | |
| const float | GetOrientation () const |
| Get orientation. | |
| void | SetOrientation (float) |
| Set orientation. | |
| const float | GetRotSpeed () const |
| Get rotation speed. | |
| void | SetRotSpeed (float) |
| Set rotation speed. | |
| const Vector2 & | GetRotCenter () const |
| Get rotation speed. | |
| void | SetRotCenter (const Vector2 &) |
| Set center of rotation. | |
| const float | GetElasticity () const |
| Get elasticity. | |
| void * | GetUserPtr () const |
| Get user pointer. | |
| void | SetUserPtr (void *) |
| Set user pointer. | |
| virtual void | Rotate (const Vector2 &, float) |
| Rotate. | |
| virtual void | Reset () |
| Reset orientation. | |
| virtual void | move () |
| Translate. | |
Protected Member Functions | |
| void | Update () |
| Update other properties from the end points. | |
Protected Member Functions inherited from Shapes::CLine | |
| const Vector2 | Intersect (const CLine &) const |
| Get intersection point with line. | |
| const Vector2 | ClosestPt (const Vector2 &) const |
| Get closest point on line. | |
Protected Attributes | |
| Vector2 | m_vPt0 |
| Point at end of line segment. | |
| Vector2 | m_vPt1 |
| Point at other end of line segment. | |
| Vector2 | m_vTangent0 |
| Tangent at point 0. | |
| Vector2 | m_vTangent1 |
| Tangent at point 1. | |
| Vector2 | m_vNormal |
| Normal to line segment. | |
Protected Attributes inherited from Shapes::CLine | |
| float | m_fGradient = 0.0f |
| Gradient. | |
| float | m_fInverseGradient = 0.0f |
| Inverse gradient. | |
| float | m_fYIntercept = 0.0f |
| Intercept with Y axis. | |
| float | m_fXIntercept = 0.0f |
| Intercept with X axis. | |
Protected Attributes inherited from Shapes::CShape | |
| eShape | m_eShapeType = eShape::Unknown |
| Type of shape. | |
| eMotion | m_eMotionType = eMotion::Static |
| How shape moves. | |
| float | m_fElasticity = 1.0f |
| Elasticity, aka restitution, bounciness. | |
| bool | m_bIsSensor = false |
| Sensor only, no rebound on collision. | |
| CAabb2D | m_cAABB |
| Axially aligned bounding box in World Space. | |
| bool | m_bCanCollide = true |
| Can collide with other shapes. | |
| float | m_fOrientation = 0.0f |
| Orientation angle. | |
| void * | m_pUser |
| Spare pointer for user in case they might need one. | |
| Vector2 | m_vRotCenter |
| Center of rotation. | |
| float | m_fRotSpeed = 0.0f |
| Rotation speed. | |
| bool | m_bRotating = false |
| Whether rotating. | |
Additional Inherited Members | |
Static Protected Attributes inherited from Shapes::CShapeCommon | |
| static float | m_fGravity = 0.0f |
| Gravitational constant. | |
| static float | m_fTimeStep = 0.0f |
| Time step per animation frame (fictional). | |
A line segment is the portion of a line drawn from one point to another, that is, it is finite in both directions.
| CLineSeg::CLineSeg | ( | CLineSegDesc & | r | ) |
Constructs a line segment described by a line segment descriptor.
| r | Line segment descriptor. |

|
virtual |
Collision detection with a dynamic circle. This function kluges out by using the closest point on this circle to the center of the other circle as the POI, and then letting CPoint do the rest of the work.
| c | [in, out] Contact descriptor for this collision. |
Reimplemented from Shapes::CShape.

| void CLineSeg::GetEndPts | ( | Vector2 & | p0, |
| Vector2 & | p1 ) const |
Reader function for the end points of the line segment.
| p0 | [out] One end. |
| p1 | [out] The other end. |
| const Vector2 & CLineSeg::GetNormal | ( | ) | const |
Reader function for the normal.
| void CLineSeg::GetTangents | ( | Vector2 & | v0, |
| Vector2 & | v1 ) const |
Reader function for the tangents at the end points of the line segment. These will be in the same order as the parameters of function GetEndPoints, that is, v0 will be the tangent at p0 and v1 will be the tangent at p1.
| v0 | [out] One tangent. |
| v1 | [out] The other tangent. |
|
protected |
Update the line segment properties from its position and end points. The tangents and AABB are recomputed along with line properties such as the gradient.

