fw4spl
|
The namespace fwMath contains classes which provide the implementation of several mathematic functions and objects (plane, line, point). More...
Functions | |
template<typename TYPE > | |
bool | isEqual (TYPE a, TYPE b, const float epsilon=0.00001F) |
Returns true iff a and b are equal with 'epsilon' error margin. More... | |
template<typename CONTAINER > | |
bool | isContainerEqual (CONTAINER &containerA, CONTAINER &containerB, const float epsilon=0.00001F) |
Returns true iff container a and b are equal with 'epsilon' error margin. More... | |
FWMATH_API bool | getClosestPoints (const fwLine &_ray1, const fwLine &_ray2, fwVec3d &_pointOnThis, fwVec3d &_pointOnfwLine) |
Compute the closest points between two rays. More... | |
FWMATH_API fwVec3d | getClosestPoint (const fwLine &_ray, const fwVec3d &_point) |
Compute the projection of a point in a given direction. More... | |
FWMATH_API bool | intersect (const fwLine &_ray, double _radius, const fwVec3d &_point) |
Compute the projection of a point in a given direction and test if this intersection is inside a given radius. More... | |
FWMATH_API bool | intersect (const fwLine &_line, double _radius, const fwVec3d &_origin, const fwVec3d &_direction, fwVec3d &_point) |
Compute the closest points between two rays and test these points lie inside a sphere of a given radius. More... | |
FWMATH_API bool | intersect (const fwLine &_line, const fwVec3d &_v1, const fwVec3d &_v2, const fwVec3d &_v3, fwVec3d &_point, fwVec3d &_barycentric, bool &_front) |
Give the intersection between a plane and a line. The result is returned in a point (_point). More... | |
FWMATH_API void | multVecMatrix (const fwMatrix4x4 &_matrix, const fwVec3d &_source, fwVec3d &_dest) |
Multiply a matrix by a vector. More... | |
FWMATH_API fwMatrix4x4 | getRotationMatrix (const fwVec3d &_vecNorm) |
Compute a matrix rotation. More... | |
FWMATH_API fwMatrix4x4 | getInverse (const fwMatrix4x4 &matrix) |
Computes the inverse of a matrix. More... | |
FWMATH_API bool | IsInclosedVolume (const fwVertexPosition &_vertex, const fwVertexIndex &_vertexIndex, const fwVec3d &_p) |
FWMATH_API bool | intersect_triangle (fwVec3d _orig, fwVec3d _dir, fwVec3d _vert0, fwVec3d _vert1, fwVec3d _vert2, double &_t, double &_u, double &_v) |
Compute the intersection between triangle(define by threes vertex vert1, vert2, vert3) and the Oz parallel line and cross by the point P. The function return true if intersection is found (false otherwise). t is the oriented distance of P to the intersection point. u and v is the coordinate of the intersection point in the (O, u, v) triangle coordinate system with : O = vert1. u = vert2 - O. v = vert3 - O. "Fast, Minimum Storage Ray/Triangle Intersection", Tomas Muller, Ben Trumbore. | |
FWMATH_API bool | isBorderlessSurface (const fwVertexIndex &_vertexIndex) |
test whatever a vertex is duplicated or not | |
FWMATH_API void | findBorderEdges (const fwVertexIndex &_vertexIndex, std::vector< std::vector< std::pair< int, int > > > &contours) |
FWMATH_API bool | closeSurface (fwVertexPosition &_vertex, fwVertexIndex &_vertexIndex) |
Closes the surface if necessary. More... | |
FWMATH_API bool | removeOrphanVertices (fwVertexPosition &_vertex, fwVertexIndex &_vertexIndex) |
template<typename T , typename U > | |
std::pair< T, U > | makeOrderedPair (const T first, const U second) |
template<typename T , typename U , typename V > | |
bool | isBorderlessSurface (T *cellDataBegin, T *cellDataEnd, U *cellDataOffsetsBegin, U *cellDataOffsetsEnd, V *cellTypesBegin) |
FWMATH_API fwPlane | getPlane (const fwVec3d &_point1, const fwVec3d &_point2, const fwVec3d &_point3) |
FWMATH_API fwPlane | getPlane (const fwVec3d &_normal, const fwVec3d &_point) |
compute a plane from a normal and a point which must be in the plane. More... | |
FWMATH_API void | setValues (fwPlane &_plane, const fwVec3d &_point1, const fwVec3d &_point2, const fwVec3d &_point3) |
Initialize a plane _plane with three points (_point1, _point2, _point3). It computes the plane's normal and the distance from the origin. More... | |
FWMATH_API fwVec3d | getNormal (const fwPlane &_plane) |
Return the normal of the given plane _plane. More... | |
FWMATH_API void | setNormal (fwPlane &_plane, const fwVec3d &_normal) |
Set the normal of the given plane _plane. More... | |
FWMATH_API double | getDistance (const fwPlane &_plane) |
Get the distance from origin for the given plan (_plane). More... | |
FWMATH_API void | setDistance (fwPlane &_plane, const double _distance) |
Set the distance from origin (_distance) for the given plan (_plane). More... | |
FWMATH_API bool | intersect (const fwPlane &_fwPlane, const fwLine &_line, fwVec3d &_point) |
Give the intersection between a plane and a line. The result is returned in a point (_point) More... | |
FWMATH_API bool | isInHalfSpace (const fwPlane &_plane, const fwVec3d &_point) |
Compute if a point is in a half plane. More... | |
FWMATH_API void | transform (fwPlane &_plane, const fwMatrix4x4 &_matrix) |
Apply a transformation to a plane. The transformation is defined by a matrix 4x4. More... | |
FWMATH_API void | offset (fwPlane &_plane, double _offset) |
Add an offset at the distance of origin which define the plane (_plane). More... | |
FWMATH_API double | normalize (fwVec3d &vec) |
Normalize a vector. | |
FWMATH_API fwVec3d | normalized (const fwVec3d &vec) |
Return a normalized vector. More... | |
FWMATH_API double | dot (const fwVec3d &v1, const fwVec3d &v2) |
Compute the Dot product between two vectors. More... | |
FWMATH_API fwVec3d | cross (const fwVec3d &v1, const fwVec3d &v2) |
Compute the Cross product between two vectors. More... | |
FWMATH_API double | vecLength (const fwVec3d &_vec) |
Compute the length of the vector. More... | |
FWMATH_API void | negate (fwVec3d &_vec) |
Compute the negate of the vector. More... | |
The namespace fwMath contains classes which provide the implementation of several mathematic functions and objects (plane, line, point).
bool fwMath::closeSurface | ( | fwVertexPosition & | _vertex, |
fwVertexIndex & | _vertexIndex | ||
) |
Closes the surface if necessary.
Definition at line 239 of file MeshFunctions.cpp.
fwVec3d fwMath::cross | ( | const fwVec3d & | v1, |
const fwVec3d & | v2 | ||
) |
Compute the Cross product between two vectors.
[in] | v1 | |
[in] | v2 |
Definition at line 47 of file VectorFunctions.cpp.
Referenced by intersect().
double fwMath::dot | ( | const fwVec3d & | v1, |
const fwVec3d & | v2 | ||
) |
Compute the Dot product between two vectors.
[in] | v1 | |
[in] | v2 |
Definition at line 39 of file VectorFunctions.cpp.
Referenced by intersect().
fwVec3d fwMath::getClosestPoint | ( | const fwLine & | _ray, |
const fwVec3d & | _point | ||
) |
Compute the projection of a point in a given direction.
[in] | _ray | ray (origin,direction). Direction vector is assumed be normalized. |
[in] | _point | point to be projected |
Definition at line 56 of file LineFunctions.cpp.
Referenced by intersect().
bool fwMath::getClosestPoints | ( | const fwLine & | _ray1, |
const fwLine & | _ray2, | ||
fwVec3d & | _pointOnThis, | ||
fwVec3d & | _pointOnfwLine | ||
) |
Compute the closest points between two rays.
[in] | _ray1 | ray (origin,direction). Direction vector is assumed be normalized. |
[in] | _ray2 | ray (origin,direction). Direction vector is assumed be normalized. |
[out] | _pointOnThis | intersection point. |
[out] | _pointOnfwLine | barycenter of the triangle defined by the three points of the place. Return FALSE if the lines are parallel, TRUE otherwise. p1 + t1 * d1 p2 + t2 * d2 (p2 - p1 + t2 * d2 - t1 * d1) * d1 = 0 (p2 - p1 + t2 * d2 - t1 * d1) * d2 = 0 t2 * (d2.d1) - t1 = (p1 - p2).d1 t2 - t1 * (d1.d2) = (p1 - p2).d2 delta = 1 - (d1.d2)**2 t2 = [ d2.(p1-p2) - d1.(p1-p2) * (d1.d2)]/delta t1 = [-d1.(p1-p2) + d2.(p1-p2) * (d1.d2)]/delta |
Definition at line 21 of file LineFunctions.cpp.
Referenced by intersect().
double fwMath::getDistance | ( | const fwPlane & | _plane | ) |
Get the distance from origin for the given plan (_plane).
[in] | _plane |
Definition at line 73 of file PlaneFunctions.cpp.
Referenced by offset().
fwMatrix4x4 fwMath::getInverse | ( | const fwMatrix4x4 & | matrix | ) |
Computes the inverse of a matrix.
[in] | matrix |
Definition at line 39 of file MatrixFunctions.cpp.
fwVec3d fwMath::getNormal | ( | const fwPlane & | _plane | ) |
Return the normal of the given plane _plane.
[in] | _plane |
Definition at line 54 of file PlaneFunctions.cpp.
Referenced by intersect().
fwPlane fwMath::getPlane | ( | const fwVec3d & | _normal, |
const fwVec3d & | _point | ||
) |
compute a plane from a normal and a point which must be in the plane.
[in] | _point | a point of the plan/ |
[in] | _normal | the normal of the new plane. |
Definition at line 171 of file PlaneFunctions.cpp.
fwMatrix4x4 fwMath::getRotationMatrix | ( | const fwVec3d & | _vecNorm | ) |
Compute a matrix rotation.
[in] | _vecNorm |
Definition at line 60 of file MatrixFunctions.cpp.
bool fwMath::intersect | ( | const fwLine & | _ray, |
double | _radius, | ||
const fwVec3d & | _point | ||
) |
Compute the projection of a point in a given direction and test if this intersection is inside a given radius.
[in] | _ray | ray (origin,direction). Direction vector is assumed be normalized. |
[in] | _radius | maximum distance of the point |
[in] | _point | point to be projected |
Definition at line 75 of file LineFunctions.cpp.
References getClosestPoint().
Referenced by intersect().
bool fwMath::intersect | ( | const fwLine & | _line, |
double | _radius, | ||
const fwVec3d & | _origin, | ||
const fwVec3d & | _direction, | ||
fwVec3d & | _point | ||
) |
Compute the closest points between two rays and test these points lie inside a sphere of a given radius.
[in] | _line | ray (origin,direction). Direction vector is assumed be normalized. |
[in] | _radius | maximum distance of the point |
[in] | _origin | origin of the second ray |
[in] | _direction | direction of the second ray |
[in] | _point | point to be projected |
Definition at line 87 of file LineFunctions.cpp.
References getClosestPoints().
bool fwMath::intersect | ( | const fwPlane & | _fwPlane, |
const fwLine & | _line, | ||
fwVec3d & | _point | ||
) |
Give the intersection between a plane and a line. The result is returned in a point (_point)
[in] | _fwPlane | |
[in] | _line | |
[out] | _point | intersection point. |
Definition at line 87 of file PlaneFunctions.cpp.
bool fwMath::intersect | ( | const fwLine & | _line, |
const fwVec3d & | _v1, | ||
const fwVec3d & | _v2, | ||
const fwVec3d & | _v3, | ||
fwVec3d & | _point, | ||
fwVec3d & | _barycentric, | ||
bool & | _front | ||
) |
Give the intersection between a plane and a line. The result is returned in a point (_point).
[in] | _line | input line (2 positions) |
[in] | _v1 | first point of the plane |
[in] | _v2 | second point of the plane |
[in] | _v3 | third point of the plane |
[out] | _point | intersection point. |
[out] | _barycentric | barycenter of the triangle defined by the three points of the plane. |
[out] | _front | true if the dot product of the plane normal and ths positive Z axis (0,0,1) is positive. |
Definition at line 106 of file LineFunctions.cpp.
References cross(), dot(), getNormal(), and intersect().
bool fwMath::isContainerEqual | ( | CONTAINER & | containerA, |
CONTAINER & | containerB, | ||
const float | epsilon = 0.00001F |
||
) |
Returns true iff container a and b are equal with 'epsilon' error margin.
containerA | container to compare |
containerB | container to compare |
epsilon | : error margin |
Definition at line 36 of file Compare.hpp.
References isEqual().
Referenced by fwDataTools::Image::mergeMask().
bool fwMath::isEqual | ( | TYPE | a, |
TYPE | b, | ||
const float | epsilon = 0.00001F |
||
) |
Returns true iff a and b are equal with 'epsilon' error margin.
a | value to compare |
b | value to compare |
epsilon | : error margin |
Definition at line 23 of file Compare.hpp.
Referenced by isContainerEqual().
bool fwMath::isInHalfSpace | ( | const fwPlane & | _plane, |
const fwVec3d & | _point | ||
) |
Compute if a point is in a half plane.
[in] | _plane | |
[in] | _point |
Definition at line 117 of file PlaneFunctions.cpp.
void fwMath::multVecMatrix | ( | const fwMatrix4x4 & | _matrix, |
const fwVec3d & | _source, | ||
fwVec3d & | _dest | ||
) |
Multiply a matrix by a vector.
[in] | _matrix | |
[in] | _source | |
[out] | _dest |
Definition at line 19 of file MatrixFunctions.cpp.
void fwMath::negate | ( | fwVec3d & | _vec | ) |
Compute the negate of the vector.
[in] | _vec | |
[out] | _vec |
Definition at line 67 of file VectorFunctions.cpp.
fwVec3d fwMath::normalized | ( | const fwVec3d & | vec | ) |
Return a normalized vector.
[in] | vec | vector to normalize |
Definition at line 30 of file VectorFunctions.cpp.
References normalize().
void fwMath::offset | ( | fwPlane & | _plane, |
double | _offset | ||
) |
Add an offset at the distance of origin which define the plane (_plane).
[in] | _plane | |
[in] | _offset | |
[out] | _plane |
Definition at line 162 of file PlaneFunctions.cpp.
References getDistance(), and setDistance().
bool fwMath::removeOrphanVertices | ( | fwVertexPosition & | _vertex, |
fwVertexIndex & | _vertexIndex | ||
) |
remove orphan vertices (i.e not used in _vertexIndex), _vertexIndex is reordered according to vertex suppressions
Definition at line 280 of file MeshFunctions.cpp.
void fwMath::setDistance | ( | fwPlane & | _plane, |
const double | _distance | ||
) |
Set the distance from origin (_distance) for the given plan (_plane).
[in] | _distance | |
[in] | _plane |
Definition at line 80 of file PlaneFunctions.cpp.
Referenced by offset().
void fwMath::setNormal | ( | fwPlane & | _plane, |
const fwVec3d & | _normal | ||
) |
Set the normal of the given plane _plane.
[in] | _plane | |
[in] | _normal |
Definition at line 61 of file PlaneFunctions.cpp.
void fwMath::setValues | ( | fwPlane & | _plane, |
const fwVec3d & | _point1, | ||
const fwVec3d & | _point2, | ||
const fwVec3d & | _point3 | ||
) |
Initialize a plane _plane with three points (_point1, _point2, _point3). It computes the plane's normal and the distance from the origin.
[out] | _plane | the new plane. |
[in] | _point1 | a point of the plan. |
[in] | _point2 | a point of the plan. |
[in] | _point3 | a point of the plan. |
Definition at line 30 of file PlaneFunctions.cpp.
void fwMath::transform | ( | fwPlane & | _plane, |
const fwMatrix4x4 & | _matrix | ||
) |
Apply a transformation to a plane. The transformation is defined by a matrix 4x4.
[in] | _plane | |
[in] | _matrix | |
[out] | _plane |
Definition at line 128 of file PlaneFunctions.cpp.
double fwMath::vecLength | ( | const fwVec3d & | _vec | ) |
Compute the length of the vector.
[in] | _vec |
Definition at line 59 of file VectorFunctions.cpp.
Referenced by normalize().