Colliding Shapes
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Protected Attributes | List of all members
CLineSegDesc Class Reference

Line segment descriptor. More...

#include <LineSeg.h>

Inheritance diagram for CLineSegDesc:
CShapeDesc

Public Member Functions

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

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 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.

Member Function Documentation

◆ GetEndPt0()

const Vector2 & CLineSegDesc::GetEndPt0 ( )

< Reader function for end point 0.

Returns
End point 0.

◆ GetEndPt1()

const Vector2 & CLineSegDesc::GetEndPt1 ( )

< Reader function for end point 1.

Returns
End point 1.

◆ GetEndPts()

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

Get end points.

Reader function for the positions of the end points.

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

◆ GetGradient()

float CLineSegDesc::GetGradient ( )

Reader function for the gradient.

Returns
Gradient.

◆ GetNormal()

const Vector2 & CLineSegDesc::GetNormal ( )

< 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.