Cheetah Software  1.0
BezierCurve< T, DIM, NUM_CTR_PT > Class Template Reference

#include <BezierCurve.h>

+ Collaboration diagram for BezierCurve< T, DIM, NUM_CTR_PT >:

Public Member Functions

 BezierCurve ()
 
bool SetParam (T **ctrl_pt, T fin_time)
 
bool getCurvePoint (T u, T *ret)
 
bool getCurveVelocity (T u, T *ret)
 

Public Attributes

_CtrlPt [NUM_CTR_PT][DIM]
 
_coeff [NUM_CTR_PT]
 
_end_time
 

Private Member Functions

int _factorial (const int &n)
 

Detailed Description

template<typename T, int DIM, int NUM_CTR_PT>
class BezierCurve< T, DIM, NUM_CTR_PT >

Definition at line 8 of file BezierCurve.h.

Constructor & Destructor Documentation

template<typename T, int DIM, int NUM_CTR_PT>
BezierCurve< T, DIM, NUM_CTR_PT >::BezierCurve ( )
inline

Definition at line 13 of file BezierCurve.h.

13  {
14  for (int j(0); j < NUM_CTR_PT; ++j) {
15  for (int i(0); i < DIM; ++i) {
16  _CtrlPt[j][i] = 0.;
17  }
18  _coeff[j] = 0.;
19  }
20  }
T _CtrlPt[NUM_CTR_PT][DIM]
Definition: BezierCurve.h:10
T _coeff[NUM_CTR_PT]
Definition: BezierCurve.h:11

Member Function Documentation

template<typename T, int DIM, int NUM_CTR_PT>
int BezierCurve< T, DIM, NUM_CTR_PT >::_factorial ( const int &  n)
inlineprivate

Definition at line 95 of file BezierCurve.h.

95  {
96  int ret = 1;
97  for (int i(1); i < n + 1; ++i) ret *= (i);
98 
99  return ret;
100  }

+ Here is the caller graph for this function:

template<typename T, int DIM, int NUM_CTR_PT>
bool BezierCurve< T, DIM, NUM_CTR_PT >::getCurvePoint ( u,
T *  ret 
)
inline

Definition at line 36 of file BezierCurve.h.

References BezierCurve< T, DIM, NUM_CTR_PT >::_end_time.

36  {
37  if (u > _end_time) {
38  for (int i(0); i < DIM; ++i) {
39  ret[i] = _CtrlPt[NUM_CTR_PT - 1][i];
40  }
41  return true;
42  } else if (u < 0.) {
43  for (int i(0); i < DIM; ++i) {
44  ret[i] = _CtrlPt[0][i];
45  }
46  return true;
47  } else {
48  u /= _end_time;
49  for (int i(0); i < DIM; ++i) {
50  ret[i] = 0.;
51  for (int j(0); j < NUM_CTR_PT; ++j) {
52  ret[i] += _coeff[j] * pow(u, j) * pow(1 - u, (NUM_CTR_PT - 1) - j) *
53  _CtrlPt[j][i];
54  }
55  }
56  }
57  return true;
58  }
T _CtrlPt[NUM_CTR_PT][DIM]
Definition: BezierCurve.h:10
T _coeff[NUM_CTR_PT]
Definition: BezierCurve.h:11

+ Here is the caller graph for this function:

template<typename T, int DIM, int NUM_CTR_PT>
bool BezierCurve< T, DIM, NUM_CTR_PT >::getCurveVelocity ( u,
T *  ret 
)
inline

Definition at line 60 of file BezierCurve.h.

References BezierCurve< T, DIM, NUM_CTR_PT >::_end_time.

60  {
61  if (u > _end_time) {
62  for (int i(0); i < DIM; ++i) {
63  ret[i] = 0.;
64  }
65  return true;
66  } else if (u < 0.) {
67  for (int i(0); i < DIM; ++i) {
68  ret[i] = 0.;
69  }
70  return true;
71  } else {
72  u /= _end_time;
73  for (int i(0); i < DIM; ++i) {
74  ret[i] = 0.;
75  ret[i] += _coeff[0] *
76  (-(NUM_CTR_PT - 1) * pow(1 - u, (NUM_CTR_PT - 1) - 1)) *
77  _CtrlPt[0][i];
78  for (int j(1); j < NUM_CTR_PT - 1; ++j) {
79  ret[i] += _coeff[j] *
80  (j * pow(u, j - 1) * pow(1 - u, (NUM_CTR_PT - 1) - j) -
81  (NUM_CTR_PT - 1 - j) * pow(u, j) *
82  pow(1 - u, (NUM_CTR_PT - 1) - j - 1)) *
83  _CtrlPt[j][i];
84  }
85  ret[i] += _coeff[NUM_CTR_PT - 1] * (NUM_CTR_PT - 1) *
86  pow(u, NUM_CTR_PT - 2) * _CtrlPt[NUM_CTR_PT - 1][i];
87 
88  ret[i] /= _end_time;
89  }
90  }
91  return true;
92  }
T _CtrlPt[NUM_CTR_PT][DIM]
Definition: BezierCurve.h:10
T _coeff[NUM_CTR_PT]
Definition: BezierCurve.h:11

+ Here is the caller graph for this function:

template<typename T, int DIM, int NUM_CTR_PT>
bool BezierCurve< T, DIM, NUM_CTR_PT >::SetParam ( T **  ctrl_pt,
fin_time 
)
inline

Definition at line 24 of file BezierCurve.h.

References BezierCurve< T, DIM, NUM_CTR_PT >::_factorial().

24  {
25  _end_time = fin_time;
26  T n_fact = _factorial(NUM_CTR_PT - 1);
27  for (int j(0); j < NUM_CTR_PT; ++j) {
28  for (int i(0); i < DIM; ++i) {
29  _CtrlPt[j][i] = ctrl_pt[j][i];
30  }
31  _coeff[j] = n_fact / (_factorial(j) * _factorial((NUM_CTR_PT - 1) - j));
32  }
33  return true;
34  }
T _CtrlPt[NUM_CTR_PT][DIM]
Definition: BezierCurve.h:10
T _coeff[NUM_CTR_PT]
Definition: BezierCurve.h:11
int _factorial(const int &n)
Definition: BezierCurve.h:95

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

template<typename T, int DIM, int NUM_CTR_PT>
T BezierCurve< T, DIM, NUM_CTR_PT >::_coeff[NUM_CTR_PT]

Definition at line 11 of file BezierCurve.h.

template<typename T, int DIM, int NUM_CTR_PT>
T BezierCurve< T, DIM, NUM_CTR_PT >::_CtrlPt[NUM_CTR_PT][DIM]

Definition at line 10 of file BezierCurve.h.

template<typename T, int DIM, int NUM_CTR_PT>
T BezierCurve< T, DIM, NUM_CTR_PT >::_end_time

Definition at line 12 of file BezierCurve.h.


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