Commit b3b2cbde authored by Mike Kremer's avatar Mike Kremer
Browse files

Adapted b-spline curve class to use template scalar type instead of hard-coded double.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15969 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3150a047
...@@ -300,7 +300,7 @@ curvePoint(double _u) ...@@ -300,7 +300,7 @@ curvePoint(double _u)
template <class PointT> template <class PointT>
PointT PointT
BSplineCurveT<PointT>:: BSplineCurveT<PointT>::
derivativeCurvePoint(double _u, unsigned int _der) derivativeCurvePoint(Scalar _u, unsigned int _der)
{ {
assert(_u >= lower() && _u <= upper()); assert(_u >= lower() && _u <= upper());
...@@ -325,7 +325,7 @@ derivativeCurvePoint(double _u, unsigned int _der) ...@@ -325,7 +325,7 @@ derivativeCurvePoint(double _u, unsigned int _der)
template <class PointT> template <class PointT>
typename BSplineCurveT<PointT>::Scalar typename BSplineCurveT<PointT>::Scalar
BSplineCurveT<PointT>:: BSplineCurveT<PointT>::
basisFunction(int _i, int _n, double _t) basisFunction(int _i, int _n, Scalar _t)
{ {
int m = knotvector_.size() - 1; int m = knotvector_.size() - 1;
...@@ -343,11 +343,11 @@ basisFunction(int _i, int _n, double _t) ...@@ -343,11 +343,11 @@ basisFunction(int _i, int _n, double _t)
typename BSplineCurveT<PointT>::Scalar Nin1 = basisFunction(_i, _n-1, _t); typename BSplineCurveT<PointT>::Scalar Nin1 = basisFunction(_i, _n-1, _t);
typename BSplineCurveT<PointT>::Scalar Nin2 = basisFunction(_i+1, _n-1, _t); typename BSplineCurveT<PointT>::Scalar Nin2 = basisFunction(_i+1, _n-1, _t);
double fac1 = 0; Scalar fac1 = 0;
if ((knotvector_(_i+_n)-knotvector_(_i)) !=0 ) if ((knotvector_(_i+_n)-knotvector_(_i)) !=0 )
fac1 = (_t - knotvector_(_i)) / (knotvector_(_i+_n) - knotvector_(_i)) ; fac1 = (_t - knotvector_(_i)) / (knotvector_(_i+_n) - knotvector_(_i)) ;
double fac2 = 0; Scalar fac2 = 0;
if ( (knotvector_(_i+1+_n)-knotvector_(_i+1)) !=0 ) if ( (knotvector_(_i+1+_n)-knotvector_(_i+1)) !=0 )
fac2 = (knotvector_(_i+1+_n) - _t)/ (knotvector_(_i+1+_n) - knotvector_(_i+1)); fac2 = (knotvector_(_i+1+_n) - _t)/ (knotvector_(_i+1+_n) - knotvector_(_i+1));
...@@ -364,7 +364,7 @@ basisFunction(int _i, int _n, double _t) ...@@ -364,7 +364,7 @@ basisFunction(int _i, int _n, double _t)
template <class PointT> template <class PointT>
typename BSplineCurveT<PointT>::Scalar typename BSplineCurveT<PointT>::Scalar
BSplineCurveT<PointT>:: BSplineCurveT<PointT>::
derivativeBasisFunction(int _i, int _n, double _t, int _der) derivativeBasisFunction(int _i, int _n, Scalar _t, int _der)
{ {
if (_der == 0) if (_der == 0)
return basisFunction(_i, _n, _t); return basisFunction(_i, _n, _t);
......
...@@ -147,7 +147,7 @@ public: ...@@ -147,7 +147,7 @@ public:
* \param _der the _derm'th derivative * \param _der the _derm'th derivative
* \return the derivative * \return the derivative
*/ */
Point derivativeCurvePoint(double _u, unsigned int _der); Point derivativeCurvePoint(Scalar _u, unsigned int _der);
/** /**
* Evaluates the curve at parameter u using deBoor algorithm. * Evaluates the curve at parameter u using deBoor algorithm.
...@@ -206,7 +206,7 @@ public: ...@@ -206,7 +206,7 @@ public:
* \param _t the parameter * \param _t the parameter
* Returns N_i^p(_u) * Returns N_i^p(_u)
*/ */
Scalar basisFunction(int _i, int _n, double _t); Scalar basisFunction(int _i, int _n, Scalar _t);
/** /**
* Derivative of a Spline Basis Function * Derivative of a Spline Basis Function
...@@ -215,7 +215,7 @@ public: ...@@ -215,7 +215,7 @@ public:
* \param _t the parameter * \param _t the parameter
* \param _der the _der'th derivative * \param _der the _der'th derivative
*/ */
Scalar derivativeBasisFunction(int _i, int _n, double _t, int _der); Scalar derivativeBasisFunction(int _i, int _n, Scalar _t, int _der);
private: // private functions private: // private functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment