Fawkes API  Fawkes Development Version
fawkes::Spline Class Reference

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

#include <>>

Inheritance diagram for fawkes::Spline:

Public Member Functions

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

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. More...
 
virtual void post_transform ()
 This method is called after the primitives are transformed. More...
 
- Protected Member Functions inherited from fawkes::Transformable
void transform (const HomTransform &t)
 Apply the transform to all registered primitives and call the post_transform() method. More...
 
void add_primitive (HomCoord *c)
 Add a primitive to the list of primitives that is transformed. More...
 
void clear_primitives ()
 Clear the list of primitives. More...
 

Friends

class fawkes::SplineDrawer
 

Detailed Description

A spline made up of cubic Bezier curves.

Author
Daniel Beck

Definition at line 36 of file spline.h.

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 ( )
protectedvirtual

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 ( )
protectedvirtual

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 set_control_point(), set_control_points(), and Spline().

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: