Core 1.0
DiscSet2 Class Reference

A simple set of discs. More...

#include <discset.h>

Public Member Functions

 DiscSet2 ()
 Empty.
 DiscSet2 (const Disc2 &)
 Creates a disc set given one disc.
 DiscSet2 (const QVector< Disc2 > &)
 Creates a set of discs.
 DiscSet2 (const DiscSet2 &, const Disc2 &)
 Creates a set of discs and keep only the subset of discs that intersect the second argument disc.
 ~DiscSet2 ()
 Empty.
void Append (const DiscSet2 &)
 Merge with another set of discs.
bool Intersect (const DiscSet2 &) const
 Check if two disc sets intersect.
bool Inside (const Vector2 &) const
 Check if a point is inside or outside the set of discs.
bool IsEmpty () const
 returns true if the set is empty
double Signed (const DiscSet2 &) const
 Compute the signed distance between two disc sets.
Box2 GetBox () const
 Compute the bounding box of the set of discs.
Vector2 Normal (const Vector2 &) const
 Computes the normal vector between a point and the disc set.
double R (const Vector2 &) const
 Compute the squared distance between a point and the set of discs.
double Signed (const Vector2 &) const
 Compute the signed distance between a point and the set of discs.
void Rotate (const Matrix2 &)
 Rotates a disc set.
void Translate (const Vector2 &)
 Translates a disc set.
void Scale (const double &)
 Uniformly scales a disc set.
void Transform (const Frame2 &)
 Transforms a disc set given a frame transformation.
int Size (void) const
 Returns the number of discs.
Disc2 GetDisc (int) const
 Returns a disc by index.
void RemoveDuplicates (const double &)
 Removes discs that are close to or embedded in another disc of the set, whatever their order.
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw the set of discs.

Protected Attributes

QVector< Disc2 > discs
 Set of discs.

Detailed Description

A simple set of discs.

This class implements functions to compute the distance between a point and a set of discs, or the detect whether two set of discs intersect.

Constructor & Destructor Documentation

◆ DiscSet2() [1/3]

DiscSet2::DiscSet2 ( const Disc2 & s)
explicit

Creates a disc set given one disc.

Parameters
sDisc2.

◆ DiscSet2() [2/3]

DiscSet2::DiscSet2 ( const QVector< Disc2 > & s)
explicit

Creates a set of discs.

Parameters
sSet.

◆ DiscSet2() [3/3]

DiscSet2::DiscSet2 ( const DiscSet2 & ss,
const Disc2 & s )
explicit

Creates a set of discs and keep only the subset of discs that intersect the second argument disc.

Parameters
ssSet.
sDisc2.

Member Function Documentation

◆ Append()

void DiscSet2::Append ( const DiscSet2 & s)

Merge with another set of discs.

Parameters
sDiscSet2.

◆ Draw()

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

Draw the set of discs.

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

◆ GetDisc()

Disc2 DiscSet2::GetDisc ( int i) const

Returns a disc by index.

Parameters
iIndex of the disc, which should be in [0,Size()[.
Returns
The i-th disc of the set.

◆ Inside()

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

Check if a point is inside or outside the set of discs.

Parameters
pThe point.

◆ Intersect()

bool DiscSet2::Intersect ( const DiscSet2 & set) const

Check if two disc sets intersect.

Parameters
setSet of discs.

◆ Normal()

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

Computes the normal vector between a point and the disc set.

Simply project point onto the nearest disc, and return the corresponding Euclidean distance vector.

Parameters
pPoint.

◆ R()

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

Compute the squared distance between a point and the set of discs.

Parameters
pThe point.

◆ RemoveDuplicates()

void DiscSet2::RemoveDuplicates ( const double & t)

Removes discs that are close to or embedded in another disc of the set, whatever their order.

Among discs that are closer than the threshold, the last one is kept.

Parameters
tThreshold value.

◆ Rotate()

void DiscSet2::Rotate ( const Matrix2 & r)

Rotates a disc set.

Parameters
rRotation matrix.

◆ Scale()

void DiscSet2::Scale ( const double & s)

Uniformly scales a disc set.

Parameters
sScaling factor.

◆ Signed() [1/2]

double DiscSet2::Signed ( const DiscSet2 & set) const

Compute the signed distance between two disc sets.

If two discs intersect, the result will be negative. If one of the set is empty, returns 0.0.

Note that, unlike DiscSet2::R(const Vector2&) const, the result is a distance and not a squared distance.

Parameters
setSet of discs.
Returns
The smallest signed distance between a disc of the set and a disc of the argument set.

◆ Signed() [2/2]

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

Compute the signed distance between a point and the set of discs.

Parameters
pThe point.

◆ Transform()

void DiscSet2::Transform ( const Frame2 & t)

Transforms a disc set given a frame transformation.

Parameters
tTransformation.

◆ Translate()

void DiscSet2::Translate ( const Vector2 & t)

Translates a disc set.

Parameters
tTranslation vector.