9#ifndef model_SplineSegment_H_
10#define model_SplineSegment_H_
72 template <
short unsigned int _dim,
short unsigned int corder>
76 static_assert(_dim>=1 && _dim <=3,
"DIMENSION MUST BE 1, 2 or 3.");
77 static_assert(corder>=0 && corder <=2,
"CONTINUITY ORDER MUST BE 0, 1 or 2.");
82 static constexpr int dim= _dim;
83 static constexpr int Ncoeff= 2*(corder+1);
84 static constexpr int pOrder= 2*corder+1;
110 double _chordLength2;
127 ,_chordLength2(_chord.squaredNorm())
128 ,_chordLength(sqrt(_chordLength2))
129 ,_unitDirection(_chordLength>FLT_EPSILON? (_chord/_chordLength).
eval() :
VectorDim::Zero())
139 _chordLength2=_chord.squaredNorm();
140 _chordLength=sqrt(_chordLength2);
141 _unitDirection=_chordLength>FLT_EPSILON? (_chord/_chordLength).
eval() : VectorDim::Zero();
147 return SplineSegmentBaseType::hermiteDofs(*
this);
151 std::pair<Eigen::Matrix<double,Ncoeff,Eigen::Dynamic>,Eigen::Matrix<double,Eigen::Dynamic,dim>>
hermite2posMatrix()
const
153 return SplineSegmentBaseType::hermite2posMatrix(*
this);
159 return SplineSegmentBaseType::hermite2posMap(*
this);
165 return SplineSegmentBaseType::hermiteCoefficients(*
this);
215 return _chordLength2;
222 return _unitDirection;
295 Eigen::Matrix<double,
dim,
Ncoeff-1> dcoeffs(Eigen::Matrix<double,dim,Ncoeff-1>::Zero());
298 dcoeffs.col(
i)=(
i+1)*coeffs.col(
i+1);
301 Eigen::Matrix<double,1,2*
Ncoeff-2> pcoeffs(Eigen::Matrix<double,1,2*Ncoeff-2>::Zero());
308 pcoeffs(2*
Ncoeff-3-
i-
j) += coeffs.col(
i).dot(dcoeffs.col(
j));
316 std::map<double,std::pair<double,VectorDim>> rootMap;
319 for (
size_t k=0;
k<mc.rootSize;++
k)
321 if (std::fabs(mc.root(
k).imag())<FLT_EPSILON && mc.root(
k).real()>0.0 && mc.root(
k).real()<1.0 )
325 rootMap.insert(std::make_pair((P-P0).norm(), std::make_pair(mc.root(
k).real(),P) ));
332 rootMap.insert(std::make_pair((
sourceP-P0).norm(), std::make_pair(0.0,
sourceP)));
333 rootMap.insert(std::make_pair((
sinkP-P0).norm(), std::make_pair(1.0,
sinkP)));
335 return *rootMap.begin();
343 template <
short unsigned int dim,
short unsigned int corder>
Class template that performs the transformation between the polynomial coefficient matrix and the He...
Class template that computes tangent, curvature and torsion of a parametric curve in arbitrary dimen...
std::pair< Eigen::Matrix< double, Ncoeff, Eigen::Dynamic >, Eigen::Matrix< double, Eigen::Dynamic, dim > > hermite2posMatrix() const
MatrixNcoeff sfCoeffs() const
Eigen::Matrix< double, 1, Ncoeff-2 > RowNcoeffuu
Eigen::Matrix< double, 1, Ncoeff > RowNcoeff
Eigen::Matrix< double, dim, dim > MatrixDim
std::pair< double, std::pair< double, VectorDim > > closestPoint(const VectorDim &P0) const
Eigen::Matrix< double, dim, Ncoeff > hermiteCoefficients() const
Eigen::Matrix< double, Ndof, Ndof > MatrixNdof
SplineSegmentBaseType::H2PmapType hermite2posMap() const
const VectorDim & unitDirection() const
Eigen::Matrix< double, Ncoeff, dim > MatrixNcoeffDim
ParametricCurve< SplineSegment< _dim, corder >, dim > ParametricCurveType
VectorDim get_ruu(const double &uin) const
SplineSegmentBase< dim, corder > SplineSegmentBaseType
const double & chordLengthSquared() const
Eigen::Matrix< double, dim, Ndof > MatrixDimNdof
Eigen::Matrix< double, dim, Ncoeff > polynomialCoeff() const
VectorDim get_rmu(const double &uin) const
Eigen::Matrix< double, 1, Ncoeff-1 > RowNcoeffu
static constexpr int eigenSize
MatrixNcoeffDim hermiteDofs() const
static constexpr int pOrder
double parametricChordLength() const
const VectorDim & chord() const
VectorDim get_ru(const double &uin) const
Eigen::Matrix< double, Ncoeff, 1 > VectorNcoeff
const double & chordLength() const
Eigen::Matrix< double, Ncoeff, Ncoeff > MatrixNcoeff
Eigen::Matrix< double, dim, 1 > VectorDim
static constexpr int Ndof
VectorDim get_rmumu(const double &uin) const
RowNcoeff sf(const double &u) const
Eigen::Matrix< double, Ndof, 1 > VectorNdof
VectorDim get_r(const double &u) const
const VectorDim & sourceP
SplineSegment(const VectorDim &sourceP_in, const VectorDim &sinkP_in)
static constexpr int Ncoeff
auto eval(const std::shared_ptr< T > &t)