Core 1.0
CircleArc2 Class Reference

Circle arcs in the plane. More...

#include <circlearc.h>

Inheritance diagram for CircleArc2:
Circle2

Public Member Functions

 CircleArc2 ()
 Empty.
 CircleArc2 (const Vector2 &, const double &, const Vector2 &, const Vector2 &)
 Creates a circle arc.
 CircleArc2 (const Vector2 &, const Vector2 &, const Vector2 &)
 Creates a circle arc given its center and its two end points.
void Rotate (const Matrix2 &)
 Rotates the arc.
void Translate (const Vector2 &)
 Translates the arc.
void Scale (const double &)
 Uniformly scales a circle.
Box2 GetBox () const
 Compute the axis aligned bounding box of the arc.
Vector2 Normal (const Vector2 &) const
 Compute the distance vector between a circular arc and a given point.
double R (const Vector2 &) const
 Compute the squared distance between a point and the circle arc.
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw the circle arc.

Protected Member Functions

bool InSector (const Vector2 &) const
 Check if the direction of a point, seen from the center, lies in the angular sector of the arc.
Protected Member Functions inherited from Circle2
 Circle2 ()
 Empty.
 Circle2 (const double &)
 Create a circle centered at origin.
 Circle2 (const Vector2 &, const double &)
 Create a circle.
 Circle2 (const Vector2 &, const Vector2 &, const Vector2 &)
 Create the circle passing through 3 points.
 Circle2 (const QVector< Vector2 > &)
 Creates a circle enclosing a set of points.
 Circle2 (const Circle2 &, const Circle2 &)
 Create a circle embedding two circles.
bool Inside (const Vector2 &) const
 Check if a point is inside the circle.
bool Inside (const Circle2 &) const
 Test if a circle is entirely embedded in another one.
bool Inside (const Box2 &) const
 Test if a box is inside the circle.
bool InsideRange (const Vector2 &, const double &) const
 Check if a point is within a given range of the circle.
Vector2 Center () const
 Center of the circle.
Vector2 Vertex (const double &) const
 Vertex on the circle.
Vector2 Tangent (const double &) const
 Tangent to the circle.
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.
Circle2 Extended (const double &) const
 Extend the radius of the circle.
bool Intersect (const Box2 &) const
 Check intersection with a box.
bool Intersect (const Circle2 &) const
 Check if two circles intersect each other.
bool Intersect (const Circle2 &, Vector2 &, Vector2 &) const
 Check if two circles intersect each other and compute intersection points.
bool Intersect (const Ray2 &, double &, double &) const
 Check the intersection between a circle and a ray.
bool Intersect (const Ray2 &) const
 Check the intersection between a circle and a ray.
bool Intersect (const Segment2 &) const
 Check the intersection between a circle and a segment.
Vector2 Normal (const Vector2 &) const
 Compute the distance vector between a circle and a point.
double R (const Vector2 &) const
 Compute the squared distance between a point and the circle.
Box2 GetBox () const
 Compute the axis aligned bounding box of a circle.
Circle2 Translated (const Vector2 &) const
 Translate a circle.
Circle2 Rotated (const Matrix2 &) const
 Rotates a circle.
Circle2 Transformed (const Frame2 &) const
 Return a circle transformed by a frame.
Circle2 Scaled (const double &) const
 Return a uniformly scaled circle.
void Translate (const Vector2 &)
 Translate a circle.
void Rotate (const Matrix2 &)
 Rotates a circle.
void Scale (const double &)
 Scales a circle.
double Area () const
 Area of the circle.
double Length () const
 Perimeter of the circle.
double Area (const Circle2 &) const
 Compute the area of the surface between two circles.
Vector2 RandomInside (Random &=Random::R239) const
 Generate a random vector inside the circle.
Vector2 RandomOn (Random &=Random::R239) const
 Generate a random vector on the circle.
Vector2 Vogel (int, int) const
 Generate a spiraling point in the disc.
QVector< Vector2 > Poisson (const double &, int, bool=false, Random &=Random::R239) const
 Compute a Poisson disc distribution inside a circle.
QVector< Vector2 > PoissonNorder (const double &, int, Random &=Random::R239) const
 Compute a Poisson disc distribution on the boundary of a circle.
QVector< Vector2 > Border (const double &, Random &=Random::R239) const
 Compute a Poisson disc distribution on the boundary of the circle.
QuadricCurve2 QuadricBezierArc (const double &) const
 Compute the quadratic B�zier approximation of a circle arc.
QuadricCurve2 QuadricBezierArc (const double &, const double &) const
 Compute the quadratic B�zier approximation of a circle arc.
CubicCurve2 CubicBezierArc (const double &) const
 Compute the cubic B�zier approximation of a circle arc.
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw a circle.

Protected Attributes

Vector2 b = Vector2(Math::InvSqrt2, Math::InvSqrt2)
 End points of arc.
Protected Attributes inherited from Circle2
Vector2 c = Vector2::Null
 Center.
double r = 1.0
 Radius.

Additional Inherited Members

Static Protected Member Functions inherited from Circle2
static Vector2 RandomUnit (Random &=Random::R239)
 Compute a random vertex inside a unit disc.
Static Protected Attributes inherited from Circle2
static constexpr const double Epsilon = 1.e-6
 Epslion for intersection tests
static const Circle2 Unit
 Unit circle.
static const Circle2 Infinite
 Infinite circle.

Detailed Description

Circle arcs in the plane.

Constructor & Destructor Documentation

◆ CircleArc2() [1/2]

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

Creates a circle arc.

Parameters
cCenter.
rRadius.
a,bEnd points, should be in trigonometric order (counter-clockwise).

◆ CircleArc2() [2/2]

CircleArc2::CircleArc2 ( const Vector2 & c,
const Vector2 & a,
const Vector2 & b )
explicit

Creates a circle arc given its center and its two end points.

The radius is the distance between the center and the first end point.

Parameters
cCenter.
a,bEnd points of the arc, which should lie on the same circle (the radius is the norm of a-c), in trigonometric order (counter-clockwise).

Member Function Documentation

◆ Draw()

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

Draw the circle arc.

The arc is approximated by line segments, with an π/64 angle accuracy.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ GetBox()

Box2 CircleArc2::GetBox ( ) const

Compute the axis aligned bounding box of the arc.

This function analyzes 16 different configurations.

◆ InSector()

bool CircleArc2::InSector ( const Vector2 & p) const
protected

Check if the direction of a point, seen from the center, lies in the angular sector of the arc.

The sector is swept counter-clockwise from the first end point to the second one, and may be larger than \( \pi \). The test only uses cross products. If the sweep angle of the arc is at most \( \pi \), the point should lie on the left of the first end point and on the right of the second one; otherwise it is enough to satisfy one of the two conditions.

Parameters
pPoint.

◆ Normal()

Vector2 CircleArc2::Normal ( const Vector2 & p) const

Compute the distance vector between a circular arc and a given point.

The vector goes from the closest point of the arc to the point. In the angular sector of the arc, the closest point is on the circle, otherwise it is the closest end point of the arc.

Parameters
pPoint.

◆ R()

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

Compute the squared distance between a point and the circle arc.

In the angular sector of the arc, the distance is the one to the circle, otherwise it is the distance to the closest end point of the arc.

Parameters
pPoint.

◆ Rotate()

void CircleArc2::Rotate ( const Matrix2 & m)

Rotates the arc.

Parameters
mRotation matrix.

◆ Scale()

void CircleArc2::Scale ( const double & s)

Uniformly scales a circle.

Parameters
sScaling factor.

◆ Translate()

void CircleArc2::Translate ( const Vector2 & t)

Translates the arc.

Parameters
tTranslation vector.