Core 1.0
Capsule2 Class Reference

A line-swept-cricle. More...

#include <capsule.h>

Inheritance diagram for Capsule2:
Axis2

Public Member Functions

 Capsule2 ()
 Empty.
 
 Capsule2 (const Vector2 &, const Vector2 &, const double &)
 Creates a capsule.
 
 ~Capsule2 ()
 Empty.
 
bool Inside (const Vector2 &) const
 Check if a point is inside the capsule.
 
double R (const Vector2 &) const
 Computes the squared distance between a point and the capsule.
 
double Signed (const Vector2 &) const
 Computes the signed distance between a point and the capsule.
 
bool Intersect (const Ray2 &) const
 Check the intersection between a capsule and a ray.
 
int Intersect (const Ray2 &, double &, double &) const
 Compute the intersections between a capsule and a ray.
 
Box2 GetBox () const
 Computes the tight bounding box of the capsule.
 
double Area () const
 Compute the surface area.
 
void Draw (QGraphicsScene &, const QPen &, const QBrush &) const
 Draws a capsule.
 
Vector2 Vertex (int) const
 Return one of the end vertexes of the axis.
 

Protected Member Functions

OrientedBox2 GetOrientedBox () const
 Compute the bounding oriented box.
 
- Protected Member Functions inherited from Axis2
double Radial (const Vector2 &, Vector2 &, Vector2 &) const
 Compute the radial coordinates of a point.
 
Vector2 Radial (const Vector2 &) const
 Compute the radial coordinates of a point.
 
 Axis2 ()
 Empty.
 
 Axis2 (const Vector2 &, const Vector2 &)
 Creates an axis given end vertices.
 
 ~Axis2 ()
 Empty.
 
Vector2 Vertex (int) const
 Return one of the end vertexes of the axis.
 
Vector2 Point (const double &) const
 Compute a point on the axis.
 
Vector2 GetAxis () const
 Returns the normalized axis vector.
 
constexpr double Length () const
 Return the axis length.
 
void Translate (const Vector2 &)
 Translation.
 
void Rotate (const Matrix2 &)
 Rotation.
 
void Scale (const double &)
 Scaling.
 
Vector2 Symmetric (const Vector2 &) const
 Symmetric point.
 
Circle2 Symmetric (const Circle2 &) const
 Symmetric circle.
 
Box2 Symmetric (const Box2 &) const
 Symmetric box.
 

Protected Attributes

double r = 1.0
 Radius.
 
- Protected Attributes inherited from Axis2
Vector2 b = Vector2(1.0, 0.0)
 End vertexes of the axis.
 
Vector2 axis = Vector2::X
 Normalized axis vector.
 
double length = 1.0
 Length of the axis.
 

Friends

std::ostream & operator<< (std::ostream &s, const Capsule2 &c)
 Overloaded.
 

Detailed Description

A line-swept-cricle.

Constructor & Destructor Documentation

◆ Capsule2()

Capsule2::Capsule2 ( const Vector2 & a,
const Vector2 & b,
const double & r )
explicit

Creates a capsule.

Parameters
a,bVertexes
rRadius.

Member Function Documentation

◆ Draw()

void Capsule2::Draw ( QGraphicsScene & scene,
const QPen & pen,
const QBrush & brush ) const

Draws a capsule.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ GetBox()

Box2 Capsule2::GetBox ( ) const

Computes the tight bounding box of the capsule.

See also
Circle::GetBox()

◆ Inside()

bool Capsule2::Inside ( const Vector2 & p) const

Check if a point is inside the capsule.

Parameters
pPoint.

◆ Intersect() [1/2]

bool Capsule2::Intersect ( const Ray2 & ray) const

Check the intersection between a capsule and a ray.

Parameters
rayThe normalized ray.

◆ Intersect() [2/2]

int Capsule2::Intersect ( const Ray2 & ray,
double & ta,
double & tb ) const

Compute the intersections between a capsule and a ray.

Parameters
rayThe ray.
ta,tbIntersection depths.

◆ R()

double Capsule2::R ( const Vector2 & p) const

Computes the squared distance between a point and the capsule.

Parameters
pPoint.

◆ Signed()

double Capsule2::Signed ( const Vector2 & p) const

Computes the signed distance between a point and the capsule.

Parameters
pPoint.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const Capsule2 & c )
friend

Overloaded.

Parameters
sStream.
cCapsule.