Core 1.0
Public Member Functions | Protected Attributes | List of all members
CubicCurve2Set Class Reference

Piecewise cubic curves in the plane. More...

#include <curveset.h>

Public Member Functions

 CubicCurve2Set ()
 Creates an empty piecewise quadric curve.
 
 CubicCurve2Set (const QVector< CubicCurve2 > &)
 Creates the piecewise quadric curve given a set of CubicCurve2. More...
 
 CubicCurve2Set (const QVector< Vector2 > &, const Vector2 &=Vector2::Null, const Vector2 &=Vector2::Null)
 Creates the piecewise cubic curve given a set of control points with the Cattmul-Rom construction. More...
 
 CubicCurve2Set (const CubicCurveSet &)
 Creates a piecewise cubic curve in the plane from a similar curve. More...
 
 ~CubicCurve2Set ()
 Empty.
 
int Size () const
 Return the number of elements of the piecewise cubic curve.
 
CubicCurve2 operator() (int) const
 Return the i-th sub-curve. More...
 
QVector< Vector2GetDiscretisation (const double &) const
 Generates a discretization of the piecewise cubic curve with a linear curvilign absisca parameterization. More...
 
QVector< Vector2GetDiscretisation (const double &, QVector< Vector2 > &) const
 Generates a discretization of the curve with a linear curvilign absisca parameterization. More...
 
Box2 GetBox () const
 Compute the bounding box of the curve.
 
double GetLength () const
 Return the length of the curve.
 
double GetLength (int) const
 Return the length of the sub-curve. More...
 
double Sinuosity () const
 Compute the sinuosity. More...
 
bool Inside (const Vector2 &) const
 Check if a point lies inside the piecewise cubic curve closed contour. More...
 
int U (const double &, double &) const
 Compute the parameter of the curve corresponding to the input length. More...
 
double R (const Vector2 &, double &, int &) const
 Compute the squared distance between a point and a set of cubic curves. More...
 
double Signed (const Vector2 &) const
 Compute the signed distance between a point and a set of cubic curves forming a closed path. More...
 
int Intersect (const Ray2 &ray, int i, double t[3]) const
 Compute the intersection between the set of curves and a ray. More...
 
void UV (const Vector2 &, double &, double &, int &) const
 Compute the inverse mapping for a given input point. More...
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw the curve. More...
 

Protected Attributes

QVector< CubicCurve2curve
 Set of 2D cubic curves.
 
QVector< double > lengths
 Length of every curve.
 
double length = 0.0
 Total length.
 

Detailed Description

Piecewise cubic curves in the plane.

The length of every curve CubicCurve2Set::lengths and the total length CubicCurve2Set::length are computed to speed up computations (internal optimization).

Constructor & Destructor Documentation

◆ CubicCurve2Set() [1/3]

CubicCurve2Set::CubicCurve2Set ( const QVector< CubicCurve2 > &  control)
explicit

Creates the piecewise quadric curve given a set of CubicCurve2.

Parameters
controlSet of cubic curves.

◆ CubicCurve2Set() [2/3]

CubicCurve2Set::CubicCurve2Set ( const QVector< Vector2 > &  control,
const Vector2 ta = Vector2::Null,
const Vector2 tb = Vector2::Null 
)
explicit

Creates the piecewise cubic curve given a set of control points with the Cattmul-Rom construction.

Parameters
controlSet of 2D points.
taStarting tangent vector.
tbEnding tangent vector.

◆ CubicCurve2Set() [3/3]

CubicCurve2Set::CubicCurve2Set ( const CubicCurveSet c)
explicit

Creates a piecewise cubic curve in the plane from a similar curve.

Parameters
cCurve.

Member Function Documentation

◆ Draw()

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

Draw the curve.

The brush is not used.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ GetDiscretisation() [1/2]

QVector< Vector2 > CubicCurve2Set::GetDiscretisation ( const double &  step) const

Generates a discretization of the piecewise cubic curve with a linear curvilign absisca parameterization.

Parameters
stepStepping distance.

◆ GetDiscretisation() [2/2]

QVector< Vector2 > CubicCurve2Set::GetDiscretisation ( const double &  step,
QVector< Vector2 > &  tangents 
) const

Generates a discretization of the curve with a linear curvilign absisca parameterization.

Parameters
stepStepping distance.
tangentsTangents to the curve at sample points.

◆ GetLength()

double CubicCurve2Set::GetLength ( int  k) const
inline

Return the length of the sub-curve.

Parameters
kCurve index.

◆ Inside()

bool CubicCurve2Set::Inside ( const Vector2 p) const

Check if a point lies inside the piecewise cubic curve closed contour.

The curve should be closed.

Parameters
pPoint.

◆ Intersect()

int CubicCurve2Set::Intersect ( const Ray2 ray,
int  i,
double  t[3] 
) const

Compute the intersection between the set of curves and a ray.

Parameters
rayThe ray.
tIntersection depths.

◆ operator()()

CubicCurve2 CubicCurve2Set::operator() ( int  i) const
inline

Return the i-th sub-curve.

Parameters
iIndex.

◆ R()

double CubicCurve2Set::R ( const Vector2 p,
double &  u,
int &  k 
) const

Compute the squared distance between a point and a set of cubic curves.

See also
CubicCurve::R()
Parameters
pPoint.
uParameter defining the coordinate of the projection of the argument vertex onto the curve.
kIndex of the curve for which the minimum distance was found.

◆ Signed()

double CubicCurve2Set::Signed ( const Vector2 p) const

Compute the signed distance between a point and a set of cubic curves forming a closed path.

See also
CubicCurve2Set::R()
Parameters
pPoint.

◆ Sinuosity()

double CubicCurve2Set::Sinuosity ( ) const

Compute the sinuosity.

Sinusoity is defined as the ratio between the length of the curve and the distance between end points.

◆ U()

int CubicCurve2Set::U ( const double &  s,
double &  u 
) const

Compute the parameter of the curve corresponding to the input length.

Parameters
sInput length.
uParameter of the i-th curve.
Returns
Identifier of the curve in the piecewise definition.

◆ UV()

void CubicCurve2Set::UV ( const Vector2 p,
double &  u,
double &  v,
int &  k 
) const

Compute the inverse mapping for a given input point.

Parameters
pPoint.
u,vInverse Coordinates, u will denote the position along the curve and v the signed distance to the curve.
kIndex of the curve for which the minimum distance was found.