Core 1.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Static Protected Attributes | Friends | List of all members
Circle2 Class Reference

Circles in the plane. More...

#include <circle.h>

Inheritance diagram for Circle2:
CircleArc2 Disc2 SmoothDisc2

Public Member Functions

 Circle2 ()
 Empty.
 
 Circle2 (const double &)
 Create a circle centered at origin. More...
 
 Circle2 (const Vector2 &, const double &)
 Create a circle. More...
 
 Circle2 (const Vector2 &, const Vector2 &, const Vector2 &)
 Create the circle passing through 3 points. More...
 
 Circle2 (Vector2 *, int)
 Creates a circle enclosing a set of points. More...
 
bool Inside (const Vector2 &) const
 Check if a point is inside the circle. More...
 
bool Inside (const Circle2 &) const
 Test if a circle is entirely embedded in another one. More...
 
bool Inside (const Box2 &) const
 Test if a box is inside the circle. More...
 
bool InsideRange (const Vector2 &, const double &) const
 Check if a point is within a given range of the circle. More...
 
Vector2 Center () const
 Center of the circle.
 
Vector2 Vertex (const double &) const
 Vertex on the circle. More...
 
double Radius () const
 Radius of the circle.
 
void Extend (const Vector2 &)
 Extend the circle so that the argument point should be embedded in the new circle. More...
 
Circle2 Extended (const double &) const
 Extend the radius of the circle. More...
 
bool Intersect (const Box2 &) const
 Check intersection with a box. More...
 
bool Intersect (const Circle2 &) const
 Check if two circles intersect each other. More...
 
bool Intersect (const Ray2 &, double &, double &) const
 Check the intersection between a circle and a ray. More...
 
bool Intersect (const Ray2 &) const
 Check the intersection between a circle and a ray. More...
 
bool Intersect (const Segment2 &) const
 Check the intersection between a circle and a segment. More...
 
Vector2 Normal (const Vector2 &) const
 Compute the distance vector between a ciecle. More...
 
double R (const Vector2 &) const
 Compute the squared distance between a point and the circle. More...
 
Box2 GetBox () const
 Compute the axis aligned bounding box of a circle.
 
Circle2 Translated (const Vector &) const
 Translate a circle. More...
 
Circle2 Rotated (const Matrix2 &) const
 Rotates a circle. More...
 
void Translate (const Vector2 &)
 Translate a circle. More...
 
void Rotate (const Matrix2 &)
 Rotates a circle. More...
 
void Scale (const double &)
 Scales a circle. More...
 
double Area () const
 Area of the circle.
 
double Area (const Circle2 &) const
 Compute the area of the surface between two circles. More...
 
Vector2 RandomInside (Random &=Random::R239) const
 Generate a random vector inside the circle. More...
 
Vector2 RandomOn (Random &=Random::R239) const
 Generate a random vector on the circle. More...
 
QVector< Vector2Poisson (const double &, int, bool=false, Random &=Random::R239) const
 Compute a Poisson sphere distribution inside a circle. More...
 
QuadricCurve2 QuadricBezierArc (const double &) const
 Compute the quadratic Bézier approximation of a circle arc. More...
 
CubicCurve2 CubicBezierArc (const double &) const
 Compute the cubic Bézier approximation of a circle arc. More...
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw a circle. More...
 

Static Public Member Functions

static Vector2 RandomUnit (Random &=Random::R239)
 Compute a random vertex inside a unit disc. More...
 

Static Public Attributes

static const Circle2 Unit
 Unit circle.
 
static const Circle2 Infinite
 Infinite circle.
 

Protected Attributes

Vector2 c = Vector2::Null
 Center.
 
double r = 1.0
 Radius.
 

Static Protected Attributes

static constexpr const double Epsilon = 1.e-6
 Epslion for intersection tests
 

Friends

std::ostream & operator<< (std::ostream &, const Circle2 &)
 Overloaded. More...
 

Detailed Description

Circles in the plane.

See also
Circle

Constructor & Destructor Documentation

◆ Circle2() [1/4]

Circle2::Circle2 ( const double &  r)
explicit

Create a circle centered at origin.

Parameters
rRadius.

◆ Circle2() [2/4]

Circle2::Circle2 ( const Vector2 c,
const double &  r 
)
explicit

Create a circle.

Parameters
cCenter.
rRadius.

◆ Circle2() [3/4]

Circle2::Circle2 ( const Vector2 a,
const Vector2 b,
const Vector2 c 
)
explicit

Create the circle passing through 3 points.

This is the circumscribed circle of the triangle.

Parameters
a,b,cPoints.

◆ Circle2() [4/4]

Circle2::Circle2 ( Vector2 p,
int  n 
)
explicit

Creates a circle enclosing a set of points.

The algorithm computes a fast approximation of the bounding ball for a point set based on the algorithm given by [Jack Ritter, 1990].

Parameters
pArray of vertices.
nNumber of vertices.

Member Function Documentation

◆ Area()

double Circle2::Area ( const Circle2 circle) const

Compute the area of the surface between two circles.

If the circles do not intersect, the function returns 0; if the smallest is included in the largest, the function returns the area of the smallest, otherwise complex computations are performed.

Parameters
circleThe other circle.

◆ CubicBezierArc()

CubicCurve2 Circle2::CubicBezierArc ( const double &  t) const

Compute the cubic Bézier approximation of a circle arc.

Parameters
tAngle.

◆ Draw()

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

Draw a circle.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush, should the circle be filled.

◆ Extend()

void Circle2::Extend ( const Vector2 p)

Extend the circle so that the argument point should be embedded in the new circle.

This is the same as computing the smallest enclosing circle of a circle and a point.

Parameters
pPoint.

◆ Extended()

Circle2 Circle2::Extended ( const double &  re) const

Extend the radius of the circle.

Parameters
reRadius extension.

◆ Inside() [1/3]

bool Circle2::Inside ( const Box2 box) const

Test if a box is inside the circle.

Parameters
boxThe box.

◆ Inside() [2/3]

bool Circle2::Inside ( const Circle2 circle) const

Test if a circle is entirely embedded in another one.

Parameters
circleThe other circle.

◆ Inside() [3/3]

bool Circle2::Inside ( const Vector2 p) const

Check if a point is inside the circle.

Parameters
pPoint.

◆ InsideRange()

bool Circle2::InsideRange ( const Vector2 p,
const double &  e 
) const

Check if a point is within a given range of the circle.

Parameters
pPoint.
eRange.

◆ Intersect() [1/5]

bool Circle2::Intersect ( const Box2 box) const

Check intersection with a box.

Simply compute the distance between the center of the circle and the box and compare to radius of the circle.

See also
Box::R(const Vector&) const
Parameters
boxThe box.

◆ Intersect() [2/5]

bool Circle2::Intersect ( const Circle2 circle) const

Check if two circles intersect each other.

Parameters
circleThe other circle.

◆ Intersect() [3/5]

bool Circle2::Intersect ( const Ray2 ray) const

Check the intersection between a circle and a ray.

Parameters
rayThe (normalized) ray.

◆ Intersect() [4/5]

bool Circle2::Intersect ( const Ray2 ray,
double &  ta,
double &  tb 
) const

Check the intersection between a circle and a ray.

Note that intersections are sorted.

This function assumes that the ray is normalized, i.e. has a unit direction vector.

Parameters
rayThe (normalized) ray.
ta,tbIntersection depths.

◆ Intersect() [5/5]

bool Circle2::Intersect ( const Segment2 segment) const

Check the intersection between a circle and a segment.

Parameters
segmentThe segment.

◆ Normal()

Vector2 Circle2::Normal ( const Vector2 p) const

Compute the distance vector between a ciecle.

Parameters
pPoint.

◆ Poisson()

QVector< Vector2 > Circle2::Poisson ( const double &  ra,
int  n,
bool  border = false,
Random random = Random::R239 
) const

Compute a Poisson sphere distribution inside a circle.

This function uses a simple O(n3) dart throwing algorithm.

See also
Box::Poisson, Box2::Poisson
Parameters
rRadius of the sphere.
nNumber of candidate points.
borderTrue to sample the border
randomRandom number generator.

◆ QuadricBezierArc()

QuadricCurve2 Circle2::QuadricBezierArc ( const double &  t) const

Compute the quadratic Bézier approximation of a circle arc.

Approximation yields best results for 0 ≤ t ≤ π;/4.

Parameters
tAngle.

◆ R()

double Circle2::R ( const Vector2 p) const

Compute the squared distance between a point and the circle.

Parameters
pPoint.

◆ RandomInside()

Vector2 Circle2::RandomInside ( Random random = Random::R239) const

Generate a random vector inside the circle.

Parameters
randomRandom number generator.

◆ RandomOn()

Vector2 Circle2::RandomOn ( Random random = Random::R239) const

Generate a random vector on the circle.

Parameters
randomRandom number generator.

◆ RandomUnit()

Vector2 Circle2::RandomUnit ( Random random = Random::R239)
static

Compute a random vertex inside a unit disc.

Parameters
randomRandom number generator.

◆ Rotate()

void Circle2::Rotate ( const Matrix2 m)
inline

Rotates a circle.

Parameters
mRotation matrix.

◆ Rotated()

Circle2 Circle2::Rotated ( const Matrix2 r) const
inline

Rotates a circle.

Parameters
rRotation matrix.

◆ Scale()

void Circle2::Scale ( const double &  s)
inline

Scales a circle.

Parameters
sScaling factor.

◆ Translate()

void Circle2::Translate ( const Vector2 t)
inline

Translate a circle.

Parameters
tTranslation vector.

◆ Translated()

Circle2 Circle2::Translated ( const Vector t) const
inline

Translate a circle.

Parameters
tTranslation vector.

◆ Vertex()

Vector2 Circle2::Vertex ( const double &  a) const

Vertex on the circle.

Parameters
aAngle.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Circle2 circle 
)
friend

Overloaded.

Parameters
sStream.
circleThe circle.