GClasses
GClasses::GBezier Class Reference

Represents a Bezier curve. More...

#include <GBezier.h>

Public Member Functions

 GBezier (int nControlPoints)
 
 GBezier (GBezier *pThat)
 
 ~GBezier ()
 
void controlPoint (G3DVector *pOutPoint, double *pOutWeight, int n)
 Returns a control point. More...
 
int controlPointCount ()
 Returns the number of control points in this curve (which is always one more than the degree of the curve). More...
 
GBezier * copy ()
 
double curvatureAtZero ()
 todo: this method is not reliable–there's a bug in this method somewhere More...
 
void derivativeAtZero (G3DVector *pOutPoint)
 Returns the tangeant to the curve at t=0. More...
 
void elevateDegree ()
 Increases the degree (and number of control points) of the curve by one without changing the curve. (Only the control points are changed.) More...
 
void point (double t, G3DVector *pOutPoint)
 Returns a point on the curve. More...
 
void segment (double t, bool bTail)
 Crops the curve. If bTail is true, only the end of the curve remains. If bTail is false, only the beginning of the curve remains. More...
 
void setControlPoint (int n, G3DVector *pPoint, double weight)
 Sets a control point. More...
 
void toPolynomial (G3DVector *pOutCoefficients)
 This expects you to pass in a pointer to an array of G3DVector of size m_nControlPoints. More...
 

Static Public Member Functions

static GBezier * fromPolynomial (G3DVector *pCoefficients, int nCoefficients)
 Example: If you have the three equations: x=1+2t+3t*t, y=4+5t+6t*t, z=7+8t+9t*t then you would pass in this array of points: { (1, 4, 7), (2, 5, 8), (3, 6, 9) } to get the equivalent Bezier curve. More...
 
static void test ()
 Performs unit tests for this class. Throws an exception if there is a failure. More...
 

Protected Member Functions

struct GBezierPoint * deCasteljau (double t, bool bTail)
 

Protected Attributes

int m_nControlPoints
 
struct GBezierPoint * m_pPoints
 

Detailed Description

Represents a Bezier curve.

Constructor & Destructor Documentation

GClasses::GBezier::GBezier ( int  nControlPoints)
GClasses::GBezier::GBezier ( GBezier *  pThat)
GClasses::GBezier::~GBezier ( )

Member Function Documentation

void GClasses::GBezier::controlPoint ( G3DVector *  pOutPoint,
double *  pOutWeight,
int  n 
)

Returns a control point.

int GClasses::GBezier::controlPointCount ( )

Returns the number of control points in this curve (which is always one more than the degree of the curve).

GBezier* GClasses::GBezier::copy ( )
double GClasses::GBezier::curvatureAtZero ( )

todo: this method is not reliable–there's a bug in this method somewhere

struct GBezierPoint* GClasses::GBezier::deCasteljau ( double  t,
bool  bTail 
)
protected
void GClasses::GBezier::derivativeAtZero ( G3DVector *  pOutPoint)

Returns the tangeant to the curve at t=0.

void GClasses::GBezier::elevateDegree ( )

Increases the degree (and number of control points) of the curve by one without changing the curve. (Only the control points are changed.)

static GBezier* GClasses::GBezier::fromPolynomial ( G3DVector *  pCoefficients,
int  nCoefficients 
)
static

Example: If you have the three equations: x=1+2t+3t*t, y=4+5t+6t*t, z=7+8t+9t*t then you would pass in this array of points: { (1, 4, 7), (2, 5, 8), (3, 6, 9) } to get the equivalent Bezier curve.

void GClasses::GBezier::point ( double  t,
G3DVector *  pOutPoint 
)

Returns a point on the curve.

void GClasses::GBezier::segment ( double  t,
bool  bTail 
)

Crops the curve. If bTail is true, only the end of the curve remains. If bTail is false, only the beginning of the curve remains.

void GClasses::GBezier::setControlPoint ( int  n,
G3DVector *  pPoint,
double  weight 
)

Sets a control point.

static void GClasses::GBezier::test ( )
static

Performs unit tests for this class. Throws an exception if there is a failure.

void GClasses::GBezier::toPolynomial ( G3DVector *  pOutCoefficients)

This expects you to pass in a pointer to an array of G3DVector of size m_nControlPoints.

Member Data Documentation

int GClasses::GBezier::m_nControlPoints
protected
struct GBezierPoint* GClasses::GBezier::m_pPoints
protected