UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-05-15)
usPolynomialCurve3D.h
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Author:
29  * Jason Chevrie
30  *
31  *****************************************************************************/
32 
33 #ifndef __usPolynomialCurve3D_h_
34 #define __usPolynomialCurve3D_h_
35 
36 #include <vector>
37 
38 #include <visp3/core/vpColVector.h>
39 #include <visp3/core/vpHomogeneousMatrix.h>
40 #include <visp3/core/vpMatrix.h>
41 
50 class VISP_EXPORT usPolynomialCurve3D
51 {
52 public:
57 
62 
66  const usPolynomialCurve3D &operator=(const usPolynomialCurve3D &curve);
67 
71  virtual ~usPolynomialCurve3D();
72 
78  usPolynomialCurve3D(unsigned int order);
79 
83  void setOrder(unsigned int order);
84 
88  unsigned int getOrder() const;
89 
93  void setStartParameter(double startParameter);
94 
98  double getStartParameter() const;
99 
103  void setEndParameter(double endParameter);
104 
108  double getEndParameter() const;
109 
115  void setBoundaries(double startParameter, double endParamter);
116 
120  void setParametricLength(double length);
121 
125  double getParametricLength() const;
126 
130  void setLength(double length, double precision = 1e-4);
131 
135  double getLength(int nbCountSeg = 50) const;
136 
140  void setPolynomialCoefficients(const vpMatrix &polynomialCoefficients);
141 
145  vpMatrix getPolynomialCoefficients() const;
146 
150  vpColVector getPoint(double parameter) const;
151 
155  vpMatrix getPoints(const vpColVector &parameters) const;
156 
160  vpColVector getStartPoint() const;
161 
165  vpColVector getEndPoint() const;
166 
170  vpColVector getTangent(double parameter) const;
171 
175  vpColVector getStartTangent() const;
176 
180  vpColVector getEndTangent() const;
181 
185  vpColVector getDerivative(double parameter, unsigned int order) const;
186 
195  void defineFromPoints(const std::vector<vpColVector> &points, const std::vector<double> &param,
196  unsigned int order = 0);
197 
206  void defineFromPoints(const vpMatrix points, const vpColVector &param, unsigned int order = 0);
207 
216  void defineFromPointsAuto(const std::vector<vpColVector> &points, unsigned int order = 0);
217 
226  void defineFromPointsAuto(const vpMatrix &points, unsigned int order = 0);
227 
238  void defineFromPointsAuto(const std::vector<vpColVector> &points, const vpColVector &direction,
239  unsigned int order = 0);
240 
251  void defineFromPointsAuto(const vpMatrix &points, const vpColVector &direction, unsigned int order = 0);
252 
262  void defineFromWeightedPoints(const std::vector<vpColVector> &points, const std::vector<double> &param,
263  const std::vector<double> &weights, unsigned int order = 0);
264 
274  void defineFromWeightedPoints(const vpMatrix &points, const vpColVector &param, const vpColVector &weights,
275  unsigned int order = 0);
276 
286  void defineFromWeightedPointsAuto(const std::vector<vpColVector> &points, const std::vector<double> &weights,
287  unsigned int order = 0);
288 
298  void defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector &weights, unsigned int order = 0);
299 
311  void defineFromWeightedPointsAuto(const std::vector<vpColVector> &points, const std::vector<double> &weights,
312  const vpColVector &direction, unsigned int order = 0);
313 
325  void defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector &weights, const vpColVector &direction,
326  unsigned int order = 0);
327 
333  double getCurvature(double param) const;
334 
343  double getCurvatureFromShape(double start, double end, vpColVector &center3D, vpColVector &direction3D) const;
344 
350  double getMeanAxisDeviation(int nbCountSeg = 50) const;
351 
358  void setControlPoints(const vpMatrix &controlPoints);
359 
363  void setControlPoints(double **controlPoints);
364 
368  vpMatrix getControlPoints() const;
369 
373  vpMatrix getRenderingPoints() const;
374 
378  static double curveDistance(const usPolynomialCurve3D &n1, const usPolynomialCurve3D &n2);
379 
383  usPolynomialCurve3D getSubPolynomialCurve(double startParameter, double endParameter) const;
384 
388  usPolynomialCurve3D getNewOrderPolynomialCurve(unsigned int order) const;
389 
394  void changeCoefficientsToFitBoundaries(double startParameter, double endParameter);
395 
399  void reverse();
400 
404  void changeCoefficientsToFitMetricLength();
405 
409  void move(const vpHomogeneousMatrix &H);
410 
414  void move(double x, double y, double z, double tx, double ty, double tz);
415 
419  void scale(double s);
420 
422 
424  friend VISP_EXPORT std::ostream &operator<<(std::ostream &s, const usPolynomialCurve3D &seg);
425  friend VISP_EXPORT std::istream &operator>>(std::istream &s, usPolynomialCurve3D &seg);
427  friend VISP_EXPORT std::ostream &operator<<=(std::ostream &s, const usPolynomialCurve3D &seg);
428  friend VISP_EXPORT std::istream &operator>>=(std::istream &s, usPolynomialCurve3D &seg);
429 
430 protected:
431  unsigned int m_order; // Order of the polynomial curve
432  double m_startParameter; // starting value of the parametric variable
433  double m_endParameter; // ending value of the parametric variable
434  vpMatrix m_polynomialCoefficients; // coefficients of the polynomial curve
435 };
436 
437 VISP_EXPORT std::ostream &operator<<(std::ostream &s, const usPolynomialCurve3D &seg);
438 VISP_EXPORT std::istream &operator>>(std::istream &s, usPolynomialCurve3D &seg);
439 
440 VISP_EXPORT std::ostream &operator<<=(std::ostream &s, const usPolynomialCurve3D &seg);
441 VISP_EXPORT std::istream &operator>>=(std::istream &s, usPolynomialCurve3D &seg);
442 
443 #endif // __usPolynomialCurve3D_h_