#include "math/CMatrix3d.h"
#include <math.h>
Go to the source code of this file.
Functions | |
bool | cZero (const double &a_value) |
bool | cPositiveBound (const double &a_value, const double &a_boundMax) |
template<class T > | |
T | cAbs (const T a_value) |
template<class T > | |
T | cMax (const T a_value1, const T a_value2) |
template<class T > | |
T | cMin (const T a_value1, const T a_value2) |
template<class T > | |
T | cMax3 (const T &a_value1, const T &a_value2, const T &a_value3) |
template<class T > | |
T | cMin3 (const T &a_value1, const T &a_value2, const T &a_value3) |
template<class T > | |
T | cMaxAbs (const T a_value1, const T a_value2) |
template<class T > | |
T | cMinAbs (const T a_value1, const T a_value2) |
template<class T > | |
T | cMax3Abs (const T &a_value1, const T &a_value2, const T &a_value3) |
template<class T > | |
T | cMin3Abs (const T &a_value1, const T &a_value2, const T &a_value3) |
template<class T > | |
void | cSwap (T &a_value1, T &a_value2) |
template<class T > | |
T | cLerp (const double &a_level, const T &a_value1, const T &a_value2) |
template<class T > | |
T | cClamp (const T a_value, const T a_low, const T a_high) |
template<class T > | |
T | cClamp0 (T &a_value) |
double | cClamp01 (double &a_value) |
template<class T , class V > | |
bool | cContains (const T &a_value, const V &a_low, const V &a_high) |
double | cSqr (const double &a_value) |
double | cCosDeg (const double &a_angleDeg) |
double | cSinDeg (const double &a_angleDeg) |
double | cTanDeg (const double &a_angleDeg) |
double | cCosRad (const double &a_angleRad) |
double | cSinRad (const double &a_value) |
double | cTanRad (const double &a_value) |
double | cDegToRad (const double &a_angleDeg) |
double | cRadToDeg (const double &a_angleRad) |
cVector3d | cAdd (const cVector3d &a_vector1, const cVector3d &a_vector2) |
cVector3d | cAdd (const cVector3d &a_vector1, const cVector3d &a_vector2, const cVector3d &a_vector3) |
cVector3d | cSub (const cVector3d &a_vector1, const cVector3d &a_vector2) |
cVector3d | cNegate (const cVector3d &a_vector) |
cVector3d | cMul (const double &a_value, const cVector3d &a_vector) |
cVector3d | cDiv (const double &a_value, const cVector3d &a_vector) |
cVector3d | cDivVect (const double &a_value, const cVector3d &a_vector) |
cVector3d | cCross (const cVector3d &a_vector1, const cVector3d &a_vector2) |
double | cDot (const cVector3d &a_vector1, const cVector3d &a_vector2) |
cVector3d | cNormalize (const cVector3d &a_vector) |
double | cDistance (const cVector3d &a_point1, const cVector3d &a_point2) |
double | cDistanceSq (const cVector3d &a_point1, const cVector3d &a_point2) |
bool | cEqualPoints (const cVector3d &v1, const cVector3d &v2, const double epsilon=CHAI_SMALL) |
cMatrix3d | cIdentity3d (void) |
cMatrix3d | cMul (const cMatrix3d &a_matrix1, const cMatrix3d &a_matrix2) |
cVector3d | cMul (const cMatrix3d &a_matrix, const cVector3d &a_vector) |
cMatrix3d | cTrans (const cMatrix3d &a_matrix) |
cMatrix3d | cInv (const cMatrix3d &a_matrix) |
double | cAngle (const cVector3d &a_vector0, const cVector3d &a_vector1) |
double | cCosAngle (const cVector3d &a_vector0, const cVector3d &a_vector1) |
cMatrix3d | cRotMatrix (const cVector3d &a_axis, const double &a_angleRad) |
cMatrix3d | cRotate (const cMatrix3d &a_matrix, const cVector3d &a_axis, const double &a_angleRad) |
cVector3d | cProjectPointOnPlane (const cVector3d &a_point, const cVector3d &a_planePoint, const cVector3d &n) |
cVector3d | cProjectPointOnPlane (const cVector3d &a_point, const cVector3d &a_planePoint0, const cVector3d &a_planePoint1, const cVector3d &a_planePoint2) |
void | cProjectPointOnPlane (const cVector3d &a_point, const cVector3d &a_planePoint0, const cVector3d &a_planePoint1, const cVector3d &a_planePoint2, double &a_v01, double a_v02) |
cVector3d | cProjectPointOnLine (const cVector3d &a_point, const cVector3d &a_pointOnLine, const cVector3d &a_directionOfLine) |
cVector3d | cProjectPointOnSegment (const cVector3d &a_point, const cVector3d &a_segmentPointA, const cVector3d &a_segmentPointB) |
cVector3d | cProject (const cVector3d &a_vector0, const cVector3d &a_vector1) |
cVector3d | cComputeSurfaceNormal (const cVector3d &a_surfacePoint0, const cVector3d &a_surfacePoint1, const cVector3d &a_surfacePoint2) |
bool | cBoxContains (const cVector3d &a_point, const cVector3d &box_min, const cVector3d &box_max) |
int | cIntersectionSegmentSphere (cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cVector3d &a_spherePos, double &a_sphereRadius, cVector3d &a_collisionPoint0, cVector3d &a_collisionNormal0, cVector3d &a_collisionPoint1, cVector3d &a_collisionNormal1) |
int | cIntersectionSegmentToplessCylinder (cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cVector3d &a_cylinderPointA, cVector3d &a_cylinderPointB, double &a_cylinderRadius, cVector3d &a_collisionPoint0, cVector3d &a_collisionNormal0, cVector3d &a_collisionPoint1, cVector3d &a_collisionNormal1) |
bool | cIntersectionSegmentTriangle (cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cVector3d &a_triangleVertex0, cVector3d &a_triangleVertex1, cVector3d &a_triangleVertex2, cVector3d &a_collisionPoint, cVector3d &a_collisionNormal) |
T cAbs | ( | const T | a_value | ) | [inline] |
Compute absolute value.
a_value | Input value. |
cVector3d cAdd | ( | const cVector3d & | a_vector1, | |
const cVector3d & | a_vector2, | |||
const cVector3d & | a_vector3 | |||
) | [inline] |
Compute the addition between three vectors.
Result = Vector1 + Vector2 + Vector3
a_vector1 | First vector. | |
a_vector2 | Second vector. | |
a_vector3 | Third vector. |
Compute the addition between two vectors.
Result = Vector1 + Vector2
a_vector1 | First vector. | |
a_vector2 | Second vector. |
Compute the angle in radians between two vectors.
a_vector0 | Input vector. | |
a_vector1 | Input vector. |
bool cBoxContains | ( | const cVector3d & | a_point, | |
const cVector3d & | box_min, | |||
const cVector3d & | box_max | |||
) | [inline] |
Returns true if point is contained in the bounding box defined by min and max
a_point | Test point | |
box_min | Minimum coordinate in the boundary box | |
box_max | Maximum coordinate in the boundary box |
T cClamp | ( | const T | a_value, | |
const T | a_low, | |||
const T | a_high | |||
) | [inline] |
Clamp the input to the specified range.
a_value | Input value. | |
a_low | Low boundary. | |
a_high | High boundary. |
T cClamp0 | ( | T & | a_value | ) | [inline] |
Clamp the input to the range 0 - infinity.
a_value | Input value. |
double cClamp01 | ( | double & | a_value | ) | [inline] |
Clamp the input to the range [0,1].
a_value | Input value of type double. |
cVector3d cComputeSurfaceNormal | ( | const cVector3d & | a_surfacePoint0, | |
const cVector3d & | a_surfacePoint1, | |||
const cVector3d & | a_surfacePoint2 | |||
) | [inline] |
Compute the normal of a surface defined by three point passed as parameters.
a_surfacePoint0 | Point 0 of surface. | |
a_surfacePoint1 | Point 1 of surface. | |
a_surfacePoint2 | Point 2 of surface. |
bool cContains | ( | const T & | a_value, | |
const V & | a_low, | |||
const V & | a_high | |||
) | [inline] |
Check whether value is in the range of [low, high].
a_value | Input value. | |
a_low | Low boundary. | |
a_high | High boundary. |
Compute the cosine of the angle between two vectors.
a_vector0 | Input vector. | |
a_vector1 | Input vector. |
double cCosDeg | ( | const double & | a_angleDeg | ) | [inline] |
Compute the cosine of an angle defined in degrees.
a_angleDeg | Angle in degrees. |
double cCosRad | ( | const double & | a_angleRad | ) | [inline] |
Return the cosine of an angle defined in radians.
a_angleRad | Angle in radians. |
Compute the cross product between two 3D vectors.
a_vector1 | Vector1. | |
a_vector2 | Vector2. |
double cDegToRad | ( | const double & | a_angleDeg | ) | [inline] |
Convert an angle from degrees to radians.
a_angleDeg | Angle in degrees. |
Compute the distance between two points.
a_point1 | First point. | |
a_point2 | Second point. |
Compute the squared distance between two points.
a_point1 | First point. | |
a_point2 | Second point. |
Divide a vector by a scalar.
a_value | Scalar. | |
a_vector | Input vector. |
Divide a scalar by components of a 3D vector and return vector
a_value | Scalar. | |
a_vector | Input vector. |
Compute the dot product between two vectors.
a_vector1 | Vector1. | |
a_vector2 | Vector2. |
bool inline cEqualPoints | ( | const cVector3d & | v1, | |
const cVector3d & | v2, | |||
const double | epsilon = CHAI_SMALL | |||
) | [inline] |
Determine whether two vectors represent the same point.
v1 | First point. | |
v2 | Second point. | |
epsilon | Two points will be considered equal if each component is within epsilon units. Defaults to CHAI_SMALL. |
cMatrix3d cIdentity3d | ( | void | ) | [inline] |
Return the Identity Matrix .
int cIntersectionSegmentSphere | ( | cVector3d & | a_segmentPointA, | |
cVector3d & | a_segmentPointB, | |||
cVector3d & | a_spherePos, | |||
double & | a_sphereRadius, | |||
cVector3d & | a_collisionPoint0, | |||
cVector3d & | a_collisionNormal0, | |||
cVector3d & | a_collisionPoint1, | |||
cVector3d & | a_collisionNormal1 | |||
) | [inline] |
Returns the number of intersection points between a segment AB and a sphere of radius R.
The number of points can be 0, 1 or 2.
If two intersection points are detected, collisionPoint0 will be the closest one to segmentPointA of segment AB.
a_segmentPointA | First point of segment AB. | |
a_segmentPointB | Second point of segment AB. | |
a_spherePos | Position of sphere center. | |
a_sphereRadius | Radius of sphere. | |
a_collisionPoint0 | Intersection point 0 if detected. | |
a_collisionNormal0 | Surface normal at intersection point 0 | |
a_collisionPoint1 | Intersection point 1 if detected. | |
a_collisionNormal1 | Surface normal at intersection point 1 |
int cIntersectionSegmentToplessCylinder | ( | cVector3d & | a_segmentPointA, | |
cVector3d & | a_segmentPointB, | |||
cVector3d & | a_cylinderPointA, | |||
cVector3d & | a_cylinderPointB, | |||
double & | a_cylinderRadius, | |||
cVector3d & | a_collisionPoint0, | |||
cVector3d & | a_collisionNormal0, | |||
cVector3d & | a_collisionPoint1, | |||
cVector3d & | a_collisionNormal1 | |||
) | [inline] |
Returns the number of intersection points between a segment AB and a open topless cylinder of radius R.
The number of intersection points can be 0, 1 or 2.
If two intersection points are detected, collisionPoint0 will correspond to the point nearest to segmentPointA of segment AB.
a_segmentPointA | First point of segment AB | |
a_segmentPointB | Second point of segment AB | |
a_cylinderPointA | Extremity point A of cylinder. | |
a_cylinderPointB | Extremity point B of cylinder. | |
a_cylinderRadius | Radius of cylinder. | |
a_collisionPoint0 | Intersection point 0 if detected | |
a_collisionNormal0 | Surface normal at intersection point 0 | |
a_collisionPoint1 | Intersection point 1 if detected | |
a_collisionNormal1 | Surface normal at intersection point 1 |
bool cIntersectionSegmentTriangle | ( | cVector3d & | a_segmentPointA, | |
cVector3d & | a_segmentPointB, | |||
cVector3d & | a_triangleVertex0, | |||
cVector3d & | a_triangleVertex1, | |||
cVector3d & | a_triangleVertex2, | |||
cVector3d & | a_collisionPoint, | |||
cVector3d & | a_collisionNormal | |||
) | [inline] |
Returns true if segment AB intersects triangle defined by its three vertices (V0, V1, V2).
a_segmentPointA | First point of segment AB | |
a_segmentPointB | Second point of segment AB | |
a_triangleVertex0 | Vertex 0 of triangle | |
a_triangleVertex1 | Vertex 1 of triangle | |
a_triangleVertex2 | Vertex 2 of triangle | |
a_collisionPoint | If a collision occurs, collision point is returned here | |
a_collisionNormal | Surface normal at the point where the collision occurred |
Compute the inverse of a matrix.
a_matrix | Input matrix. |
T cLerp | ( | const double & | a_level, | |
const T & | a_value1, | |||
const T & | a_value2 | |||
) | [inline] |
Linear interpolation from value0 (when a=0) to value1 (when a=1).
a_level | Interpolation parameter. | |
a_value1 | First value. | |
a_value2 | Second value. |
T cMax | ( | const T | a_value1, | |
const T | a_value2 | |||
) | [inline] |
Compute maximum between two values.
a_value1 | First value. | |
a_value2 | Second value. |
T cMax3 | ( | const T & | a_value1, | |
const T & | a_value2, | |||
const T & | a_value3 | |||
) | [inline] |
Compute maximum of 3 values.
a_value1 | First value. | |
a_value2 | Second value. | |
a_value3 | Third value. |
T cMax3Abs | ( | const T & | a_value1, | |
const T & | a_value2, | |||
const T & | a_value3 | |||
) | [inline] |
Compute maximum of absolute values of 3 values.
a_value1 | First value. | |
a_value2 | Second value. | |
a_value3 | Third value. |
T cMaxAbs | ( | const T | a_value1, | |
const T | a_value2 | |||
) | [inline] |
Compute maximum of absolute values of 2 numbers.
a_value1 | First value. | |
a_value2 | Second value. |
T cMin | ( | const T | a_value1, | |
const T | a_value2 | |||
) | [inline] |
Compute minimum between two values.
a_value1 | First value. | |
a_value2 | Second value. |
T cMin3 | ( | const T & | a_value1, | |
const T & | a_value2, | |||
const T & | a_value3 | |||
) | [inline] |
Return minimum of 3 values.
a_value1 | First value. | |
a_value2 | Second value. | |
a_value3 | Third value. |
T cMin3Abs | ( | const T & | a_value1, | |
const T & | a_value2, | |||
const T & | a_value3 | |||
) | [inline] |
Compute minimum of absolute values of 3 values.
a_value1 | First value. | |
a_value2 | Second value. | |
a_value3 | Third value. |
T cMinAbs | ( | const T | a_value1, | |
const T | a_value2 | |||
) | [inline] |
Compute minimum of absolute values of 2 values.
a_value1 | First value. | |
a_value2 | Second value. |
Compute the multiplication of a matrix and a vector.
a_matrix | Input matrix. | |
a_vector | Input vector. |
Compute the multiplication between two matrices.
a_matrix1 | First matrix. | |
a_matrix2 | Second matrix. |
Multiply a vector by a scalar.
a_value | Scalar. | |
a_vector | Input vector. |
Compute the negated vector of a input vector.
a_vector | Input vector. |
Compute the normalized vector (length = 1) of an input vector.
a_vector | Input vector. |
bool cPositiveBound | ( | const double & | a_value, | |
const double & | a_boundMax | |||
) | [inline] |
Check if value is strictly positive and less than maxBound in case maxBound is positive.
a_value | Value to be checked. | |
a_boundMax | Positive bound. |
Project a vector V0 onto a second vector V1.
a_vector0 | Vector 0. | |
a_vector1 | Vector 1. |
cVector3d cProjectPointOnLine | ( | const cVector3d & | a_point, | |
const cVector3d & | a_pointOnLine, | |||
const cVector3d & | a_directionOfLine | |||
) | [inline] |
Compute the projection of a point on a line. the line is expressed by a point located on the line and a direction vector.
a_point | Point to project on the line. | |
a_pointOnLine | Point located on the line | |
a_directionOfLine | Vector expressing the direction of the line |
void cProjectPointOnPlane | ( | const cVector3d & | a_point, | |
const cVector3d & | a_planePoint0, | |||
const cVector3d & | a_planePoint1, | |||
const cVector3d & | a_planePoint2, | |||
double & | a_v01, | |||
double | a_v02 | |||
) | [inline] |
Projects a 3D point on a plane composed of three points.
This function returns two parameters v01 and v02 which correspond to the factord which express the following relation: projectedPoint = planePoint0 + v01 * V01 + v02 * V02
where:
V01 = planePoint1 - planePoint0, and
V02 = planePoint2 - planePoint0
a_point | Point to project on plane. | |
a_planePoint0 | Point 0 on plane. | |
a_planePoint1 | Point 1 on plane. | |
a_planePoint2 | Point 2 on plane. | |
a_v01 | returned factor. | |
a_v02 | returned factor. |
cVector3d cProjectPointOnPlane | ( | const cVector3d & | a_point, | |
const cVector3d & | a_planePoint0, | |||
const cVector3d & | a_planePoint1, | |||
const cVector3d & | a_planePoint2 | |||
) | [inline] |
Compute the projection of a point on a plane. the plane is expressed by a set of three points.
a_point | Point to project on plane. | |
a_planePoint0 | Point 0 on plane. | |
a_planePoint1 | Point 1 on plane. | |
a_planePoint2 | Point 2 on plane. |
cVector3d cProjectPointOnPlane | ( | const cVector3d & | a_point, | |
const cVector3d & | a_planePoint, | |||
const cVector3d & | n | |||
) | [inline] |
Compute the projection of a point on a plane. the plane is expressed by a point and a surface normal.
a_point | Point to project on plane. | |
a_planePoint | Point on plane. | |
n | Plane normal. |
cVector3d cProjectPointOnSegment | ( | const cVector3d & | a_point, | |
const cVector3d & | a_segmentPointA, | |||
const cVector3d & | a_segmentPointB | |||
) | [inline] |
Compute the projection of a point on a segment. the segment is described by its two extremity points.
a_point | Point that is projected. | |
a_segmentPointA | Point A of segment. | |
a_segmentPointB | Point B of segment. |
double cRadToDeg | ( | const double & | a_angleRad | ) | [inline] |
Convert an angle from radians to degrees
a_angleRad | Angle in radians. |
cMatrix3d cRotate | ( | const cMatrix3d & | a_matrix, | |
const cVector3d & | a_axis, | |||
const double & | a_angleRad | |||
) | [inline] |
Compute the rotation of a matrix around an axis and an angle.
a_matrix | Input matrix. | |
a_axis | Axis of rotation. | |
a_angleRad | Rotation angle in Radian. |
Compute a rotation matrix given a rotation axis and an angle.
a_axis | Axis of rotation. | |
a_angleRad | Rotation angle in Radian. |
double cSinDeg | ( | const double & | a_angleDeg | ) | [inline] |
Compute the sine of an angle defined in degrees.
a_angleDeg | Angle in degrees. |
double cSinRad | ( | const double & | a_value | ) | [inline] |
Return the sine of an angle defined in radians.
a_value | Angle in radians. |
double cSqr | ( | const double & | a_value | ) | [inline] |
Compute the square of a scalar.
a_value | Input value. |
Compute the subtraction between two vectors.
Result = Vector1 - Vector2
a_vector1 | First vector. | |
a_vector2 | Second vector. |
void cSwap | ( | T & | a_value1, | |
T & | a_value2 | |||
) | [inline] |
Swap two elements.
a_value1 | First value. | |
a_value2 | Second value. |
double cTanDeg | ( | const double & | a_angleDeg | ) | [inline] |
Compute the tangent of an angle defined in degrees.
a_angleDeg | Angle in degrees. |
double cTanRad | ( | const double & | a_value | ) | [inline] |
Return the tangent of an angle defined in radians.
a_value | Angle in radians. |
Compute the transpose of a matrix
a_matrix | Input matrix. |
bool cZero | ( | const double & | a_value | ) | [inline] |
Check if value is equal or near zero.
a_value | Value to be checked. |