SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CompGeom.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 
30 ///
31 ///@file CompGeom.h
32 ///
33 ///@author
34 /// Allen Sanderson
35 /// SCI Institute
36 /// University of Utah
37 ///@date August 2005
38 ///
39 
40 #ifndef CORE_GEOMETRY_COMPGEOM_H
41 #define CORE_GEOMETRY_COMPGEOM_H 1
42 
45 #include <Core/Math/MusilRNG.h>
46 #include <vector>
47 
49 
50 namespace SCIRun {
51  namespace Core {
52  namespace Geometry {
53 
54 /// Compute the distance squared from the point to the given line,
55 /// where the line is specified by two end points. This function
56 /// actually computes the distance to the line segment
57 /// between the given points and not to the line itself.
58 SCISHARE double
59 distance_to_line2(const Point &p, const Point &a, const Point &b,
60  const double epsilon = 1e-12);
61 
62 SCISHARE void
63 distance_to_line2_aux(Point &result,
64  const Point &p, const Point &a, const Point &b,
65  const double epsilon = 1e-12);
66 
67 SCISHARE void
68 distance_to_line2_aux(Point &result, int& node,
69  const Point &p, const Point &a, const Point &b,
70  const double epsilon = 1e-12);
71 
72 /// Compute the point on the triangle closest to the given point.
73 /// The distance to the triangle will be (P - result).length())
74 SCISHARE void
75 closest_point_on_tri(Point &result, const Point &P,
76  const Point &A, const Point &B, const Point &C,
77  const double epsilon = 1e-12);
78 
79 SCISHARE void
80 closest_point_on_tri(Point &result, int &edge, int& node,
81  const Point &P, const Point &A,
82  const Point &B, const Point &C,
83  const double epsilon = 1e-12);
84 
85 
86 /// This is only an estimate for an element that is not flat, it is exact
87 /// for a flat element.
88 SCISHARE void
89 est_closest_point_on_quad(Point &result, const Point &P,
90  const Point &A, const Point &B,
91  const Point &C, const Point &D,
92  const double epsilon = 1e-12);
93 
94 
95 SCISHARE double
96 RayPlaneIntersection(const Point &p, const Vector &dir,
97  const Point &p0, const Vector &pn, const double epsilon = 1e-6);
98 
99 
100 SCISHARE bool
101 RayTriangleIntersection(double &t, double &u, double &v, bool backface_cull,
102  const Point &orig, const Vector &dir,
103  const Point &p0, const Point &p1, const Point &p2,
104  const double epsilon = 1e-6);
105 
106 
107 /// Compute s and t such that the distance between A0 + s * (A1 - AO)
108 /// and B0 + t * (B1 - B0) is minimal. Return false if the lines are
109 /// parallel, true otherwise.
110 SCISHARE bool
111 closest_line_to_line(double &s, double &t,
112  const Point &A0, const Point &A1,
113  const Point &B0, const Point &B1,
114  const double epsilon = 1e-12);
115 
116 
117 SCISHARE void
118 TriTriIntersection(const Point &A0, const Point &A1, const Point &A2,
119  const Point &B0, const Point &B1, const Point &B2,
120  std::vector<Point> &results);
121 
122 
123 
124 SCISHARE void
125 uniform_sample_triangle(Point &p, const Point &p0,
126  const Point &p1, const Point &p2,
127  MusilRNG &rng);
128 
129 
130 SCISHARE double
131 tetrahedra_volume(const Point &p0, const Point &p1,
132  const Point &p2, const Point &p3);
133 
134 
135 SCISHARE void
136 uniform_sample_tetrahedra(Point &p, const Point &p0, const Point &p1,
137  const Point &p2, const Point &p3,
138  MusilRNG &rng);
139 
140 
141  }}}
142 
143 #endif
void uniform_sample_triangle(Point &p, const Point &p0, const Point &p1, const Point &p2, MusilRNG &rng)
Definition: CompGeom.cc:338
bool RayTriangleIntersection(double &t, double &u, double &v, bool backface_cull, const Point &orig, const Vector &dir, const Point &p0, const Point &p1, const Point &p2, const double epsilon)
Definition: CompGeom.cc:269
double RayPlaneIntersection(const Point &p, const Vector &dir, const Point &p0, const Vector &pn, const double epsilon)
Definition: CompGeom.cc:249
#define SCISHARE
Definition: share.h:39
double tetrahedra_volume(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Definition: CompGeom.cc:389
string dir
Definition: eab.py:5
bool closest_line_to_line(double &s, double &t, const Point &a0, const Point &a1, const Point &b0, const Point &b1, const double epsilon)
Definition: CompGeom.cc:306
Musil random number generator.
Definition: MusilRNG.h:49
void est_closest_point_on_quad(Point &result, const Point &orig, const Point &p0, const Point &p1, const Point &p2, const Point &p3, const double epsilon)
Definition: CompGeom.cc:226
void TriTriIntersection(const Point &A0, const Point &A1, const Point &A2, const Point &B0, const Point &B1, const Point &B2, std::vector< Point > &results)
Definition: CompGeom.cc:397
void closest_point_on_tri(Point &result, const Point &orig, const Point &p0, const Point &p1, const Point &p2, const double epsilon)
Definition: CompGeom.cc:136
v
Definition: readAllFields.py:42
double distance_to_line2(const Point &p, const Point &a, const Point &b, const double epsilon)
Definition: CompGeom.cc:53
void uniform_sample_tetrahedra(Point &p, const Point &p0, const Point &p1, const Point &p2, const Point &p3, MusilRNG &rng)
Definition: CompGeom.cc:353
void distance_to_line2_aux(Point &result, const Point &p, const Point &a, const Point &b, const double epsilon)
Definition: CompGeom.cc:71