Core 1.0
Sector2 Class Reference

Intersection between a cone and a circle in the plane. More...

#include <sector.h>

Public Member Functions

 Sector2 ()
 Empty.
 Sector2 (const double &, const double &=Math::HalfPi)
 Creates a sector.
 Sector2 (const Vector2 &, const Vector2 &, const double &, const double &=Math::HalfPi)
 Creates a sector.
 ~Sector2 ()
 Empty.
double Signed (const Vector2 &) const
 Compute the signed Euclidean distance between a point and a sector.
bool Inside (const Vector2 &) const
 Check if a point is inside the sector.
void Rotate (const Matrix2 &)
 Rotates a sector.
void Translate (const Vector2 &)
 Translates a sector.
void Scale (const double &)
 Uniformly scales a sector.
Box2 GetBox () const
 Compute the axis aligned bounding box.
OrientedBox2 GetOrientedBox () const
 Compute the oriented bounding box.
void Draw (QGraphicsScene &, const QPen &, const QBrush &) const
 Draw the sector.

Protected Member Functions

Vector2 Vertex (const double &) const
 Compute the position of a point on the circular part of the sector.
Vector2 Vertex (int) const
 Return the vertexes at the end of the circle part.

Protected Attributes

Vector2 c = Vector2::Null
 Center.
double a = Math::Pi / 4.0
 Angle.
Vector2 sc = Vector2(Math::InvSqrt2, Math::InvSqrt2)
 Sine and cosine of the sector angle.
Vector2 axis = Vector::X
 Axis.
double r = 1.0
 Radius.

Friends

std::ostream & operator<< (std::ostream &s, const Sector2 &sector)
 Overloaded.

Detailed Description

Intersection between a cone and a circle in the plane.

Constructor & Destructor Documentation

◆ Sector2() [1/2]

Sector2::Sector2 ( const double & r,
const double & a = Math::HalfPi )
explicit

Creates a sector.

Parameters
rRadius.
aAngle.

◆ Sector2() [2/2]

Sector2::Sector2 ( const Vector2 & c,
const Vector2 & axis,
const double & r,
const double & a = Math::HalfPi )
explicit

Creates a sector.

Parameters
cCenter.
axisAxis, which should be normalized.
rRadius.
aAngle.

Member Function Documentation

◆ Draw()

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

Draw the sector.

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

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ GetOrientedBox()

OrientedBox2 Sector2::GetOrientedBox ( ) const

Compute the oriented bounding box.

The box is aligned with the axis of the sector. When the half-angle exceeds pi/2, the box extends behind the center down to the arc extremity at r cos(a), and its half-width is the radius.

◆ Inside()

bool Sector2::Inside ( const Vector2 & p) const
inline

Check if a point is inside the sector.

The point should be inside the disc, and its angle with the axis should not exceed the angle of the sector.

Parameters
pPoint.

◆ Rotate()

void Sector2::Rotate ( const Matrix2 & r)

Rotates a sector.

Parameters
rRotation matrix.

◆ Scale()

void Sector2::Scale ( const double & s)

Uniformly scales a sector.

Parameters
sScaling factor.

◆ Signed()

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

Compute the signed Euclidean distance between a point and a sector.

Parameters
pPoint.

◆ Translate()

void Sector2::Translate ( const Vector2 & t)

Translates a sector.

Parameters
tTranslation vector.

◆ Vertex() [1/2]

Vector2 Sector2::Vertex ( const double & u) const
protected

Compute the position of a point on the circular part of the sector.

Parameters
uShould be in [0,1].

◆ Vertex() [2/2]

Vector2 Sector2::Vertex ( int i) const
protected

Return the vertexes at the end of the circle part.

Note that the following calls yield the same result.

Vector2 a=s.Vertex(0); // Integer function avoids (precomputed) trigonometrics
Vector2 b=s.Vertex(0.0);
double a
Angle.
Definition sector.h:43
Vector2 Vertex(const double &) const
Compute the position of a point on the circular part of the sector.
Definition sector2.cpp:125
Sector2()
Empty.
Definition sector.h:49
Vectors in two dimensions.
Definition evector.h:632
Parameters
iIndex, should be in {0,1}.

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const Sector2 & sector )
friend

Overloaded.

Parameters
sStream.
sectorThe sector.