Fawkes API  Fawkes Development Version
fawkes::Spline Class Reference

A spline made up of cubic Bezier curves. More...

#include <>>

Inheritance diagram for fawkes::Spline:

List of all members.

Public Member Functions

 Spline ()
 Constructor.
 Spline (const std::vector< HomPoint > &control_points)
 Constructor.
virtual ~Spline ()
 Destructor.
void set_control_points (const std::vector< HomPoint > &control_points)
 Set the control points.
void set_control_point (unsigned int i, const HomPoint &p)
 Set a specific control point.
const std::vector< HomPoint > & get_control_points () const
 Get the control points.
const std::vector< Bezier > & get_bezier_curves () const
 Get the Bezier curves.
HomPoint eval (unsigned int bezier_index, float t)
 Get a point on the curve for a specified segment and value t.
HomVector tangent (unsigned int bezier_index, float t)
 Compute the tangent vector at position t of the i-th Bezier curve.
HomVector tangent (unsigned int point_index)
 Compute the tangent vector at the specified approximation point.
std::vector< HomPointapproximate (unsigned int num_subdivisions=4)
 Get linear approximation of the curve.

Protected Member Functions

virtual void register_primitives ()
 Here, a derived class should register its primitives (HomPoints and HomVectors) by calling add_primitive for each of those.
virtual void post_transform ()
 This method is called after the primitives are transformed.

Friends

class fawkes::SplineDrawer

Detailed Description

A spline made up of cubic Bezier curves.

Author:
Daniel Beck

Constructor & Destructor Documentation

fawkes::Spline::Spline ( )

Constructor.

Definition at line 38 of file spline.cpp.

fawkes::Spline::Spline ( const std::vector< HomPoint > &  control_points)

Constructor.

Parameters:
control_pointsthe control points of the spline

Definition at line 46 of file spline.cpp.

References register_primitives().

fawkes::Spline::~Spline ( ) [virtual]

Destructor.

Definition at line 56 of file spline.cpp.


Member Function Documentation

vector< HomPoint > fawkes::Spline::approximate ( unsigned int  num_subdivisions = 4)

Get linear approximation of the curve.

Instead of evaluating the Bezier polynoms at constant intervals the Bezier curves are subdivided and the control points are taken as an approximation. This is more efficient and yields better results. The control points converge to the curve quadratically in the number of subdivisions.

Parameters:
num_subdivisionsthe number of subdivision that shall be performed.
Returns:
points approximating the curve

Definition at line 161 of file spline.cpp.

HomPoint fawkes::Spline::eval ( unsigned int  bezier_index,
float  t 
)

Get a point on the curve for a specified segment and value t.

Parameters:
bezier_indexthe index of the curve
ta value between 0.0 and 1.0
Returns:
a point on the i-th curve for the parameter t

Definition at line 111 of file spline.cpp.

const vector< Bezier > & fawkes::Spline::get_bezier_curves ( ) const

Get the Bezier curves.

Returns:
const reference to the current Bezier curves

Definition at line 100 of file spline.cpp.

const vector< HomPoint > & fawkes::Spline::get_control_points ( ) const

Get the control points.

Returns:
const reference to the current control points

Definition at line 91 of file spline.cpp.

void fawkes::Spline::post_transform ( ) [protected, virtual]

This method is called after the primitives are transformed.

Any additional updates that need to be done should be done here.

Implements fawkes::Transformable.

Definition at line 204 of file spline.cpp.

void fawkes::Spline::register_primitives ( ) [protected, virtual]

Here, a derived class should register its primitives (HomPoints and HomVectors) by calling add_primitive for each of those.

Implements fawkes::Transformable.

Definition at line 191 of file spline.cpp.

References fawkes::Transformable::add_primitive().

Referenced by Spline(), set_control_points(), and set_control_point().

void fawkes::Spline::set_control_point ( unsigned int  i,
const HomPoint point 
)

Set a specific control point.

Parameters:
ithe index of the control point
pointthe replacement control point

Definition at line 78 of file spline.cpp.

References fawkes::Transformable::clear_primitives(), and register_primitives().

void fawkes::Spline::set_control_points ( const std::vector< HomPoint > &  control_points)

Set the control points.

Parameters:
control_pointsthe new control points

Definition at line 64 of file spline.cpp.

References fawkes::Transformable::clear_primitives(), and register_primitives().

HomVector fawkes::Spline::tangent ( unsigned int  bezier_index,
float  t 
)

Compute the tangent vector at position t of the i-th Bezier curve.

Parameters:
bezier_indexthe index of the Bezier patch
tthe curve parameter t
Returns:
the tangent vector

Definition at line 122 of file spline.cpp.

HomVector fawkes::Spline::tangent ( unsigned int  point_index)

Compute the tangent vector at the specified approximation point.

The range of the index is determined by number of subidivisions that have been performed during the last approximation.

Parameters:
point_indexindex of the approximation point
Returns:
tangent vector

Definition at line 134 of file spline.cpp.


The documentation for this class was generated from the following files: