Core 1.0
SphereSet Class Reference

A simple set of spheres. More...

#include <sphereset.h>

Public Member Functions

 SphereSet ()
 Empty.
 SphereSet (const Sphere &)
 Creates a sphere set given one sphere.
 SphereSet (const QVector< Sphere > &)
 Creates a set of spheres.
 SphereSet (const SphereSet &, const Sphere &)
 Creates a set of spheres and keep only the subset of spheres that intersect the second argument sphere.
 ~SphereSet ()
 Empty.
const Sphere operator[] (int i) const
 Get the i-th sphere in the set.
Sphere & operator[] (int i)
 Get the i-th sphere in the set.
void Append (const SphereSet &)
 Merge with another set of spheres.
bool Intersect (const SphereSet &) const
 Check if two sphere-sets intersect.
bool Inside (const Vector &) const
 Check if a point is inside or outside the set of sphere.
bool IsEmpty () const
 returns true if the set is empty
double R (const SphereSet &) const
 Compute the signed distance between two sphere-sets.
Box GetBox () const
 Compute the bounding box of the set of spheres.
Vector Normal (const Vector &) const
 Computes the normal vector between a point and the sphere set.
double R (const Vector &) const
 Compute the squared distance between a point and the set of spheres.
double Signed (const Vector &) const
 Compute the signed distance between a point and the set of spheres.
void Rotate (const Matrix &)
 Rotates a sphere set.
void Translate (const Vector &)
 Translates a sphere set.
void Scale (const double &)
 Uniformly scales a sphere-set.
void Transform (const Frame &)
 Transforms a sphere set given a frame transformation.
Vector Center () const
 Returns the center of mass of the sphere set.
int Size (void) const
 Returns the number of Spheres.
Sphere GetSphere (int) const
 Returns the i-th sphere.
void RemoveDuplicates (const double &)
 Removes spheres that are close to or embedded in another sphere of the set, whatever their order.

Protected Attributes

QVector< Sphere > spheres
 Set of spheres.

Detailed Description

A simple set of spheres.

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

Constructor & Destructor Documentation

◆ SphereSet() [1/3]

SphereSet::SphereSet ( const Sphere & s)
explicit

Creates a sphere set given one sphere.

Parameters
sSphere.

◆ SphereSet() [2/3]

SphereSet::SphereSet ( const QVector< Sphere > & s)
explicit

Creates a set of spheres.

Parameters
sSet.

◆ SphereSet() [3/3]

SphereSet::SphereSet ( const SphereSet & ss,
const Sphere & s )
explicit

Creates a set of spheres and keep only the subset of spheres that intersect the second argument sphere.

Parameters
ssSet.
sSphere.

Member Function Documentation

◆ Append()

void SphereSet::Append ( const SphereSet & s)

Merge with another set of spheres.

Parameters
sSphereSet.

◆ GetSphere()

Sphere SphereSet::GetSphere ( int i) const

Returns the i-th sphere.

Parameters
iIndex.

◆ Inside()

bool SphereSet::Inside ( const Vector & p) const

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

Parameters
pThe point.

◆ Intersect()

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

Check if two sphere-sets intersect.

Parameters
setSet of spheres.

◆ Normal()

Vector SphereSet::Normal ( const Vector & p) const

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

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

Parameters
pPoint.

◆ R() [1/2]

double SphereSet::R ( const SphereSet & set) const

Compute the signed distance between two sphere-sets.

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

Parameters
setSet of spheres.

◆ R() [2/2]

double SphereSet::R ( const Vector & p) const

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

Parameters
pThe point.

◆ RemoveDuplicates()

void SphereSet::RemoveDuplicates ( const double & t)

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

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

Parameters
tThreshold value.

◆ Rotate()

void SphereSet::Rotate ( const Matrix & r)

Rotates a sphere set.

Parameters
rRotation matrix.

◆ Scale()

void SphereSet::Scale ( const double & s)

Uniformly scales a sphere-set.

Parameters
sScaling factor.

◆ Signed()

double SphereSet::Signed ( const Vector & p) const

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

Parameters
pThe point.

◆ Transform()

void SphereSet::Transform ( const Frame & t)

Transforms a sphere set given a frame transformation.

Parameters
tTransformation.

◆ Translate()

void SphereSet::Translate ( const Vector & t)

Translates a sphere set.

Parameters
tTranslation vector.