# D:/CHAI3D/build-2-0-0/2.0.0/win32/src/math/CMaths.h File Reference

Math
General Utility Functions. More...

`#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)

## Detailed Description

Math
General Utility Functions.

## Function Documentation

template<class T >

T cAbs | ( | const T | a_value | ) | `[inline]`

Compute absolute value.

Parameters:

  | a_value | Input value.

Returns:
  Return the absolute value of 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

Parameters:

  | a_vector1 | First vector.
  | a_vector2 | Second vector.
  | a_vector3 | Third vector.

Returns:
  Return the addition of all three vectors.

cVector3d cAdd | ( | const cVector3d & | a_vector1,
|  | const cVector3d & | a_vector2 |
| ) |  |  | `[inline]`

Compute the addition between two vectors.
Result = Vector1 + Vector2

Parameters:

  | a_vector1 | First vector.
  | a_vector2 | Second vector.

Returns:
  Return the addition of both vectors.

double cAngle | ( | const cVector3d & | a_vector0,
|  | const cVector3d & | a_vector1 |
| ) |  |  | `[inline]`

Compute the angle in radians between two vectors.

Parameters:

  | a_vector0 | Input vector.
  | a_vector1 | Input vector.

Returns:
  Returns the angle in radians between the input vectors.

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

Parameters:

  | a_point | Test point
  | box_min | Minimum coordinate in the boundary box
  | box_max | Maximum coordinate in the boundary box

Returns:
  Returns true if p is in [box_min,box_max], inclusive

template<class T >

T cClamp | ( | const T | a_value,
|  | const T | a_low,
|  | const T | a_high |
| ) |  |  | `[inline]`

Clamp the input to the specified range.

Parameters:

  | a_value | Input value.
  | a_low | Low boundary.
  | a_high | High boundary.

Returns:
  Return clamped value.

Note that this function should not be modified to take inputs by reference.

template<class T >

T cClamp0 | ( | T & | a_value | ) | `[inline]`

Clamp the input to the range 0 - infinity.

Parameters:

  | a_value | Input value.

Returns:
  Return clamped value.

double cClamp01 | ( | double & | a_value | ) | `[inline]`

Clamp the input to the range [0,1].

Parameters:

  | a_value | Input value of type double.

Returns:
  Return clamped value.

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.

Parameters:

  | a_surfacePoint0 | Point 0 of surface.
  | a_surfacePoint1 | Point 1 of surface.
  | a_surfacePoint2 | Point 2 of surface.

Returns:
  Return surface normal.

template<class T , class V >

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].

Parameters:

  | a_value | Input value.
  | a_low | Low boundary.
  | a_high | High boundary.

Returns:
  Return true if value is in the rage of [low, high] and false otherwise.

double cCosAngle | ( | const cVector3d & | a_vector0,
|  | const cVector3d & | a_vector1 |
| ) |  |  | `[inline]`

Compute the cosine of the angle between two vectors.

Parameters:

  | a_vector0 | Input vector.
  | a_vector1 | Input vector.

Returns:
  Returns the cosine of the angle between the input vectors.

double cCosDeg | ( | const double & | a_angleDeg | ) | `[inline]`

Compute the cosine of an angle defined in degrees.

Parameters:

  | a_angleDeg | Angle in degrees.

Returns:
  Return the cosine of angle.

double cCosRad | ( | const double & | a_angleRad | ) | `[inline]`

Return the cosine of an angle defined in radians.

Parameters:

  | a_angleRad | Angle in radians.

Returns:
  Return the cosine of angle.

cVector3d cCross | ( | const cVector3d & | a_vector1,
|  | const cVector3d & | a_vector2 |
| ) |  |  | `[inline]`

Compute the cross product between two 3D vectors.

Parameters:

  | a_vector1 | Vector1.
  | a_vector2 | Vector2.

Returns:
  Returns the cross product between Vector1 and Vector2.

double cDegToRad | ( | const double & | a_angleDeg | ) | `[inline]`

Convert an angle from degrees to radians.

Parameters:

  | a_angleDeg | Angle in degrees.

Returns:
  Return angle in radians.

double cDistance | ( | const cVector3d & | a_point1,
|  | const cVector3d & | a_point2 |
| ) |  |  | `[inline]`

Compute the distance between two points.

Parameters:

  | a_point1 | First point.
  | a_point2 | Second point.

Returns:
  Return distance between points

double cDistanceSq | ( | const cVector3d & | a_point1,
|  | const cVector3d & | a_point2 |
| ) |  |  | `[inline]`

Compute the squared distance between two points.

Parameters:

  | a_point1 | First point.
  | a_point2 | Second point.

Returns:
  Return squared distance between points.

cVector3d cDiv | ( | const double & | a_value,
|  | const cVector3d & | a_vector |
| ) |  |  | `[inline]`

Divide a vector by a scalar.

Parameters:

  | a_value | Scalar.
  | a_vector | Input vector.

Returns:
  Returns result of division.

cVector3d cDivVect | ( | const double & | a_value,
|  | const cVector3d & | a_vector |
| ) |  |  | `[inline]`

Divide a scalar by components of a 3D vector and return vector

Parameters:

  | a_value | Scalar.
  | a_vector | Input vector.

Returns:
  Returns a vector. result = value / vector.

double cDot | ( | const cVector3d & | a_vector1,
|  | const cVector3d & | a_vector2 |
| ) |  |  | `[inline]`

Compute the dot product between two vectors.

Parameters:

  | a_vector1 | Vector1.
  | a_vector2 | Vector2.

Returns:
  Returns the dot product between between both vectors.

bool inline cEqualPoints | ( | const cVector3d & | v1,
|  | const cVector3d & | v2,
|  | const double | epsilon = `CHAI_SMALL` |
| ) |  |  | `[inline]`

Determine whether two vectors represent the same point.

Parameters:

  | v1 | First point.
  | v2 | Second point.
  | epsilon | Two points will be considered equal if each component is within epsilon units. Defaults to CHAI_SMALL.

Returns:
  Return whether the two vectors represent the same point.

cMatrix3d cIdentity3d | ( | void |  | ) | `[inline]`

Return the Identity Matrix .

Returns:
  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.

Parameters:

  | 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

Returns:
  Returns the number of intersection points found.

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.

Parameters:

  | 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

Returns:
  Returns the number of intersection points found

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).

Parameters:

  | 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

Returns:
  Return true id collision occurs, otherwise return false

cMatrix3d cInv | ( | const cMatrix3d & | a_matrix | ) | `[inline]`

Compute the inverse of a matrix.

Parameters:

  | a_matrix | Input matrix.

Returns:
  Returns the inverse of the input matrix.

template<class T >

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).

Parameters:

  | a_level | Interpolation parameter.
  | a_value1 | First value.
  | a_value2 | Second value.

Returns:
  Return an interpolated result: (1-a_level) * a_value1 + a_level * a_value2

template<class T >

T cMax | ( | const T | a_value1,
|  | const T | a_value2 |
| ) |  |  | `[inline]`

Compute maximum between two values.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.

Returns:
  Return maximum of a_value1 and a_value2.

Note that this function should not be modified to take inputs by reference.

template<class T >

T cMax3 | ( | const T & | a_value1,
|  | const T & | a_value2,
|  | const T & | a_value3 |
| ) |  |  | `[inline]`

Compute maximum of 3 values.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.
  | a_value3 | Third value.

Returns:
  Return maximum of a_value1, a_value2 and a_value3.

template<class T >

T cMax3Abs | ( | const T & | a_value1,
|  | const T & | a_value2,
|  | const T & | a_value3 |
| ) |  |  | `[inline]`

Compute maximum of absolute values of 3 values.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.
  | a_value3 | Third value.

Returns:
  Return max(abs(p), abs(q), abs(r)).

template<class T >

T cMaxAbs | ( | const T | a_value1,
|  | const T | a_value2 |
| ) |  |  | `[inline]`

Compute maximum of absolute values of 2 numbers.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.

Returns:
  Return max(abs(p), abs(q)).

Note that this function should not be modified to take inputs by reference.

template<class T >

T cMin | ( | const T | a_value1,
|  | const T | a_value2 |
| ) |  |  | `[inline]`

Compute minimum between two values.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.

Returns:
  Return minimum of a_value1 and a_value2.

Note that this function should not be modified to take inputs by reference.

template<class T >

T cMin3 | ( | const T & | a_value1,
|  | const T & | a_value2,
|  | const T & | a_value3 |
| ) |  |  | `[inline]`

Return minimum of 3 values.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.
  | a_value3 | Third value.

Returns:
  Return minimum of a_value1, a_value2 and a_value3.

template<class T >

T cMin3Abs | ( | const T & | a_value1,
|  | const T & | a_value2,
|  | const T & | a_value3 |
| ) |  |  | `[inline]`

Compute minimum of absolute values of 3 values.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.
  | a_value3 | Third value.

Returns:
  Return min(abs(p), abs(q), abs(r)).

template<class T >

T cMinAbs | ( | const T | a_value1,
|  | const T | a_value2 |
| ) |  |  | `[inline]`

Compute minimum of absolute values of 2 values.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.

Returns:
  Return min(abs(p), abs(q)).

Note that this function should not be modified to take inputs by reference.

cVector3d cMul | ( | const cMatrix3d & | a_matrix,
|  | const cVector3d & | a_vector |
| ) |  |  | `[inline]`

Compute the multiplication of a matrix and a vector.

Parameters:

  | a_matrix | Input matrix.
  | a_vector | Input vector.

Returns:
  Returns the multiplication of the matrix and vector.

cMatrix3d cMul | ( | const cMatrix3d & | a_matrix1,
|  | const cMatrix3d & | a_matrix2 |
| ) |  |  | `[inline]`

Compute the multiplication between two matrices.

Parameters:

  | a_matrix1 | First matrix.
  | a_matrix2 | Second matrix.

Returns:
  Returns multiplication of /e matrix1 * /e matrix2.

cVector3d cMul | ( | const double & | a_value,
|  | const cVector3d & | a_vector |
| ) |  |  | `[inline]`

Multiply a vector by a scalar.

Parameters:

  | a_value | Scalar.
  | a_vector | Input vector.

Returns:
  Returns result of multiplication.

cVector3d cNegate | ( | const cVector3d & | a_vector | ) | `[inline]`

Compute the negated vector of a input vector.

Parameters:

  | a_vector | Input vector.

Returns:
  Return (-a_vector).

cVector3d cNormalize | ( | const cVector3d & | a_vector | ) | `[inline]`

Compute the normalized vector (length = 1) of an input vector.

Parameters:

  | a_vector | Input vector.

Returns:
  Returns the normalized 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.

Parameters:

  | a_value | Value to be checked.
  | a_boundMax | Positive bound.

Returns:
  Return true if value is greater than 0 and either maxBound is negative, or value is less thanmaxBound. Otherwise return false.

cVector3d cProject | ( | const cVector3d & | a_vector0,
|  | const cVector3d & | a_vector1 |
| ) |  |  | `[inline]`

Project a vector V0 onto a second vector V1.

Parameters:

  | a_vector0 | Vector 0.
  | a_vector1 | Vector 1.

Returns:
  Returns the projection of V0 onto V1.

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.

Parameters:

  | a_point | Point to project on the line.
  | a_pointOnLine | Point located on the line
  | a_directionOfLine | Vector expressing the direction of the line

Returns:
  Returns the projection of a_point on 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

Parameters:

  | 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.

Parameters:

  | 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.

Returns:
  Returns the projection of point 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.

Parameters:

  | a_point | Point to project on plane.
  | a_planePoint | Point on plane.
  | n | Plane normal.

Returns:
  Returns the projection of point on plane.

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.

Parameters:

  | a_point | Point that is projected.
  | a_segmentPointA | Point A of segment.
  | a_segmentPointB | Point B of segment.

Returns:
  Returns the projection of a_point on the segment.

double cRadToDeg | ( | const double & | a_angleRad | ) | `[inline]`

Convert an angle from radians to degrees

Parameters:

  | a_angleRad | Angle in radians.

Returns:
  Return angle in degrees.

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.

Parameters:

  | a_matrix | Input matrix.
  | a_axis | Axis of rotation.
  | a_angleRad | Rotation angle in Radian.

Returns:
  Returns input matrix after rotation.

cMatrix3d cRotMatrix | ( | const cVector3d & | a_axis,
|  | const double & | a_angleRad |
| ) |  |  | `[inline]`

Compute a rotation matrix given a rotation axis and an angle.

Parameters:

  | a_axis | Axis of rotation.
  | a_angleRad | Rotation angle in Radian.

Returns:
  Returns a rotation matrix.

double cSinDeg | ( | const double & | a_angleDeg | ) | `[inline]`

Compute the sine of an angle defined in degrees.

Parameters:

  | a_angleDeg | Angle in degrees.

Returns:
  Return the sine of angle.

double cSinRad | ( | const double & | a_value | ) | `[inline]`

Return the sine of an angle defined in radians.

Parameters:

  | a_value | Angle in radians.

Returns:
  Return the sine of angle a_value.

double cSqr | ( | const double & | a_value | ) | `[inline]`

Compute the square of a scalar.

Parameters:

  | a_value | Input value.

Returns:
  Return (/e value * /e value).

cVector3d cSub | ( | const cVector3d & | a_vector1,
|  | const cVector3d & | a_vector2 |
| ) |  |  | `[inline]`

Compute the subtraction between two vectors.
Result = Vector1 - Vector2

Parameters:

  | a_vector1 | First vector.
  | a_vector2 | Second vector.

Returns:
  Return result of subtraction.

template<class T >

void cSwap | ( | T & | a_value1,
|  | T & | a_value2 |
| ) |  |  | `[inline]`

Swap two elements.

Parameters:

  | a_value1 | First value.
  | a_value2 | Second value.

double cTanDeg | ( | const double & | a_angleDeg | ) | `[inline]`

Compute the tangent of an angle defined in degrees.

Parameters:

  | a_angleDeg | Angle in degrees.

Returns:
  Return the tangent of angle.

double cTanRad | ( | const double & | a_value | ) | `[inline]`

Return the tangent of an angle defined in radians.

Parameters:

  | a_value | Angle in radians.

Returns:
  Return the tangent of angle a_value.

cMatrix3d cTrans | ( | const cMatrix3d & | a_matrix | ) | `[inline]`

Compute the transpose of a matrix

Parameters:

  | a_matrix | Input matrix.

Returns:
  Returns the transpose of the input matrix.

bool cZero | ( | const double & | a_value | ) | `[inline]`

Check if value is equal or near zero.

Parameters:

  | a_value | Value to be checked.

Returns:
  Returns true if it's almost zero, otherwise false.

CHAI3D 2.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2009 - CHAI 3D
All Rights Reserved.