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


Public Member Functions | |
| 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 Attributes | |
| 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). | |
A circle is represented by the position of its center and its radius.
| CCircle::CCircle | ( | const CCircleDesc & | r | ) |
Constructs a circle described by a circle descriptor.
| r | Circle descriptor. |

| const Vector2 CCircle::ClosestPt | ( | const Vector2 & | p | ) | const |
Find the point on the perimeter that is closest to a given point.
| p | A point. |


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

| const float CCircle::GetRadius | ( | ) | const |
Reader function for the radius.

| const bool CCircle::PtInCircle | ( | const Vector2 & | p | ) | const |
Determine whether a given point is strictly inside this circle, that is, if the point's distance to the center of this circle is strictly less that its radius.
| p | A point. |


| const bool CCircle::Tangent | ( | const CCircle * | pCirc, |
| CLineSegDesc & | t ) const |
Compute the common tangent with another circle that is counterclockwise from the vector pointing from this circle to that one.
| pCirc | Pointer to another circle. | |
| [out] | t | Line segment descriptor for common tangent. |

| const bool CCircle::Tangents | ( | const CCircle * | pCirc, |
| CLineSegDesc & | t0, | ||
| CLineSegDesc & | t1 ) const |
A line tangent to circles at centers \(p_0\) and \(p_1\) of radii \(r_0\) and \(r_1 < r_0\) is constructed by constructing the tangent to a single circle of radius \(r_0 - r_1\) centered at \(p_0\) and through \(p_1\), then translating this line segment along the radius through \(p_0\) a distance \(r_1\). See J. Casey, "A sequel to the First Six Books of the Elements of Euclid", pp. 31-32, 1888.
| pCirc | Pointer to another circle. | |
| [out] | t0 | Line segment descriptor for first common tangent. |
| [out] | t1 | Line segment descriptor for second common tangent. |

| const bool CCircle::Tangents | ( | const Vector2 & | p, |
| Vector2 & | p0, | ||
| Vector2 & | p1 ) const |
Compute the points of intersection of tangents passing through a point. Note that there are two possible tangents to a circle that pass through a given point outside the circle. If the point is inside the circle, then the tangents don't exist.
| p | Point that must lie on the tangents. | |
| [out] | p0 | Intersection point with first tangent. |
| [out] | p1 | Intersection point with second tangent. |

