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


Public Member Functions | |
| CArc (CArcDesc &) | |
| Constructor. | |
| const bool | CollisionDetected (CContactDesc &) const |
| Collision detection. | |
| const bool | PtInSector (const Vector2 &) const |
| Point in sector test. | |
| void | GetEndPts (Vector2 &, Vector2 &) const |
| Get end points. | |
| void | GetTangents (Vector2 &, Vector2 &) const |
| Get tangents. | |
Public Member Functions inherited from Shapes::CCircle | |
| CCircle (const CCircleDesc &) | |
| Constructor. | |
| const bool | CollisionDetected (CContactDesc &) const |
| Collision detection. | |
| const bool | PtInCircle (const Vector2 &) const |
| Point in circle test. | |
| const Vector2 | ClosestPt (const Vector2 &) const |
| Closest point on circle. | |
| const bool | Tangents (const Vector2 &, Vector2 &, Vector2 &) const |
| Tangents through external point. | |
| const bool | Tangents (const CCircle *, CLineSegDesc &, CLineSegDesc &) const |
| Common tangents. | |
| const bool | Tangent (const CCircle *, CLineSegDesc &) const |
| Common tangent. | |
| const float | GetRadius () const |
| Get radius. | |
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 from angles and radius. | |
| const float | PtToAngle (const Vector2 &) const |
| Point to angle. | |
Protected Attributes | |
| Vector2 | m_vPt0 |
| Point 0. | |
| Vector2 | m_vPt1 |
| Point 1. | |
| float | m_fAngle0 |
| Angle from center to point 0. | |
| float | m_fAngle1 |
| Angle from center to point 1. | |
| Vector2 | m_vTangent0 |
| Tangent at point 0. | |
| Vector2 | m_vTangent1 |
| Tangent at point 1. | |
Protected Attributes inherited from Shapes::CCircle | |
| float | m_fRadius = 0.0f |
| Radius. | |
| float | m_fRadiusSq = 0.0f |
| Radius squared, for fast distance calc. | |
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). | |
An arc represents a portion of the circumference of a circle bounded by a pair of angles. If the first angle is smaller than the second angle, then the arc extends from the first angle to the second angle in a counterclockwise direction. If the first angle is greater than the second angle, then the arc extends from the first angle to the second angle in a clockwise direction. If the first angle is the same as the second angle, then you are an idiot.
| CArc::CArc | ( | CArcDesc & | r | ) |
Constructs an arc described by an arc descriptor.
| r | Arc descriptor. |

|
virtual |
Collision detection with a dynamic circle.
| c | [in, out] Contact descriptor for this collision. |
Reimplemented from Shapes::CShape.

| void CArc::GetEndPts | ( | Vector2 & | p0, |
| Vector2 & | p1 ) const |
Reader function for the end points.
| p0 | [out] First end point. |
| p1 | [out] Second end point. |
| void CArc::GetTangents | ( | Vector2 & | v0, |
| Vector2 & | v1 ) const |
Reader function for the tangents. Tangents are returned in the same order as GetEndPoints().
| v0 | [out] Tangent at fist end point. |
| v1 | [out] Tangent at second end point. |
| const bool CArc::PtInSector | ( | const Vector2 & | p | ) | const |
Draw imaginary lines from the center of this arc (meaning the center of the circle containing it) to its end points and continue them on infinitely. A point is said to be inside the sector if it is between those two lines.
| p | A point. |


|
protected |
Given a point \(p\), compute a vector from the center of the arc to \(p\) and return the angle from the positive \(X\)-axis to that vector.
| p | A 2D point. |


|
protected |
Update the arc properties from its center, radius, and angles. The end points, tangents, and AABB are recomputed.

