Core 1.0
QuinticCurve2 Class Reference

Quintic curves in the plane. More...

#include <curve.h>

Public Member Functions

 QuinticCurve2 ()
 Empty.
 QuinticCurve2 (const Quintic &, const Quintic &)
 Creates a quintic curve.
 ~QuinticCurve2 ()
 Empty.
Quintic & operator[] (int)
Quintic operator[] (int) const
QuinticCurve2 operator- () const
 Negative curve unary operator.
Vector2 Tangent (const double &) const
 Computes the tangent to the quintic curve at a given position on the curve.
Vector2 Normal (const double &) const
 Computes the normal vector to the quintic curve at a given position on the curve.
double Length (int=256) const
 Computes the length of the quintic curve. Integration is performed over interval [0,1].
double Length (const double &, const double &, int=256) const
 Computes the length of the quintic curve over interval [a,b].
Vector2 operator() (const double &) const
 Evaluates curve point at a given location.
Vector2 Eval (const double &) const
 Evaluates curve point at a given location.
double Curvature (const double &) const
 Computes the signed curvature of the curve at a given point.
Box2 GetBox () const
 Compute the bounding box of the quintic curve with parameter interval [0,1].
Matrix2 GetMatrix (const double &) const
 Compute the Frenet vectors (tangent and normal) at a given point on the curve.
Frame2 GetFrame (const double &) const
 Compute the frame at a given point on the curve.
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw a quintic curve.
Vector2 BezierControl (int) const
 Compute the i-th Bezier control point of the curve.

Static Public Member Functions

static QuinticCurve2 Hermite (const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &)
 Creates an Hermite quintic curve on interval [0,1] given vertex locations and tangent vectors (in that order).
static QuinticCurve2 Hermite (const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &, const double &, const double &)
 Creates an Hermite quintic curve on interval [0,1] given vertex locations, tangent vectors and curvature radii.
static QuinticCurve2 Bezier (const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &)
 Creates a Bezier quintic curve on interval [0,1] given six control points.

Static Public Attributes

static const QuinticCurve2 Null
 Null curve.

Protected Attributes

Quintic y
 Quintic polynomial functions for every coordinate.

Friends

std::ostream & operator<< (std::ostream &s, const QuinticCurve2 &curve)
 Overloaded.

Detailed Description

Quintic curves in the plane.

Constructor & Destructor Documentation

◆ QuinticCurve2()

QuinticCurve2::QuinticCurve2 ( const Quintic & x,
const Quintic & y )
explicit

Creates a quintic curve.

Parameters
x,yQuintic parametric equations of the corresponding x, y coordinates.

Member Function Documentation

◆ Bezier()

QuinticCurve2 QuinticCurve2::Bezier ( const Vector2 & a,
const Vector2 & b,
const Vector2 & c,
const Vector2 & d,
const Vector2 & e,
const Vector2 & f )
static

Creates a Bezier quintic curve on interval [0,1] given six control points.

Parameters
a,b,c,d,e,fControl points of the Bezier curve.

◆ BezierControl()

Vector2 QuinticCurve2::BezierControl ( int i) const

Compute the i-th Bezier control point of the curve.

Computations have been optimized.

Parameters
iIndex.

◆ Curvature()

double QuinticCurve2::Curvature ( const double & t) const

Computes the signed curvature of the curve at a given point.

Parameters
tParameter.

◆ Draw()

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

Draw a quintic curve.

The brush is not used.

Parameters
sceneGraphics scene.
penThe pen.

◆ Eval()

Vector2 QuinticCurve2::Eval ( const double & t) const

Evaluates curve point at a given location.

Parameters
tParameter.

◆ GetFrame()

Frame2 QuinticCurve2::GetFrame ( const double & u) const

Compute the frame at a given point on the curve.

Parameters
uParameter.

◆ GetMatrix()

Matrix2 QuinticCurve2::GetMatrix ( const double & u) const

Compute the Frenet vectors (tangent and normal) at a given point on the curve.

Parameters
uParameter.

◆ Hermite() [1/2]

QuinticCurve2 QuinticCurve2::Hermite ( const Vector2 & a,
const Vector2 & b,
const Vector2 & ta,
const Vector2 & tb,
const double & ra,
const double & rb )
static

Creates an Hermite quintic curve on interval [0,1] given vertex locations, tangent vectors and curvature radii.

Parameters
a,bEnd vertices of the Hermite quintic curve.
ta,tbTangent vectors at the end vertices.
ra,rbSigned curvature radii at the end vertices.
Warning
ra and rb must be non-zero. A zero radius (inflection point with infinite curvature) causes a division by zero. Callers are responsible for ensuring this precondition is met.

◆ Hermite() [2/2]

QuinticCurve2 QuinticCurve2::Hermite ( const Vector2 & a,
const Vector2 & b,
const Vector2 & ta,
const Vector2 & tb,
const Vector2 & aa,
const Vector2 & ab )
static

Creates an Hermite quintic curve on interval [0,1] given vertex locations and tangent vectors (in that order).

Parameters
a,bEnd vertices of the Hermite quintic curve.
ta,tbTangent vectors at the end vertices.
aa,abAcceleration vectors at the end vertices.

◆ Length() [1/2]

double QuinticCurve2::Length ( const double & a,
const double & b,
int n = 256 ) const

Computes the length of the quintic curve over interval [a,b].

Since we have the parametric equations of the coordinates of the points on the curve, then the length is the integral of the square root of the sum of the squared derivatives where the limits of integration are [a,b].

In the general case, the function we end up with is not integrable in closed form, leading to an elliptic integral or some such. Thus we evaluate the integral numerically.

Parameters
a,bInterval.
nDiscretization of the integration interval.

◆ Length() [2/2]

double QuinticCurve2::Length ( int n = 256) const

Computes the length of the quintic curve. Integration is performed over interval [0,1].

Simply call QuinticCurve2::Length(0.0,1.0,n) with n as the passed argument parameter.

Parameters
nDiscretization of the curve.

◆ Normal()

Vector2 QuinticCurve2::Normal ( const double & t) const

Computes the normal vector to the quintic curve at a given position on the curve.

The normal is the obtained by evaluating the second derivative.

Parameters
tPosition.

◆ operator()()

Vector2 QuinticCurve2::operator() ( const double & t) const

Evaluates curve point at a given location.

Parameters
tParameter.

◆ operator[]() [1/2]

Quintic & QuinticCurve2::operator[] ( int i)
inline

Access curve components (0 = x, 1 = y).

Warning
Any index other than 0 silently returns the y component; no bounds check is performed.

◆ operator[]() [2/2]

Quintic QuinticCurve2::operator[] ( int i) const
inline

Access curve components (0 = x, 1 = y).

Warning
Any index other than 0 silently returns the y component; no bounds check is performed.

◆ Tangent()

Vector2 QuinticCurve2::Tangent ( const double & t) const

Computes the tangent to the quintic curve at a given position on the curve.

The tangent is the obtained by evaluating the first derivative.

Parameters
tPosition.

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const QuinticCurve2 & curve )
friend

Overloaded.

Parameters
sStream.
curveThe quintic curve.