UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
usPolynomialCurve2D.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  * Authors:
29  * Pierre Chatelain
30  * Alexandre Krupa
31  * Jason Chevrie
32  *
33  *****************************************************************************/
34 
35 #ifndef __usPolynomialCurve2D_h_
36 #define __usPolynomialCurve2D_h_
37 
38 #include <vector>
39 
40 #include <visp3/core/vpColVector.h>
41 #include <visp3/core/vpMatrix.h>
42 
51 class VISP_EXPORT usPolynomialCurve2D
52 {
53 public:
58 
63 
67  const usPolynomialCurve2D &operator=(const usPolynomialCurve2D &curve);
68 
72  virtual ~usPolynomialCurve2D();
73 
79  usPolynomialCurve2D(unsigned int order);
80 
84  void setOrder(unsigned int order);
85 
89  unsigned int getOrder() const;
90 
94  void setStartParameter(double startParameter);
95 
99  double getStartParameter() const;
100 
104  void setEndParameter(double endParameter);
105 
109  double getEndParameter() const;
110 
116  void setBoundaries(double startParameter, double endParamter);
117 
121  void setParametricLength(double length);
122 
126  double getParametricLength() const;
127 
131  void setLength(double length, double precision = 1e-4);
132 
136  double getLength(int nbCountSeg = 50) const;
137 
141  void setPolynomialCoefficients(const vpMatrix &polynomialCoefficients);
142 
146  vpMatrix getPolynomialCoefficients() const;
147 
151  vpColVector getPoint(double parameter) const;
152 
156  vpMatrix getPoints(vpColVector parameters) const;
157 
161  vpColVector getStartPoint() const;
162 
166  vpColVector getEndPoint() const;
167 
171  vpColVector getTangent(double parameter) const;
172 
176  vpColVector getStartTangent() const;
177 
181  vpColVector getEndTangent() const;
182 
186  vpColVector getDerivative(double parameter, unsigned int order) const;
187 
196  void defineFromPoints(const std::vector<vpColVector> &points, const std::vector<double> &param,
197  unsigned int order = 0);
198 
207  void defineFromPoints(const vpMatrix points, const vpColVector &param, unsigned int order = 0);
208 
217  void defineFromPointsAuto(const std::vector<vpColVector> &points, unsigned int order = 0);
218 
227  void defineFromPointsAuto(const vpMatrix &points, unsigned int order = 0);
228 
239  void defineFromPointsAuto(const std::vector<vpColVector> &points, const vpColVector &direction,
240  unsigned int order = 0);
241 
252  void defineFromPointsAuto(const vpMatrix &points, const vpColVector &direction, unsigned int order = 0);
253 
263  void defineFromWeightedPoints(const std::vector<vpColVector> &points, const std::vector<double> &param,
264  const std::vector<double> &weights, unsigned int order = 0);
265 
275  void defineFromWeightedPoints(const vpMatrix &points, const vpColVector &param, const vpColVector &weights,
276  unsigned int order = 0);
277 
287  void defineFromWeightedPointsAuto(const std::vector<vpColVector> &points, const std::vector<double> &weights,
288  unsigned int order = 0);
289 
299  void defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector &weights, unsigned int order = 0);
300 
312  void defineFromWeightedPointsAuto(const std::vector<vpColVector> &points, const std::vector<double> &weights,
313  const vpColVector &direction, unsigned int order = 0);
314 
326  void defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector &weights, const vpColVector &direction,
327  unsigned int order = 0);
328 
334  double getCurvature(double param) const;
335 
341  double getMeanAxisDeviation(int nbCountSeg = 50) const;
342 
349  void setControlPoints(const vpMatrix &controlPoints);
350 
354  void setControlPoints(double **controlPoints);
355 
359  vpMatrix getControlPoints() const;
360 
364  vpMatrix getRenderingPoints() const;
365 
369  static double curveDistance(const usPolynomialCurve2D &n1, const usPolynomialCurve2D &n2);
370 
374  usPolynomialCurve2D getSubPolynomialCurve(double startParameter, double endParameter) const;
375 
379  usPolynomialCurve2D getNewOrderPolynomialCurve(unsigned int order) const;
380 
385  void changeCoefficientsToFitBoundaries(double startParameter, double endParameter);
386 
390  void reverse();
391 
395  void changeCoefficientsToFitMetricLength();
396 
400  void move(double x, double y, double tz);
401 
405  void scale(double s);
406 
408 
410  friend VISP_EXPORT std::ostream &operator<<(std::ostream &s, const usPolynomialCurve2D &seg);
411  friend VISP_EXPORT std::istream &operator>>(std::istream &s, usPolynomialCurve2D &seg);
413  friend VISP_EXPORT std::ostream &operator<<=(std::ostream &s, const usPolynomialCurve2D &seg);
414  friend VISP_EXPORT std::istream &operator>>=(std::istream &s, usPolynomialCurve2D &seg);
415 
416 protected:
417  unsigned int m_order; // Order of the polynomial curve
418  double m_startParameter; // starting value of the parametric variable
419  double m_endParameter; // ending value of the parametric variable
420  vpMatrix m_polynomialCoefficients; // coefficients of the polynomial curve
421 };
422 
423 VISP_EXPORT std::ostream &operator<<(std::ostream &s, const usPolynomialCurve2D &seg);
424 VISP_EXPORT std::istream &operator>>(std::istream &s, usPolynomialCurve2D &seg);
425 
426 VISP_EXPORT std::ostream &operator<<=(std::ostream &s, const usPolynomialCurve2D &seg);
427 VISP_EXPORT std::istream &operator>>=(std::istream &s, usPolynomialCurve2D &seg);
428 
429 #endif // __usPolynomialCurve2D_h_