Core 1.0
BezierCurve2 Class Reference

Bézier curves. More...

#include <bezier.h>

Public Member Functions

 BezierCurve2 ()
 Empty.
 BezierCurve2 (const QVector< Vector2 > &)
 Create a Bézier curve.
 ~BezierCurve2 ()
 Empty.
int Degree () const
 Return the degree of the curve.
Vector2 Vertex (int) const
 Return the control point.
Vector2 Point (const double &) const
 Compute a point on the curve.
Vector2 Tangent (const double &) const
 Compute the tangent at a given point on the curve.
Vector2 Second (const double &) const
 Compute the secondary derivative a given point on the curve.
Vector2 DeCasteljau (const double &) const
 Compute a point on the curve using De Casteljau's algorithm.
Box2 GetBox () const
 Return the bounding box.
PointCurve2 GetPolyLine () const
 Return the poly-line.
Polygon2 GetPolygon () const
 Return the polygon.
void Rotate (const Matrix2 &)
 Rotates the curve.
void Translate (const Vector2 &)
 Translation.
void Scale (const Vector2 &)
 Scale.
void Transform (const Frame2 &)
 Transforms the curve.
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw the curve.

Protected Attributes

QVector< Vector2 > c
 Control points.

Detailed Description

Bézier curves.

Constructor & Destructor Documentation

◆ BezierCurve2()

BezierCurve2::BezierCurve2 ( const QVector< Vector2 > & c)
explicit

Create a Bézier curve.

Parameters
cSet of control points.

Member Function Documentation

◆ DeCasteljau()

Vector2 BezierCurve2::DeCasteljau ( const double & u) const

Compute a point on the curve using De Casteljau's algorithm.

Parameters
uCoordinates.

◆ Draw()

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

Draw the curve.

Parameters
sceneGraphics scene.
penPen.
brushBrush.

◆ Point()

Vector2 BezierCurve2::Point ( const double & u) const

Compute a point on the curve.

Parameters
uCoordinates.

◆ Rotate()

void BezierCurve2::Rotate ( const Matrix2 & r)

Rotates the curve.

Parameters
rRotation matrix.

◆ Scale()

void BezierCurve2::Scale ( const Vector2 & s)

Scale.

Parameters
sScaling vector.

◆ Second()

Vector2 BezierCurve2::Second ( const double & u) const

Compute the secondary derivative a given point on the curve.

The second derivative of a curve of degree n is a curve of degree n-2:

\[ c''(u) = n(n-1) \sum_{i=0}^{n-2} (p_{i+2} - 2 p_{i+1} + p_i) B_i^{n-2}(u) \]

where \( B_i^{n-2} \) are the Bernstein polynomials of degree n-2, computed by Math::BernsteinSeries() with n-1 terms.

Parameters
uCoordinates.

◆ Tangent()

Vector2 BezierCurve2::Tangent ( const double & u) const

Compute the tangent at a given point on the curve.

Parameters
uCoordinates.

◆ Transform()

void BezierCurve2::Transform ( const Frame2 & frame)

Transforms the curve.

Parameters
frameTransformation.

◆ Translate()

void BezierCurve2::Translate ( const Vector2 & t)

Translation.

Parameters
tTranslation vector.

◆ Vertex()

Vector2 BezierCurve2::Vertex ( int i) const
inline

Return the control point.

Parameters
iIndex.