UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-05-20)
usGeometryTools.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 __usGeometryTools_h
34 #define __usGeometryTools_h
35 
36 #include <vector>
37 
38 #include <visp3/core/vpColVector.h>
39 #include <visp3/core/vpConfig.h>
40 
41 #include <visp3/ustk_core/usBSpline3D.h>
42 #include <visp3/ustk_core/usOrientedPlane3D.h>
43 #include <visp3/ustk_core/usPolynomialCurve3D.h>
44 
45 namespace usGeometryTools
46 {
47 VISP_EXPORT double getPointPlaneDistance(const vpColVector &point, const usOrientedPlane3D &plane);
48 VISP_EXPORT bool IsPointInFrontOfPlane(const vpColVector &point, const usOrientedPlane3D &plane);
49 VISP_EXPORT bool DoesSegmentCrossPlane(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane);
50 VISP_EXPORT bool DoesSegmentCrossPlane(const usBSpline3D &spline, const usOrientedPlane3D &plane);
51 VISP_EXPORT bool DoesSegmentCrossPlaneDirect(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane);
52 VISP_EXPORT bool DoesSegmentCrossPlaneDirect(const usBSpline3D &spline, const usOrientedPlane3D &plane);
53 VISP_EXPORT vpColVector getPlaneCurveCrossingPoint(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane,
54  double threshold, double *t = nullptr);
55 VISP_EXPORT vpColVector getPlaneCurveCrossingPoint(const usBSpline3D &spline, const usOrientedPlane3D &plane,
56  double threshold, double *t = nullptr);
57 VISP_EXPORT vpColVector projectPointOnPlane(const vpColVector &point, const usOrientedPlane3D &plane,
58  const vpColVector &direction = vpColVector());
59 VISP_EXPORT vpColVector projectPointOnCurve(const vpColVector &point, const usPolynomialCurve3D &poly,
60  double threshold = -1, double *t = nullptr);
61 VISP_EXPORT vpColVector projectPointOnCurve(const vpColVector &point, const usBSpline3D &spline, double threshold = -1,
62  int *index = nullptr, double *t = nullptr);
63 VISP_EXPORT usOrientedPlane3D getNormalPlane(const usPolynomialCurve3D &p, double l);
64 
65 VISP_EXPORT usPolynomialCurve3D convertBSplineToPolynomial(const usBSpline3D &spline, int order);
66 VISP_EXPORT usBSpline3D convertPolynomialToBSpline(const usPolynomialCurve3D &poly, int nbSegments, int order);
67 
68 VISP_EXPORT vpPoseVector findPointCloudRelativePose(std::vector<vpColVector> &P1, std::vector<vpColVector> &P2,
69  double *res = nullptr); // return transform from P1 to P2 (P2 = H *
70  // P1) (here P1 and P2 have the same size
71  // and are already matched one by one)
72 VISP_EXPORT vpTranslationVector findPointCloudRelativePosition(std::vector<vpColVector> &P1,
73  std::vector<vpColVector> &P2,
74  const vpRotationMatrix &worldRprobe,
75  double *res = nullptr); // return translation from P1 to
76  // P2 (P2 = P1 + T) (here P1 and
77  // P2 have the same size and are
78  // already matched one by one)
79 VISP_EXPORT vpRotationMatrix findPointCloudRelativeRotation(std::vector<vpColVector> &P1, std::vector<vpColVector> &P2,
80  double *res = nullptr); // return rotation from P1 to P2 (P2
81  // = R * P1) (here P1 and P2 have
82  // the same size and are already
83  // matched one by one)
84 
85 VISP_EXPORT vpPoseVector ICPPointCloudRelativePose(
86  std::vector<vpColVector> &P1, std::vector<vpColVector> &P2, double *res = nullptr,
87  vpPoseVector *initialGuess =
88  nullptr); // return transform from P1 to P2 (P2 = H * P1) (P1 and P2 can have different sizes)
89 VISP_EXPORT vpTranslationVector ICPPointCloudRelativePosition(
90  std::vector<vpColVector> &P1, std::vector<vpColVector> &P2, const vpRotationMatrix &worldRprobe,
91  double *res = nullptr,
92  vpTranslationVector *initialGuess =
93  nullptr); // return translation from P1 to P2 (P2 = P1 + T) (P1 and P2 can have different sizes)
94 VISP_EXPORT vpRotationMatrix ICPPointCloudRelativeRotation(
95  std::vector<vpColVector> &P1, std::vector<vpColVector> &P2, double *res = nullptr,
96  vpRotationMatrix *initialGuess =
97  nullptr); // return rotation from P1 to P2 (P2 = R * P1) (P1 and P2 can have different sizes)
98 
99 VISP_EXPORT bool fitCircleTo2DPointCloud(const std::vector<vpColVector> &points, vpColVector &center, double &r);
100 VISP_EXPORT bool fitSphereTo3DPointCloud(const std::vector<vpColVector> &points, vpColVector &center, double &r);
101 
102 } // namespace usGeometryTools
103 
104 #endif // __usGeometryTools_h
VISP_EXPORT bool IsPointInFrontOfPlane(const vpColVector &point, const usOrientedPlane3D &plane)
VISP_EXPORT bool fitSphereTo3DPointCloud(const std::vector< vpColVector > &points, vpColVector &center, double &r)
VISP_EXPORT bool fitCircleTo2DPointCloud(const std::vector< vpColVector > &points, vpColVector &center, double &r)
VISP_EXPORT vpColVector projectPointOnCurve(const vpColVector &point, const usPolynomialCurve3D &poly, double threshold=-1, double *t=nullptr)
VISP_EXPORT vpTranslationVector findPointCloudRelativePosition(std::vector< vpColVector > &P1, std::vector< vpColVector > &P2, const vpRotationMatrix &worldRprobe, double *res=nullptr)
VISP_EXPORT vpColVector getPlaneCurveCrossingPoint(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane, double threshold, double *t=nullptr)
VISP_EXPORT vpRotationMatrix ICPPointCloudRelativeRotation(std::vector< vpColVector > &P1, std::vector< vpColVector > &P2, double *res=nullptr, vpRotationMatrix *initialGuess=nullptr)
VISP_EXPORT double getPointPlaneDistance(const vpColVector &point, const usOrientedPlane3D &plane)
VISP_EXPORT vpRotationMatrix findPointCloudRelativeRotation(std::vector< vpColVector > &P1, std::vector< vpColVector > &P2, double *res=nullptr)
VISP_EXPORT vpColVector projectPointOnPlane(const vpColVector &point, const usOrientedPlane3D &plane, const vpColVector &direction=vpColVector())
VISP_EXPORT usBSpline3D convertPolynomialToBSpline(const usPolynomialCurve3D &poly, int nbSegments, int order)
VISP_EXPORT usOrientedPlane3D getNormalPlane(const usPolynomialCurve3D &p, double l)
VISP_EXPORT usPolynomialCurve3D convertBSplineToPolynomial(const usBSpline3D &spline, int order)
VISP_EXPORT bool DoesSegmentCrossPlaneDirect(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane)
VISP_EXPORT vpPoseVector ICPPointCloudRelativePose(std::vector< vpColVector > &P1, std::vector< vpColVector > &P2, double *res=nullptr, vpPoseVector *initialGuess=nullptr)
VISP_EXPORT vpTranslationVector ICPPointCloudRelativePosition(std::vector< vpColVector > &P1, std::vector< vpColVector > &P2, const vpRotationMatrix &worldRprobe, double *res=nullptr, vpTranslationVector *initialGuess=nullptr)
VISP_EXPORT bool DoesSegmentCrossPlane(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane)
VISP_EXPORT vpPoseVector findPointCloudRelativePose(std::vector< vpColVector > &P1, std::vector< vpColVector > &P2, double *res=nullptr)