distances.h 4.86 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
/*******************************************************************************
 * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
 * version 0.1                                                                  *
4
 * Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *                                                                              *
 * This library is free software; you can redistribute it and/or modify it      *
 * under the terms of the GNU Lesser General Public License as published by the *
 * Free Software Foundation; either version 2.1 of the License, or (at your     *
 * option) any later version.                                                   *
 *                                                                              *
 * This library is distributed in the hope that it will be useful, but WITHOUT  *
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
 * for more details.                                                            *
 *                                                                              *
 * You should have received a copy of the GNU Lesser General Public License     *
 * along with this library; if not, write to the Free Software Foundation,      *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
 *                                                                              *
20
 * Web site: http://cgogn.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 * Contact information: cgogn@unistra.fr                                        *
 *                                                                              *
 *******************************************************************************/

#ifndef __DISTANCES__
#define __DISTANCES__

#include "Geometry/basic.h"

namespace CGoGN
{

namespace Geom
{

/**
* compute squared distance from point to triangle plane
* @param P the point
* @param A triangle point 1
* @param B triangle point 2
* @param C triangle point 3
* @return the squared distance
*/
template <typename VEC3>
typename VEC3::DATA_TYPE squaredDistancePoint2TrianglePlane(const VEC3& P, const VEC3& A, const VEC3& B, const VEC3& C) ;

/**
* compute distance from point to triangle plane
* @param P the point
* @param A triangle point 1
* @param B triangle point 2
* @param C triangle point 3
* @return the distance
*/
template <typename VEC3>
typename VEC3::DATA_TYPE distancePoint2TrianglePlane(const VEC3& P, const VEC3& A, const VEC3& B, const VEC3& C) ;

/**
* compute squared distance from point to triangle
* @param P the point
* @param A triangle point 1
* @param B triangle point 2
* @param C triangle point 3
* @return the squared distance
*/
template <typename VEC3>
typename VEC3::DATA_TYPE squaredDistancePoint2Triangle(const VEC3& P, const VEC3& A, const VEC3& B, const VEC3& C) ;

/**
* compute squared distance from point to line
* @param P the point
* @param A a point on the line
* @param AB line direction
* @param AB2 squared norm of vector AB
* @return the squared distance
*/
template <typename VEC3>
typename VEC3::DATA_TYPE squaredDistanceLine2Point(const VEC3& A, const VEC3& AB, typename VEC3::DATA_TYPE AB2, const VEC3& P) ;

/**
* compute squared distance from point to line
* @param P the point
* @param A line point 1
* @param B line point 2
* @return the squared distance
*/
template <typename VEC3>
typename VEC3::DATA_TYPE squaredDistanceLine2Point(const VEC3& A, const VEC3& B, const VEC3& P) ;

/**
* compute squared distance from line to line
* @return the squared distance
*/
template <typename VEC3>
typename VEC3::DATA_TYPE squaredDistanceLine2Line(const VEC3& A, const VEC3& AB, typename VEC3::DATA_TYPE AB2, const VEC3& P, const VEC3& Q) ;

/**
* compute squared distance from line to segment
* @return the squared distance
*/
template <typename VEC3>
typename VEC3::DATA_TYPE squaredDistanceLine2Seg(const VEC3& A, const VEC3& AB, typename VEC3::DATA_TYPE AB2, const VEC3& P, const VEC3& Q) ;

/**
* compute squared distance from segment to point
* @return the squared distance
*/
template <typename VEC3>
typename VEC3::DATA_TYPE squaredDistanceSeg2Point(const VEC3& A, const VEC3& AB, typename VEC3::DATA_TYPE AB2, const VEC3& P) ;

111
112
113
114
115
116
117
118
119
120
121
122
123
124

/**
 * compute the closest points on a line from an other
 * @param P1 one point on first line
 * @param V1 vector defining first line
 * @param P2 one point on second line
 * @param P1 vector defining second line
 * @param Q1 computed point of (P1,V1) closest of (P2,V2)
 * @param Q2 computed point of (P2,V2) closest of (P1,V1)
 * &return true if computaable
 */
template <typename VEC3>
bool lineLineClosestPoints(const VEC3& P1, const VEC3& V1, const VEC3& P2, const VEC3& V2, VEC3& Q1, VEC3& Q2);

Pierre Kraemer's avatar
Pierre Kraemer committed
125
} // namespace Geom
Pierre Kraemer's avatar
Pierre Kraemer committed
126

Pierre Kraemer's avatar
Pierre Kraemer committed
127
} // namespace CGoGN
Pierre Kraemer's avatar
Pierre Kraemer committed
128

Pierre Kraemer's avatar
Pierre Kraemer committed
129
#include "Geometry/distances.hpp"
Pierre Kraemer's avatar
Pierre Kraemer committed
130
131

#endif