ug4
Loading...
Searching...
No Matches
math_util.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009-2015: G-CSC, Goethe University Frankfurt
3 * Author: Sebastian Reiter
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __H__UGMATH__MATH_UTIL__
34#define __H__UGMATH__MATH_UTIL__
35
36#include <cstdlib>
37#include "math_constants.h"
38#include "../math_vector_matrix/math_vector.h"
39#include "../math_vector_matrix/math_vector_functions.h"
40#include "../ugmath_types.h"
41#include "../../ug_config.h"
42#include "eigenvalues.h"
43
44// this is quite hacky...
45// some environments (on windows) seem to define a small type or variable.
46// this causes errors with parameter names etc. It is thus undefined below.
47#ifdef small
48 #undef small
49#endif
50
51namespace ug
52{
53
61// deg_to_rad
62template <class TNumber>
63inline TNumber
64deg_to_rad(TNumber deg);
65
67// rad_to_deg
68template <class TNumber>
69inline TNumber
70rad_to_deg(TNumber rad);
71
73// urand
75template <class TNumber>
76TNumber
77urand(TNumber lowerBound, TNumber upperBound);
78
80// clip
82template <class TNumber>
83TNumber
84clip(TNumber val, TNumber lowerBound, TNumber upperBound);
85
88template <class TNumber>
89inline TNumber sq(TNumber val);
90
94bool FindNormal(vector3& normOut, const vector3& v);
95
98
111UG_API
112bool ConstructOrthonormalSystem(matrix33& matOut, const vector3& v,
113 size_t vColInd);
114
117template <class vector_t>
118void CalculateCenter(vector_t& centerOut, const vector_t* pointSet,
119 size_t numPoints);
120
123template <class vector_t>
124vector_t
125TriangleBarycenter(const vector_t& p1, const vector_t& p2, const vector_t& p3);
126
129
134UG_API
135bool TriangleCircumcenter(vector2& centerOut, const vector2& p1,
136 const vector2& p2, const vector2& p3);
137
138UG_API
139bool TriangleCircumcenter(vector3& centerOut, const vector3& p1,
140 const vector3& p2, const vector3& p3);
145
149UG_API
150void CalculateCovarianceMatrix(matrix33& matOut, const vector3* pointSet,
151 const vector3& center, size_t numPoints);
152
155
160UG_API
161bool FindClosestPlane(vector3& centerOut, vector3& normalOut,
162 const vector3* pointSet, size_t numPoints);
163
166
177UG_API
178bool TransformPointSetTo2D(vector2* pointSetOut, const vector3* pointSet,
179 size_t numPoints);
180
183
189template <class vector_t>
190number DropAPerpendicular(vector_t& vOut, const vector_t& v,
191 const vector_t& v0, const vector_t& v1);
192
193
196template <class vector_t>
197vector_t PointOnRay(const vector_t& from, const vector_t& dir, number s);
198
201
207template <class vector_t>
208number ProjectPointToRay(vector_t& vOut, const vector_t& v,
209 const vector_t& from, const vector_t& dir);
210
211
214
218template <class vector_t>
219number ProjectPointToLine(vector_t& vOut, const vector_t& v,
220 const vector_t& from, const vector_t& to);
221
222
225/*
226 * the coordinates of the point are given through v.
227 * the line-segment is defined by its endpoints v1 and v2.
228 *
229 * The method returns the distance.
230 */
231template <class vector_t>
232inline
233number DistancePointToLine(const vector_t& v, const vector_t& v1,
234 const vector_t& v2);
235
236template <class vector_t>
237number DistancePointToLine(number& tOut, const vector_t& v,
238 const vector_t& v1, const vector_t& v2);
239
242/*
243 * the coordinates of the point are given through v.
244 * the ray is defined by from (an arbitrary point on the ray) and
245 * dir (the direction of the ray).
246 *
247 * The method returns the distance.
248 */
249template <class vector_t>
250inline
251number DistancePointToRay(const vector_t& v, const vector_t& from,
252 const vector_t& dir);
253
254template <class vector_t>
255inline
256number DistancePointToRay(number& tOut, const vector_t& v,
257 const vector_t& from, const vector_t& dir);
258
261
273template <class vector_t>
274number DistancePointToTriangle(vector_t& vOut, number& bc1Out, number& bc2Out,
275 const vector_t& p, const vector_t& v1, const vector_t& v2,
276 const vector_t& v3, const vector_t& n);
277
280template <class vector_t>
281number DistancePointToPlane(const vector_t& v, const vector_t& p,
282 const vector_t& n);
283
286
287template <class vector_t>
288void ProjectPointToPlane(vector_t& vOut, const vector_t& v,
289 const vector_t& p, const vector_t& n);
290
292// RayPlaneIntersection
294template <class vector_t>
295bool RayPlaneIntersection(vector_t& vOut, number& tOut,
296 const vector_t& rayFrom, const vector_t& rayDir,
297 const vector_t& p, const vector_t& n);
298
300// RayRayIntersection2d
302
309template <class vector_t>
310bool RayRayIntersection2d(vector_t &vOut, number& t0Out, number& t1Out,
311 const vector_t &p0, const vector_t &dir0,
312 const vector_t &p1, const vector_t &dir1);
313
315// RayLineIntersection2d
317
330template <class vector_t>
331bool RayLineIntersection2d(vector_t &vOut, number& bcOut, number& tOut,
332 const vector_t &p0, const vector_t &p1,
333 const vector_t &vFrom, const vector_t &vDir,
334 number sml = 0);
335
336
338// LineLineIntersection2d
340
350template <class vector_t>
351bool LineLineIntersection2d(vector_t &vOut, number& t0Out, number& t1Out,
352 const vector_t &from0, const vector_t &to0,
353 const vector_t &from1, const vector_t &to1,
354 const number threshold = 0);
355
356
359
369UG_API
370bool RayRayIntersection3d(vector3& aOut, vector3& bOut,
371 const vector3& p0, const vector3& dir0,
372 const vector3& p1, const vector3& dir1);
373
376
385UG_API
386bool LineLineIntersection3d(vector3& aOut, vector3& bOut,
387 const vector3& a1, const vector3& a2,
388 const vector3& b1, const vector3& b2);
389
392
394template <class vector_t>
395bool RayRayProjection(number& t1Out, number& t2Out,
396 const vector_t& from1, const vector_t& dir1,
397 const vector_t& from2, const vector_t& dir2);
398
401
402template <class vector_t>
403bool LineLineProjection(number& t1Out, number& t2Out,
404 const vector_t& a1, const vector_t& a2,
405 const vector_t& b1, const vector_t& b2);
406
409
414UG_API
415number DistanceLineToLine(const vector3& a1, const vector3& a2,
416 const vector3& b1, const vector3& b2);
417
419// RayTriangleIntersection
421
436template <class vector_t>
437bool RayTriangleIntersection(vector_t &vOut, number& bc1Out, number& bc2Out, number& tOut,
438 const vector_t &p0, const vector_t &p1, const vector_t &p2,
439 const vector_t &vFrom, const vector_t &vDir,
440 const number small = SMALL);
441
443// RayTriangleIntersection
445
456template <class vector_t> inline
457bool RayTriangleIntersection(vector_t &vOut, const vector_t &p0,
458 const vector_t &p1, const vector_t &p2,
459 const vector_t &vFrom, const vector_t &vDir);
460
462// RayBoxIntersection
464
476template <class vector_t>
477bool RayBoxIntersection(const vector_t& rayFrom, const vector_t& rayDir,
478 const vector_t& boxMin, const vector_t& boxMax,
479 number* tNearOut = NULL, number* tFarOut = NULL);
480
483
488template <class vector_t>
489bool LineBoxIntersection(const vector_t& v1, const vector_t& v2,
490 const vector_t& boxMin, const vector_t& boxMax);
491
494
497template <class vector_t>
498int RaySphereIntersection(number& s1Out, number& s2Out,
499 const vector_t& v, const vector_t& dir,
500 const vector_t& center, number radius);
501
502template <class vector_t>
503int LineSphereIntersection(number& s1Out, number& s2Out,
504 const vector_t& v1, const vector_t& v2,
505 const vector_t& center, number radius);
506
507
510UG_API
511bool RayCylinderIntersection(number& tMinOut, number& tMaxOut, const vector3& rayFrom,
512 const vector3& rayDir, const vector3& cylCenter,
513 const vector3& cylAxis, number cylRadius);
514
516// TriangleTriangleIntersection
518
527UG_API
529 const MathVector<3>& p2, const MathVector<3>& q0,
530 const MathVector<3>& q1, const MathVector<3>& q2,
531 MathVector<3>* ip1Out = NULL,
532 MathVector<3>* ip2Out = NULL,
533 number snapThreshold = SMALL);
534
536// TriBoxIntersection
537// opposed to most of the other methods here, TriBoxIntersection is not
538// a template method. Instead it directly operates on the built in
539// vector3 type. This is due to its implementation, which is taken
540// from 'Game Programming Gems'. Please have a look at the copyright notice
541// in 'tri_box.cpp'.
544
549UG_API
550bool TriangleBoxIntersection(const MathVector<3>& p0, const MathVector<3>& p1,
551 const MathVector<3>& p2,
552 const MathVector<3>& boxMin, const MathVector<3>& boxMax);
553
556
557template <class vector_t>
558bool BoxBoxIntersection(const vector_t& box1Min, const vector_t& box1Max,
559 const vector_t& box2Min, const vector_t& box2Max);
560
562// BoxBoundProbe
564
566template <class vector_t>
567bool BoxBoundProbe(const vector_t& v, const vector_t& boxMin,
568 const vector_t& boxMax);
569
572template <class vector_t>
573number TriangleArea(const vector_t& p1, const vector_t& p2,
574 const vector_t& p3);
575
578template <class vector_t>
579number QuadrilateralArea(const vector_t& p1, const vector_t& p2,
580 const vector_t& p3, const vector_t& p4);
581
584
588template <class vector_t>
589number GeometricApproximationDegree(vector_t& n1, vector_t& n2, vector_t& n3,
590 vector_t& tn);
591
594
599template <class vector_t>
600number TriangleQuality_Area(const vector_t& p1, const vector_t& p2,
601 const vector_t& p3);
602
605
609template <class vector_t>
610bool PointIsInsideTriangle(const vector_t& v, const vector_t& v0,
611 const vector_t& v1, const vector_t& v2);
612
615
622template <class vector_t>
623bool PointIsInsideTriangle_HighAcc(const vector_t& v, const vector_t& v0,
624 const vector_t& v1, const vector_t& v2);
625
628
632template <class vector_t>
633bool PointIsInsideQuadrilateral(const vector_t& v, const vector_t& v0,
634 const vector_t& v1, const vector_t& v2,
635 const vector_t& v3);
636
638// PointIsInsideTetrahedron
640
645template <class vector_t>
646bool PointIsInsideTetrahedron(const vector_t& v, const vector_t& v0, const vector_t& v1,
647 const vector_t& v2, const vector_t& v3);
648
650// CalculateTetrahedronVolume - mstepnie
651UG_API
653 const vector3& c, const vector3& d);
654
655// CalculatePyramidVolume - mscherer
656number CalculatePyramidVolume(const vector3& v0, const vector3& v1,
657 const vector3& v2, const vector3& v3, const vector3& v4);
658
659// CalculatePrismVolume - mscherer
660number CalculatePrismVolume(const vector3& v0, const vector3& v1,
661 const vector3& v2, const vector3& v3, const vector3& v4,
662 const vector3& v5);
663
664// CalculateHexahedronVolume - mscherer
666 const vector3& v2, const vector3& v3, const vector3& v4,
667 const vector3& v5, const vector3& v6, const vector3& v8);
668
669// CalculateHexahedronVolume - mstepnie
685 const vector3& c, const vector3& d, const vector3& e,
686 const vector3& f);
687
689// BinomialCoefficient
691
697UG_API
698int BinomCoeff(int n, int k);
699
701// ReflectVectorAtPlane
703
715template <class vector_t>
716void ReflectVectorAtPlane(vector_t& vReflectedOut, const vector_t& v,
717 const vector_t& n, const vector_t& r0);
718
719// end group ugbase_math
721
722}// end of namespace
723
725// include implementation
726#include "math_util_impl.hpp"
727
728#endif
#define UG_API
Definition ug_config.h:65
double number
Definition types.h:124
number CalculateTetrahedronVolume(const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d)
Definition math_util.cpp:440
number TriangleArea(const vector_t &p1, const vector_t &p2, const vector_t &p3)
calculates the are of the triangle defined by p1, p2 and p3
Definition math_util_impl.hpp:914
number ProjectPointToLine(vector_t &vOut, const vector_t &v, const vector_t &from, const vector_t &to)
finds the projection of v onto the line defined by from and to
Definition math_util_impl.hpp:186
bool TransformPointSetTo2D(vector2 *pointSetOut, const vector3 *pointSet, size_t numPoints)
transforms points from 3d space to 2d space.
Definition math_util.cpp:294
bool LineLineIntersection2d(vector_t &vOut, number &t0Out, number &t1Out, const vector_t &from0, const vector_t &to0, const vector_t &from1, const vector_t &to1, const number threshold=0)
calculates the intersection of a two lines in 2d
Definition math_util_impl.hpp:443
bool PointIsInsideQuadrilateral(const vector_t &v, const vector_t &v0, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Returns true if the point lies inside or on the boundary of a quadrilateral.
Definition math_util_impl.hpp:1040
bool LineLineProjection(number &t1Out, number &t2Out, const vector_t &a1, const vector_t &a2, const vector_t &b1, const vector_t &b2)
calculates the closest point between the rays through the given lines.
Definition math_util_impl.hpp:488
number QuadrilateralArea(const vector_t &p1, const vector_t &p2, const vector_t &p3, const vector_t &p4)
calculates the are of the triangle defined by p1, p2 and p3
Definition math_util_impl.hpp:924
number CalculateOctahedronVolume(const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d, const vector3 &e, const vector3 &f)
Definition math_util.cpp:525
vector_t TriangleBarycenter(const vector_t &p1, const vector_t &p2, const vector_t &p3)
Calculates the barycenter of a triangle (1/3) * (p1+p2+p3)
Definition math_util_impl.hpp:114
bool RayPlaneIntersection(vector_t &vOut, number &tOut, const vector_t &rayFrom, const vector_t &rayDir, const vector_t &p, const vector_t &n)
calculates the intersection of the ray rayFrom+t*rayDir and the plane (x-p)*n=0.
Definition math_util_impl.hpp:360
bool RayBoxIntersection(const vector_t &rayFrom, const vector_t &rayDir, const vector_t &boxMin, const vector_t &boxMax, number *tNearOut=NULL, number *tFarOut=NULL)
checks if a ray is intersecting a box
Definition math_util_impl.hpp:754
bool RayRayIntersection2d(vector_t &vOut, number &t0Out, number &t1Out, const vector_t &p0, const vector_t &dir0, const vector_t &p1, const vector_t &dir1)
calculates the intersection of two Rays in 2d
Definition math_util_impl.hpp:383
number DistancePointToRay(const vector_t &v, const vector_t &from, const vector_t &dir)
calculates the distance of a point to a ray
Definition math_util_impl.hpp:225
number CalculatePyramidVolume(const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d, const vector3 &e)
Definition math_util.cpp:465
TNumber urand(TNumber lowerBound, TNumber upperBound)
uniform distributed random numbers in [lowerBound, upperBound[. Use srand to set a seed.
Definition math_util_impl.hpp:67
bool RayRayIntersection3d(vector3 &aOut, vector3 &bOut, const vector3 &p0, const vector3 &dir0, const vector3 &p1, const vector3 &dir1)
intersects two 3d rays
Definition math_util.cpp:331
bool ConstructOrthonormalSystem(matrix33 &matOut, const vector3 &v, size_t vColInd)
constructs a orthonormal matrix given a vector in 3d.
Definition math_util.cpp:211
number DistancePointToLine(const vector_t &v, const vector_t &v1, const vector_t &v2)
calculates the distance of a point to a line segment
Definition math_util_impl.hpp:197
void CalculateCovarianceMatrix(matrix33 &matOut, const vector3 *pointSet, const vector3 &center, size_t numPoints)
Calculates the covariance matrix of a given point-set.
Definition math_util.cpp:248
number DropAPerpendicular(vector_t &vOut, const vector_t &v, const vector_t &v0, const vector_t &v1)
finds the projection of v onto the line defined by v0 and v1
Definition math_util_impl.hpp:123
bool PointIsInsideTriangle(const vector_t &v, const vector_t &v0, const vector_t &v1, const vector_t &v2)
Returns true if the point lies inside or on the boundary of a triangle.
Definition math_util_impl.hpp:971
vector_t PointOnRay(const vector_t &from, const vector_t &dir, number s)
returns the point described by a relative ray coordinate
Definition math_util_impl.hpp:150
TNumber sq(TNumber val)
returns the square of a value (val*val)
Definition math_util_impl.hpp:91
number GeometricApproximationDegree(vector_t &n1, vector_t &n2, vector_t &n3, vector_t &tn)
the returned degree lies between 0 and 1. The closer to 1 the better.
Definition math_util_impl.hpp:932
bool BoxBoundProbe(const vector_t &v, const vector_t &boxMin, const vector_t &boxMax)
Returns true if the point lies inside or on the boundary of the box.
Definition math_util_impl.hpp:958
number CalculatePrismVolume(const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d, const vector3 &e, const vector3 &f)
Definition math_util.cpp:485
bool RayLineIntersection2d(vector_t &vOut, number &bcOut, number &tOut, const vector_t &p0, const vector_t &p1, const vector_t &vFrom, const vector_t &vDir, number sml=0)
calculates the intersection of a ray with a Line in 2d
Definition math_util_impl.hpp:428
void CalculateCenter(vector_t &centerOut, const vector_t *pointSet, size_t numPoints)
calculates the center of a point-set
Definition math_util_impl.hpp:98
int RaySphereIntersection(number &s1Out, number &s2Out, const vector_t &v, const vector_t &dir, const vector_t &center, number radius)
checks whether the line segment (v1, v2) intersect the given sphere.
Definition math_util_impl.hpp:843
bool RayTriangleIntersection(vector_t &vOut, number &bc1Out, number &bc2Out, number &tOut, const vector_t &p0, const vector_t &p1, const vector_t &p2, const vector_t &vFrom, const vector_t &vDir, const number small=SMALL)
calculates the intersection of a ray with a triangle
Definition math_util_impl.hpp:506
TNumber clip(TNumber val, TNumber lowerBound, TNumber upperBound)
clips a number to the given interval [lowerBound, upperBound].
Definition math_util_impl.hpp:80
bool LineBoxIntersection(const vector_t &v1, const vector_t &v2, const vector_t &boxMin, const vector_t &boxMax)
checks whether the given line-segment (v1, v2) intersect the given box.
Definition math_util_impl.hpp:826
number TriangleQuality_Area(const vector_t &p1, const vector_t &p2, const vector_t &p3)
returns a value between 0 and 1. The higher the better.
Definition math_util_impl.hpp:940
void ProjectPointToPlane(vector_t &vOut, const vector_t &v, const vector_t &p, const vector_t &n)
projects v onto the plane defined by the point p and the planes normal n.
Definition math_util_impl.hpp:342
bool PointIsInsideTriangle_HighAcc(const vector_t &v, const vector_t &v0, const vector_t &v1, const vector_t &v2)
Returns true if the point lies inside or on a side of the given triangle.
Definition math_util_impl.hpp:1031
bool RayCylinderIntersection(number &tMinOut, number &tMaxOut, const vector3 &rayFrom, const vector3 &rayDir, const vector3 &cylCenter, const vector3 &cylAxis, number cylRadius)
returns the parameter values at which a given ray intersects an infinite cylinder.
Definition math_util.cpp:386
int BinomCoeff(int n, int k)
Returns the BinomialCoefficient.
Definition math_util.cpp:553
TNumber deg_to_rad(TNumber deg)
Definition math_util_impl.hpp:49
UG_API bool TriangleTriangleIntersection(const MathVector< 3 > &p0, const MathVector< 3 > &p1, const MathVector< 3 > &p2, const MathVector< 3 > &q0, const MathVector< 3 > &q1, const MathVector< 3 > &q2, MathVector< 3 > *ip1Out=NULL, MathVector< 3 > *ip2Out=NULL, number snapThreshold=SMALL)
checks whether two triangles intersect and returns the intervals, if they do.
Definition tritri.cpp:390
bool PointIsInsideTetrahedron(const vector_t &v, const vector_t &v0, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Returns true if the point lies inside or on the boundary of a tetrahedron.
Definition math_util_impl.hpp:1110
UG_API bool TriangleBoxIntersection(const MathVector< 3 > &p0, const MathVector< 3 > &p1, const MathVector< 3 > &p2, const MathVector< 3 > &boxMin, const MathVector< 3 > &boxMax)
checks whether a triangle and an axis-aligned box intersect.
Definition tri_box.cpp:370
number DistancePointToPlane(const vector_t &v, const vector_t &p, const vector_t &n)
Calculates the distance between the specified point and the plane.
Definition math_util_impl.hpp:332
void ReflectVectorAtPlane(vector_t &vReflectedOut, const vector_t &v, const vector_t &n, const vector_t &r0)
reflects a vector at a plane
Definition math_util_impl.hpp:1166
bool TriangleCircumcenter(vector2 &centerOut, const vector2 &p1, const vector2 &p2, const vector2 &p3)
Calculates the circumcenter of a triangle.
Definition math_util.cpp:45
bool BoxBoxIntersection(const vector_t &box1Min, const vector_t &box1Max, const vector_t &box2Min, const vector_t &box2Max)
checks whether two boxes intersect.
Definition math_util_impl.hpp:901
number CalculateHexahedronVolume(const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d, const vector3 &e, const vector3 &f, const vector3 &g, const vector3 &h)
Definition math_util.cpp:503
bool LineLineIntersection3d(vector3 &aOut, vector3 &bOut, const vector3 &a1, const vector3 &a2, const vector3 &b1, const vector3 &b2)
intersects two 3d line segments
Definition math_util.cpp:352
bool FindNormal(vector3 &normOut, const vector3 &v)
finds a normal to the given vector in 3d.
Definition math_util.cpp:184
int LineSphereIntersection(number &s1Out, number &s2Out, const vector_t &v1, const vector_t &v2, const vector_t &center, number radius)
Definition math_util_impl.hpp:873
bool RayRayProjection(number &t1Out, number &t2Out, const vector_t &from1, const vector_t &dir1, const vector_t &from2, const vector_t &dir2)
Calculates the parameter values at wich two rays are closest.
Definition math_util_impl.hpp:462
bool FindClosestPlane(vector3 &centerOut, vector3 &normalOut, const vector3 *pointSet, size_t numPoints)
Finds the plane which minimizes the distance to the given point set.
Definition math_util.cpp:268
TNumber rad_to_deg(TNumber rad)
Definition math_util_impl.hpp:58
number DistanceLineToLine(const vector3 &a1, const vector3 &a2, const vector3 &b1, const vector3 &b2)
calculates the distance between two 3d line segments
Definition math_util.cpp:369
number ProjectPointToRay(vector_t &vOut, const vector_t &v, const vector_t &from, const vector_t &dir)
finds the projection of v onto the ray defined by from and dir
Definition math_util_impl.hpp:160
number DistancePointToTriangle(vector_t &vOut, number &bc1Out, number &bc2Out, const vector_t &p, const vector_t &v1, const vector_t &v2, const vector_t &v3, const vector_t &n)
calculates the minimal distance of a point to a triangle.
Definition math_util_impl.hpp:243
MathVector< 2, number > vector2
a 2d vector
Definition ugmath_types.h:69
MathVector< 3, number > vector3
a 3d vector
Definition ugmath_types.h:72
MathMatrix< 3, 3, number > matrix33
a 3x3 matrix
Definition ugmath_types.h:81
the ug namespace
const number SMALL
Definition math_constants.h:41