Core 1.0
|
Circles in the plane. More...
#include <circle.h>
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< Vector2 > | Poisson (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... | |
Circles in the plane.
|
explicit |
Create a circle centered at origin.
r | Radius. |
|
explicit |
Create a circle.
c | Center. |
r | Radius. |
Create the circle passing through 3 points.
This is the circumscribed circle of the triangle.
a,b,c | Points. |
|
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].
p | Array of vertices. |
n | Number of vertices. |
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.
circle | The other circle. |
CubicCurve2 Circle2::CubicBezierArc | ( | const double & | t | ) | const |
Compute the cubic Bézier approximation of a circle arc.
t | Angle. |
void Circle2::Draw | ( | QGraphicsScene & | scene, |
const QPen & | pen = QPen() , |
||
const QBrush & | brush = QBrush() |
||
) | const |
Draw a circle.
scene | Graphics scene. |
pen | The pen. |
brush | The brush, should the circle be filled. |
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.
p | Point. |
Circle2 Circle2::Extended | ( | const double & | re | ) | const |
Extend the radius of the circle.
re | Radius extension. |
bool Circle2::Inside | ( | const Box2 & | box | ) | const |
Test if a box is inside the circle.
box | The box. |
bool Circle2::Inside | ( | const Circle2 & | circle | ) | const |
Test if a circle is entirely embedded in another one.
circle | The other circle. |
bool Circle2::Inside | ( | const Vector2 & | p | ) | const |
Check if a point is inside the circle.
p | Point. |
bool Circle2::InsideRange | ( | const Vector2 & | p, |
const double & | e | ||
) | const |
Check if a point is within a given range of the circle.
p | Point. |
e | Range. |
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.
box | The box. |
bool Circle2::Intersect | ( | const Circle2 & | circle | ) | const |
Check if two circles intersect each other.
circle | The other circle. |
bool Circle2::Intersect | ( | const Ray2 & | ray | ) | const |
Check the intersection between a circle and a ray.
ray | The (normalized) ray. |
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.
ray | The (normalized) ray. |
ta,tb | Intersection depths. |
bool Circle2::Intersect | ( | const Segment2 & | segment | ) | const |
Check the intersection between a circle and a segment.
segment | The segment. |
Compute the distance vector between a ciecle.
p | Point. |
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.
r | Radius of the sphere. |
n | Number of candidate points. |
border | True to sample the border |
random | Random number generator. |
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.
t | Angle. |
double Circle2::R | ( | const Vector2 & | p | ) | const |
Compute the squared distance between a point and the circle.
p | Point. |
Vector2 Circle2::RandomInside | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector inside the circle.
random | Random number generator. |
Vector2 Circle2::RandomOn | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector on the circle.
random | Random number generator. |
|
static |
Compute a random vertex inside a unit disc.
random | Random number generator. |
|
inline |
Rotates a circle.
m | Rotation matrix. |
Rotates a circle.
r | Rotation matrix. |
|
inline |
Scales a circle.
s | Scaling factor. |
|
inline |
Translate a circle.
t | Translation vector. |
Translate a circle.
t | Translation vector. |
Vector2 Circle2::Vertex | ( | const double & | a | ) | const |
Vertex on the circle.
a | Angle. |
|
friend |
Overloaded.
s | Stream. |
circle | The circle. |