ug4
math_util.h File Reference

Go to the source code of this file.

Namespaces

 ug
 the ug namespace
 

Functions

int ug::BinomCoeff (int n, int k)
 Returns the BinomialCoefficient. More...
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
bool ug::BoxBoxIntersection (const vector_t &box1Min, const vector_t &box1Max, const vector_t &box2Min, const vector_t &box2Max)
 checks whether two boxes intersect. More...
 
template<class vector_t >
void ug::CalculateCenter (vector_t &centerOut, const vector_t *pointSet, size_t numPoints)
 calculates the center of a point-set More...
 
void ug::CalculateCovarianceMatrix (matrix33 &matOut, const vector3 *pointSet, const vector3 &center, size_t numPoints)
 Calculates the covariance matrix of a given point-set. More...
 
number ug::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)
 
number ug::CalculateOctahedronVolume (const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d, const vector3 &e, const vector3 &f)
 
number ug::CalculatePrismVolume (const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d, const vector3 &e, const vector3 &f)
 
number ug::CalculatePyramidVolume (const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d, const vector3 &e)
 
number ug::CalculateTetrahedronVolume (const vector3 &a, const vector3 &b, const vector3 &c, const vector3 &d)
 
template<class TNumber >
TNumber ug::clip (TNumber val, TNumber lowerBound, TNumber upperBound)
 clips a number to the given interval [lowerBound, upperBound]. More...
 
bool ug::ConstructOrthonormalSystem (matrix33 &matOut, const vector3 &v, size_t vColInd)
 constructs a orthonormal matrix given a vector in 3d. More...
 
template<class TNumber >
TNumber ug::deg_to_rad (TNumber deg)
 
number ug::DistanceLineToLine (const vector3 &a1, const vector3 &a2, const vector3 &b1, const vector3 &b2)
 calculates the distance between two 3d line segments More...
 
template<class vector_t >
number ug::DistancePointToLine (const vector_t &v, const vector_t &v1, const vector_t &v2)
 calculates the distance of a point to a line segment More...
 
template<class vector_t >
number ug::DistancePointToLine (number &tOut, const vector_t &v, const vector_t &v1, const vector_t &v2)
 
template<class vector_t >
number ug::DistancePointToPlane (const vector_t &v, const vector_t &p, const vector_t &n)
 Calculates the distance between the specified point and the plane. More...
 
template<class vector_t >
number ug::DistancePointToRay (const vector_t &v, const vector_t &from, const vector_t &dir)
 calculates the distance of a point to a ray More...
 
template<class vector_t >
number ug::DistancePointToRay (number &tOut, const vector_t &v, const vector_t &from, const vector_t &dir)
 
template<class vector_t >
number ug::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.
More...
 
template<class vector_t >
number ug::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 More...
 
bool ug::FindClosestPlane (vector3 &centerOut, vector3 &normalOut, const vector3 *pointSet, size_t numPoints)
 Finds the plane which minimizes the distance to the given point set. More...
 
bool ug::FindNormal (vector3 &normOut, const vector3 &v)
 finds a normal to the given vector in 3d. More...
 
template<class vector_t >
number ug::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. More...
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
bool ug::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 More...
 
bool ug::LineLineIntersection3d (vector3 &aOut, vector3 &bOut, const vector3 &a1, const vector3 &a2, const vector3 &b1, const vector3 &b2)
 intersects two 3d line segments More...
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
int ug::LineSphereIntersection (number &s1Out, number &s2Out, const vector_t &v1, const vector_t &v2, const vector_t &center, number radius)
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
vector_t ug::PointOnRay (const vector_t &from, const vector_t &dir, number s)
 returns the point described by a relative ray coordinate More...
 
template<class vector_t >
number ug::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 More...
 
template<class vector_t >
void ug::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. More...
 
template<class vector_t >
number ug::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 More...
 
template<class vector_t >
number ug::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 More...
 
template<class TNumber >
TNumber ug::rad_to_deg (TNumber rad)
 
template<class vector_t >
bool ug::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 More...
 
bool ug::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. More...
 
template<class vector_t >
bool ug::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 More...
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
bool ug::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 More...
 
bool ug::RayRayIntersection3d (vector3 &aOut, vector3 &bOut, const vector3 &p0, const vector3 &dir0, const vector3 &p1, const vector3 &dir1)
 intersects two 3d rays More...
 
template<class vector_t >
bool ug::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. More...
 
template<class vector_t >
int ug::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. More...
 
template<class vector_t >
bool ug::RayTriangleIntersection (vector_t &vOut, const vector_t &p0, const vector_t &p1, const vector_t &p2, const vector_t &vFrom, const vector_t &vDir)
 calculates the intersection of a ray with a triangle More...
 
template<class vector_t >
bool ug::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 More...
 
template<class vector_t >
void ug::ReflectVectorAtPlane (vector_t &vReflectedOut, const vector_t &v, const vector_t &n, const vector_t &r0)
 reflects a vector at a plane More...
 
template<class TNumber >
TNumber ug::sq (TNumber val)
 returns the square of a value (val*val) More...
 
bool ug::TransformPointSetTo2D (vector2 *pointSetOut, const vector3 *pointSet, size_t numPoints)
 transforms points from 3d space to 2d space. More...
 
template<class vector_t >
number ug::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 More...
 
template<class vector_t >
vector_t ug::TriangleBarycenter (const vector_t &p1, const vector_t &p2, const vector_t &p3)
 Calculates the barycenter of a triangle (1/3) * (p1+p2+p3) More...
 
UG_API bool ug::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. More...
 
template<class vector_t >
number ug::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. More...
 
UG_API bool ug::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. More...
 
template<class TNumber >
TNumber ug::urand (TNumber lowerBound, TNumber upperBound)
 uniform distributed random numbers in [lowerBound, upperBound[. Use srand to set a seed. More...
 
bool ug::TriangleCircumcenter (vector2 &centerOut, const vector2 &p1, const vector2 &p2, const vector2 &p3)
 Calculates the circumcenter of a triangle. More...
 
bool ug::TriangleCircumcenter (vector3 &centerOut, const vector3 &p1, const vector3 &p2, const vector3 &p3)
 Calculates the circumcenter of a triangle. More...