The Shapes Library
Game Physics with Bespoke Code
Loading...
Searching...
No Matches
Shapes::CLineSegDesc Class Reference

Line segment descriptor. More...

#include <LineSeg.h>

Inheritance diagram for Shapes::CLineSegDesc:
Collaboration diagram for Shapes::CLineSegDesc:

Public Member Functions

 CLineSegDesc ()
 Constructor.
 
 CLineSegDesc (const Vector2 &, const Vector2 &, float=1.0f)
 Constructor.
 
void SetEndPts (const Vector2 &, const Vector2 &)
 
void GetEndPts (Vector2 &, Vector2 &) const
 Set end points.
 
const Vector2 & GetEndPt0 () const
 Get end point 0.
 
const Vector2 & GetEndPt1 () const
 Get end point 1.
 
const Vector2 & GetNormal () const
 Get normal.
 
const float GetGradient () const
 Get gradient.
 
- Public Member Functions inherited from Shapes::CShapeDesc
 CShapeDesc (eShape)
 Constructor.
 
 CShapeDesc ()
 Default constructor.
 

Protected Attributes

Vector2 m_vPt0
 Point 0.
 
Vector2 m_vPt1
 Point 1.
 
Vector2 m_vNormal
 Normal.
 
float m_fGradient = 0.0f
 Gradient.
 

Additional Inherited Members

- Public Attributes inherited from Shapes::CShapeDesc
eShape m_eShapeType = eShape::Unknown
 Type of shape.
 
Vector2 m_vPos
 Position.
 
float m_fElasticity = 1.0f
 Elasticity, aka restitution, bounciness.
 
eMotion m_eMotionType = eMotion::Static
 How shape moves.
 
bool m_bIsSensor = false
 Sensor only, no rebound.
 

Detailed Description

The line segment descriptor describes a line segment.

Constructor & Destructor Documentation

◆ CLineSegDesc() [1/2]

CLineSegDesc::CLineSegDesc ( )

The default contructor creates a line segment descriptor whose end points are the origin.

◆ CLineSegDesc() [2/2]

CLineSegDesc::CLineSegDesc ( const Vector2 & p0,
const Vector2 & p1,
float e = 1.0f )

This constructor creates a line segment descriptor given the line segment's end points and elasticity.

Parameters
p0End point.
p1End point.
eElasticity, defaults to 1.0f.
Here is the call graph for this function:

Member Function Documentation

◆ GetEndPt0()

const Vector2 & CLineSegDesc::GetEndPt0 ( ) const

Reader function for end point 0.

Returns
End point 0.

◆ GetEndPt1()

const Vector2 & CLineSegDesc::GetEndPt1 ( ) const

< Reader function for end point 1.

Returns
End point 1.

◆ GetEndPts()

void CLineSegDesc::GetEndPts ( Vector2 & p0,
Vector2 & p1 ) const

Get end points.

Reader function for the positions of the end points.

Parameters
p0[out] Leftmost end point.
p1[out] Other end point.

◆ GetGradient()

const float CLineSegDesc::GetGradient ( ) const

Reader function for the gradient.

Returns
Gradient.

◆ GetNormal()

const Vector2 & CLineSegDesc::GetNormal ( ) const

< Reader function for normal.

Returns
Normal.

◆ SetEndPts()

void CLineSegDesc::SetEndPts ( const Vector2 & p0,
const Vector2 & p1 )

Set the end points of this line segment descriptor, ensuring that the first point is to the left of the second point so that the gradient is computed correctly. Also computes the normal vector (which will be counterclockwise from the vector that points from the first and point to the second one in the order in which they are given as parameters.

Parameters
p0First end point.
p1Second end point.
Here is the call graph for this function:
Here is the caller graph for this function: