BRL-CAD
|
fundamental vector, matrix, quaternion math macros More...
Go to the source code of this file.
Macros | |
#define | _USE_MATH_DEFINES 1 |
#define | M_ XXX |
#define | M_1_2PI 0.159154943091895335768883763372514362 |
#define | M_1_PI 0.318309886183790671537767526745028724 |
#define | M_2_PI 0.636619772367581343075535053490057448 |
#define | M_2_SQRTPI 1.12837916709551257389615890312154517 |
#define | M_E 2.71828182845904523536028747135266250 |
#define | M_EULER 0.577215664901532860606512090082402431 |
#define | M_LOG2E 1.44269504088896340735992468100189214 |
#define | M_LOG10E 0.434294481903251827651128918916605082 |
#define | M_LN2 0.693147180559945309417232121458176568 |
#define | M_LN10 2.30258509299404568401799145468436421 |
#define | M_LNPI 1.14472988584940017414342735135305871 /** log_e(pi) */ |
#define | M_PI 3.14159265358979323846264338327950288 |
#define | M_2PI 6.28318530717958647692528676655900576 |
#define | M_PI_2 1.57079632679489661923132169163975144 |
#define | M_PI_3 1.04719755119659774615421446109316763 |
#define | M_PI_4 0.785398163397448309615660845819875721 |
#define | M_SQRT1_2 0.707106781186547524400844362104849039 |
#define | M_SQRT2 1.41421356237309504880168872420969808 |
#define | M_SQRT3 1.73205080756887729352744634150587237 |
#define | M_SQRTPI 1.77245385090551602729816748334114518 |
#define | DEG2RAD 0.0174532925199432957692369076848861271 |
#define | RAD2DEG 57.2957795130823208767981548141051703 |
#define | MAX_FASTF 1.0e73 /* Very close to the largest number */ |
#define | SQRT_MAX_FASTF 1.0e36 /* This squared just avoids overflow */ |
#define | SMALL_FASTF 1.0e-77 /* Anything smaller is zero */ |
#define | SQRT_SMALL_FASTF 1.0e-39 /* This squared gives zero */ |
#define | SMALL SQRT_SMALL_FASTF |
#define | INFINITY ((fastf_t)1.0e38) |
#define | VDIVIDE_TOL (1.0e-20) |
#define | VUNITIZE_TOL (1.0e-15) |
#define | ELEMENTS_PER_VECT2D 2 |
number of fastf_t's per vect2d_t More... | |
#define | ELEMENTS_PER_POINT2D 2 |
number of fastf_t's per point2d_t More... | |
#define | ELEMENTS_PER_VECT 3 |
number of fastf_t's per vect_t More... | |
#define | ELEMENTS_PER_POINT 3 |
number of fastf_t's per point_t More... | |
#define | ELEMENTS_PER_HVECT 4 |
number of fastf_t's per hvect_t (homogeneous vector) More... | |
#define | ELEMENTS_PER_HPOINT 4 |
number of fastf_t's per hpt_t (homogeneous point) More... | |
#define | ELEMENTS_PER_PLANE 4 |
number of fastf_t's per plane_t More... | |
#define | ELEMENTS_PER_MAT (ELEMENTS_PER_PLANE*ELEMENTS_PER_PLANE) |
number of fastf_t's per mat_t More... | |
#define | INVALID(n) (!((n) > -INFINITY && (n) < INFINITY)) |
#define | VINVALID(v) (INVALID((v)[X]) || INVALID((v)[Y]) || INVALID((v)[Z])) |
#define | V2INVALID(v) (INVALID((v)[X]) || INVALID((v)[Y])) |
#define | HINVALID(v) (INVALID((v)[X]) || INVALID((v)[Y]) || INVALID((v)[Z]) || INVALID((v)[W])) |
#define | NEAR_ZERO(val, epsilon) (((val) > -epsilon) && ((val) < epsilon)) |
#define | VNEAR_ZERO(v, tol) |
#define | V2NEAR_ZERO(v, tol) (NEAR_ZERO(v[X], tol) && NEAR_ZERO(v[Y], tol)) |
#define | HNEAR_ZERO(v, tol) |
#define | ZERO(_a) NEAR_ZERO((_a), SMALL_FASTF) |
#define | VZERO(_a) VNEAR_ZERO((_a), SMALL_FASTF) |
#define | V2ZERO(_a) V2NEAR_ZERO((_a), SMALL_FASTF) |
#define | HZERO(_a) HNEAR_ZERO((_a), SMALL_FASTF) |
#define | NEAR_EQUAL(_a, _b, _tol) NEAR_ZERO((_a) - (_b), (_tol)) |
#define | VNEAR_EQUAL(_a, _b, _tol) |
#define | V2NEAR_EQUAL(a, b, tol) |
#define | HNEAR_EQUAL(_a, _b, _tol) |
#define | EQUAL(_a, _b) NEAR_EQUAL((_a), (_b), SMALL_FASTF) |
#define | VEQUAL(_a, _b) VNEAR_EQUAL((_a), (_b), SMALL_FASTF) |
#define | V2EQUAL(_a, _b) V2NEAR_EQUAL((_a), (_b), SMALL_FASTF) |
Return truthfully whether two 2D vectors are equal within a minimum representation tolerance. More... | |
#define | HEQUAL(_a, _b) HNEAR_EQUAL((_a), (_b), SMALL_FASTF) |
Return truthfully whether two higher degree vectors are equal within a minimum representation tolerance. More... | |
#define | DIST_PNT_PLANE(_pt, _pl) (VDOT(_pt, _pl) - (_pl)[W]) |
Compute distance from a point to a plane. More... | |
#define | DIST_PNT_PNT_SQ(_a, _b) |
Compute distance between two points. More... | |
#define | DIST_PNT_PNT(_a, _b) sqrt(DIST_PNT_PNT_SQ(_a, _b)) |
#define | DIST_PNT2_PNT2_SQ(_a, _b) |
Compute distance between two 2D points. More... | |
#define | DIST_PNT2_PNT2(_a, _b) sqrt(DIST_PNT2_PNT2_SQ(_a, _b)) |
#define | MAT_DELTAS(_m, _x, _y, _z) |
set translation values of 4x4 matrix with x, y, z values. More... | |
#define | MAT_DELTAS_VEC(_m, _v) MAT_DELTAS(_m, (_v)[X], (_v)[Y], (_v)[Z]) |
set translation values of 4x4 matrix from a vector. More... | |
#define | MAT_DELTAS_VEC_NEG(_m, _v) MAT_DELTAS(_m, -(_v)[X], -(_v)[Y], -(_v)[Z]) |
set translation values of 4x4 matrix from a reversed vector. More... | |
#define | MAT_DELTAS_GET(_v, _m) |
get translation values of 4x4 matrix to a vector. More... | |
#define | MAT_DELTAS_GET_NEG(_v, _m) |
get translation values of 4x4 matrix to a vector, reversed. More... | |
#define | MAT_DELTAS_ADD(_m, _x, _y, _z) |
increment translation elements in a 4x4 matrix with x, y, z values. More... | |
#define | MAT_DELTAS_ADD_VEC(_m, _v) |
increment translation elements in a 4x4 matrix from a vector. More... | |
#define | MAT_DELTAS_SUB(_m, _x, _y, _z) |
decrement translation elements in a 4x4 matrix with x, y, z values. More... | |
#define | MAT_DELTAS_SUB_VEC(_m, _v) |
decrement translation elements in a 4x4 matrix from a vector. More... | |
#define | MAT_DELTAS_MUL(_m, _x, _y, _z) |
decrement translation elements in a 4x4 matrix with x, y, z values. More... | |
#define | MAT_DELTAS_MUL_VEC(_m, _v) |
decrement translation elements in a 4x4 matrix from a vector. More... | |
#define | MAT_SCALE(_m, _x, _y, _z) |
set scale of 4x4 matrix from xyz. More... | |
#define | MAT_SCALE_VEC(_m, _v) |
set scale of 4x4 matrix from vector. More... | |
#define | MAT_SCALE_ALL(_m, _s) (_m)[MSA] = (_s) |
set uniform scale of 4x4 matrix from scalar. More... | |
#define | MAT_SCALE_ADD(_m, _x, _y, _z) |
add to scaling elements in a 4x4 matrix from xyz. More... | |
#define | MAT_SCALE_ADD_VEC(_m, _v) |
add to scaling elements in a 4x4 matrix from vector. More... | |
#define | MAT_SCALE_SUB(_m, _x, _y, _z) |
subtract from scaling elements in a 4x4 matrix from xyz. More... | |
#define | MAT_SCALE_SUB_VEC(_m, _v) |
subtract from scaling elements in a 4x4 matrix from vector. More... | |
#define | MAT_SCALE_MUL(_m, _x, _y, _z) |
multiply scaling elements in a 4x4 matrix from xyz. More... | |
#define | MAT_SCALE_MUL_VEC(_m, _v) |
multiply scaling elements in a 4x4 matrix from vector. More... | |
#define | MAT_ZERO(m) |
Zero a matrix. More... | |
#define | MAT_IDN(m) |
Set matrix to identity. More... | |
#define | MAT_TRANSPOSE(t, m) |
set t to the transpose of matrix m More... | |
#define | MAT_COPY(c, m) |
Copy a matrix ‘m’ into ‘c’. More... | |
#define | VSET(o, a, b, c) |
Set 3D vector at ‘o’ to have coordinates ‘a’, ‘b’, and ‘c’. More... | |
#define | V2SET(o, a, b) |
Set 2D vector at ‘o’ to have coordinates ‘a’ and ‘b’. More... | |
#define | HSET(o, a, b, c, d) |
Set 4D vector at ‘o’ to homogeneous coordinates ‘a’, ‘b’, ‘c’, and ‘d’. More... | |
#define | VSETALL(v, s) |
Set all elements of 3D vector to same scalar value. More... | |
#define | V2SETALL(v, s) |
Set 2D vector elements to same scalar value. More... | |
#define | HSETALL(v, s) |
Set 4D vector elements to same scalar value. More... | |
#define | VSETALLN(v, s, n) |
Set all elements of N-vector to same scalar value. More... | |
#define | VMOVE(o, v) |
Transfer 3D vector at ‘v’ to vector at ‘o’. More... | |
#define | V2MOVE(o, v) |
Move a 2D vector at ‘v’ to vector at ‘o’. More... | |
#define | HMOVE(o, v) |
Move a homogeneous 4-tuple at ‘v’ to ‘o’. More... | |
#define | VMOVEN(o, v, n) |
Transfer vector of length ‘n’ at ‘v’ to vector at ‘o’. More... | |
#define | VREVERSE(o, v) |
Reverse the direction of 3D vector ‘v’ and store it in ‘o’. More... | |
#define | V2REVERSE(o, v) |
Reverse the direction of 2D vector ‘v’ and store it in ‘o’. More... | |
#define | HREVERSE(o, v) |
Same as VREVERSE, but for a 4-tuple. Also useful on plane_t objects. More... | |
#define | VADD2(o, a, b) |
Add 3D vectors at ‘a’ and ‘b’, store result at ‘o’. More... | |
#define | V2ADD2(o, a, b) |
Add 2D vectors at ‘a’ and ‘b’, store result at ‘o’. More... | |
#define | HADD2(o, a, b) |
Add 4D vectors at ‘a’ and ‘b’, store result at ‘o’. More... | |
#define | VADD2N(o, a, b, n) |
Add vectors of length ‘n’ at ‘a’ and ‘b’, store result at ‘o’. More... | |
#define | VSUB2(o, a, b) |
Subtract 3D vector at ‘b’ from vector at ‘a’, store result at ‘o’. More... | |
#define | V2SUB2(o, a, b) |
Subtract 2D vector at ‘b’ from vector at ‘a’, store result at ‘o’. More... | |
#define | HSUB2(o, a, b) |
Subtract 4D vector at ‘b’ from vector at ‘a’, store result at ‘o’. More... | |
#define | VSUB2N(o, a, b, n) |
Subtract ‘n’ length vector at ‘b’ from ‘n’ length vector at ‘a’, store result at ‘o’. More... | |
#define | VSUB3(o, a, b, c) |
3D Vectors: O = A - B - C More... | |
#define | V2SUB3(o, a, b, c) |
2D Vectors: O = A - B - C More... | |
#define | HSUB3(o, a, b, c) |
4D Vectors: O = A - B - C More... | |
#define | VSUB3N(o, a, b, c, n) |
Vectors: O = A - B - C for vectors of length ‘n’. More... | |
#define | VADD3(o, a, b, c) |
Add 3 3D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’. More... | |
#define | V2ADD3(o, a, b, c) |
Add 3 2D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’. More... | |
#define | HADD3(o, a, b, c) |
Add 3 4D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’. More... | |
#define | VADD3N(o, a, b, c, n) |
Add 3 vectors of length ‘n’ at ‘a’, ‘b’, and ‘c’, store result at ‘o’. More... | |
#define | VADD4(o, a, b, c, d) |
Add 4 vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’. More... | |
#define | V2ADD4(o, a, b, c, d) |
Add 4 2D vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’. More... | |
#define | HADD4(o, a, b, c, d) |
Add 4 4D vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’. More... | |
#define | VADD4N(o, a, b, c, d, n) |
Add 4 ‘n’ length vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’. More... | |
#define | VSCALE(o, v, s) |
Scale 3D vector at ‘v’ by scalar ‘s’, store result at ‘o’. More... | |
#define | V2SCALE(o, v, s) |
Scale 2D vector at ‘v’ by scalar ‘s’, store result at ‘o’. More... | |
#define | HSCALE(o, v, s) |
Scale 4D vector at ‘v’ by scalar ‘s’, store result at ‘o’. More... | |
#define | VSCALEN(o, v, s, n) |
Scale vector of length ‘n’ at ‘v’ by scalar ‘s’, store result at ‘o’. More... | |
#define | VUNITIZE(v) |
Normalize vector ‘v’ to be a unit vector. More... | |
#define | V2UNITIZE(v) |
Normalize 2D vector ‘v’ to be a unit vector. More... | |
#define | VADD2SCALE(o, a, b, s) |
Find the sum of two points, and scale the result. Often used to find the midpoint. More... | |
#define | VADD2SCALEN(o, a, b, s, n) |
Find the sum of two vectors of length ‘n’, and scale the result by ‘s’. Often used to find the midpoint. More... | |
#define | VSUB2SCALE(o, a, b, s) |
Find the difference between two points, and scale result. Often used to compute bounding sphere radius given rpp points. More... | |
#define | VSUB2SCALEN(o, a, b, s, n) |
Find the difference between two vectors of length ‘n’, and scale result by ‘s’. More... | |
#define | VCOMB3(o, a, b, c, d, e, f) |
Combine together three vectors, all scaled by scalars. More... | |
#define | VCOMB3N(o, a, b, c, d, e, f, n) |
Combine together three vectors of length ‘n’, all scaled by scalars. More... | |
#define | VCOMB2(o, sa, va, sb, vb) |
Combine together 2 vectors, both scaled by scalars. More... | |
#define | VCOMB2N(o, sa, a, sb, b, n) |
Combine together 2 vectors of length ‘n’, both scaled by scalars. More... | |
#define | VJOIN4(a, b, c, d, e, f, g, h, i, j) |
#define | VJOIN3(o, a, sb, b, sc, c, sd, d) |
#define | VJOIN2(o, a, sb, b, sc, c) |
Compose 3D vector at ‘o’ of: Vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’ plus scalar ‘sc’ times vector at ‘c’. More... | |
#define | V2JOIN2(o, a, sb, b, sc, c) |
Compose 2D vector at ‘o’ of: Vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’ plus scalar ‘sc’ times vector at ‘c’. More... | |
#define | HJOIN2(o, a, sb, b, sc, c) |
Compose 4D vector at ‘o’ of: Vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’ plus scalar ‘sc’ times vector at ‘c’. More... | |
#define | VJOIN2N(o, a, sb, b, sc, c, n) |
#define | VJOIN1(o, a, sb, b) |
#define | V2JOIN1(o, a, sb, b) |
#define | HJOIN1(o, a, sb, b) |
#define | VJOIN1N(o, a, sb, b, n) |
#define | VBLEND2(o, sa, a, sb, b) |
Blend into vector ‘o’ scalar ‘sa’ times vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’. More... | |
#define | VBLEND2N(o, sa, a, sb, b, n) |
Blend into vector ‘o’ scalar ‘sa’ times vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’. More... | |
#define | VPROJECT(a, b, c, d) |
Project vector ‘a’ onto ‘b’ vector ‘c’ is the component of ‘a’ parallel to ‘b’ " `d' " " " " " orthogonal " ". More... | |
#define | MAGSQ(v) ((v)[X]*(v)[X] + (v)[Y]*(v)[Y] + (v)[Z]*(v)[Z]) |
Return scalar magnitude squared of vector at ‘v’. More... | |
#define | MAG2SQ(v) ((v)[X]*(v)[X] + (v)[Y]*(v)[Y]) |
#define | MAGNITUDE(v) sqrt(MAGSQ(v)) |
Return scalar magnitude of the 3D vector ‘a’. This is otherwise known as the Euclidean norm of the provided vector.. More... | |
#define | MAGNITUDE2(v) sqrt(MAG2SQ(v)) |
Return scalar magnitude of the 2D vector at ‘a’. This is otherwise known as the Euclidean norm of the provided vector.. More... | |
#define | VCROSS(o, a, b) |
Store cross product of 3D vectors at ‘a’ and ‘b’ in vector at ‘o’. More... | |
#define | V2CROSS(a, b) ((a)[X] * (b)[Y] - (a)[Y] * (b)[X]) |
#define | HCROSS(a, b, c) |
#define | VDOT(a, b) ((a)[X]*(b)[X] + (a)[Y]*(b)[Y] + (a)[Z]*(b)[Z]) |
Compute dot product of vectors at ‘a’ and ‘b’. More... | |
#define | V2DOT(a, b) ((a)[X]*(b)[X] + (a)[Y]*(b)[Y]) |
#define | HDOT(a, b) ((a)[X]*(b)[X] + (a)[Y]*(b)[Y] + (a)[Z]*(b)[Z] + (a)[W]*(b)[W]) |
#define | VLERP(o, a, b, t) |
Linearly interpolate between two 3D vectors ‘a’ and ‘b’ by interpolant ‘t’, expected in the range [0,1], with result in ‘o’. More... | |
#define | V2LERP(o, a, b, t) |
Linearly interpolate between two 2D vectors ‘a’ and ‘b’ by interpolant ‘t’, expected in the range [0,1], with result in ‘o’. More... | |
#define | HLERP(o, a, b, t) |
Linearly interpolate between two 4D vectors ‘a’ and ‘b’ by interpolant ‘t’, expected in the range [0,1], with result in ‘o’. More... | |
#define | VSUB2DOT(_pt2, _pt, _vec) |
Subtract two points to make a vector, dot with another vector. Returns the dot product scalar value. More... | |
#define | V2ARGS(a) (a)[X], (a)[Y] |
Turn a vector into comma-separated list of elements, for variable argument subroutines (e.g. printf()). More... | |
#define | V3ARGS(a) (a)[X], (a)[Y], (a)[Z] |
#define | V4ARGS(a) (a)[X], (a)[Y], (a)[Z], (a)[W] |
#define | INTCLAMP(_a) (NEAR_EQUAL((_a), rint(_a), VUNITIZE_TOL) ? rint(_a) : (_a)) |
#define | VINTCLAMP(_v) |
#define | V2INTCLAMP(_v) |
#define | HINTCLAMP(_v) |
#define | V2INTCLAMPARGS(a) INTCLAMP((a)[X]), INTCLAMP((a)[Y]) |
integer clamped versions of the previous arg macros. More... | |
#define | V3INTCLAMPARGS(a) INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z]) |
integer clamped versions of the previous arg macros. More... | |
#define | V4INTCLAMPARGS(a) INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z]), INTCLAMP((a)[W]) |
integer clamped versions of the previous arg macros. More... | |
#define | V2PRINT(a, b) fprintf(stderr, "%s (%.6f, %.6g)\n", a, V2ARGS(b)); |
Print vector name and components on stderr. More... | |
#define | VPRINT(a, b) fprintf(stderr, "%s (%.6f, %.6f, %.6f)\n", a, V3ARGS(b)); |
#define | HPRINT(a, b) fprintf(stderr, "%s (%.6f, %.6f, %.6f, %.6f)\n", a, V4ARGS(b)); |
#define | V2INTCLAMPPRINT(a, b) fprintf(stderr, "%s (%g, %g)\n", a, V2INTCLAMPARGS(b)); |
Included below are integer clamped versions of the previous print macros. More... | |
#define | VINTCLAMPPRINT(a, b) fprintf(stderr, "%s (%g, %g, %g)\n", a, V3INTCLAMPARGS(b)); |
#define | HINTCLAMPPRINT(a, b) fprintf(stderr, "%s (%g, %g, %g, %g)\n", a, V4INTCLAMPARGS(b)); |
#define | VELMUL(o, a, b) |
Vector element multiplication. Really: diagonal matrix X vect. More... | |
#define | VELMUL3(o, a, b, c) |
#define | VELDIV(o, a, b) |
Similar to VELMUL. More... | |
#define | VINVDIR(_inv, _dir) |
Given a direction vector, compute the inverses of each element. When division by zero would have occurred, mark inverse as INFINITY. More... | |
#define | MAT3X3VEC(o, mat, vec) |
Apply the 3x3 part of a mat_t to a 3-tuple. This rotates a vector without scaling it (changing its length). More... | |
#define | VEC3X3MAT(o, i, m) |
Multiply a 3-tuple by the 3x3 part of a mat_t. More... | |
#define | MAT3X2VEC(o, mat, vec) |
Apply the 3x3 part of a mat_t to a 2-tuple (Z part=0). More... | |
#define | VEC2X3MAT(o, i, m) |
Multiply a 2-tuple (Z=0) by the 3x3 part of a mat_t. More... | |
#define | MAT4X3PNT(o, m, i) |
Apply a 4x4 matrix to a 3-tuple which is an absolute Point in space. Output and input points should be separate arrays. More... | |
#define | PNT3X4MAT(o, i, m) |
Multiply an Absolute 3-Point by a full 4x4 matrix. Output and input points should be separate arrays. More... | |
#define | MAT4X4PNT(o, m, i) |
Multiply an Absolute hvect_t 4-Point by a full 4x4 matrix. Output and input points should be separate arrays. More... | |
#define | MAT4X3VEC(o, m, i) |
Apply a 4x4 matrix to a 3-tuple which is a relative Vector in space. This macro can scale the length of the vector if [15] != 1.0. Output and input vectors should be separate arrays. More... | |
#define | MAT4XSCALOR(o, m, i) |
#define | VEC3X4MAT(o, i, m) |
Multiply a Relative 3-Vector by most of a 4x4 matrix. Output and input vectors should be separate arrays. More... | |
#define | VEC2X4MAT(o, i, m) |
Multiply a Relative 2-Vector by most of a 4x4 matrix. More... | |
#define | V_MIN(r, s) if ((r) > (s)) r = (s) |
Included below are macros to update min and max X, Y, Z values to contain a point. More... | |
#define | V_MAX(r, s) if ((r) < (s)) r = (s) |
#define | VMIN(r, s) |
#define | VMAX(r, s) |
#define | VMINMAX(min, max, pt) |
#define | V2MIN(r, s) |
Included below are macros to update min and max X, Y values to contain a point. More... | |
#define | V2MAX(r, s) |
#define | V2MINMAX(min, max, pt) |
#define | CLAMP(_v, _l, _h) V_MAX((_v), (_l)); else V_MIN((_v), (_h)) |
#define | HDIVIDE(o, v) |
Divide out homogeneous parameter from hvect_t, creating vect_t. More... | |
#define | QUAT_FROM_ROT(q, r, x, y, z) |
Quaternion math definitions. More... | |
#define | QUAT_FROM_VROT(q, r, v) |
#define | QUAT_FROM_VROT_DEG(q, r, v) QUAT_FROM_VROT(q, ((r)*DEG2RAD), v) |
#define | QUAT_FROM_ROT_DEG(q, r, x, y, z) QUAT_FROM_ROT(q, ((r)*DEG2RAD), x, y, z) |
#define | QSET(a, b, c, d, e) |
Set quaternion at ‘a’ to have coordinates ‘b’, ‘c’, ‘d’, and ‘e’. More... | |
#define | QMOVE(a, b) |
Transfer quaternion at ‘b’ to quaternion at ‘a’. More... | |
#define | QADD2(a, b, c) |
Add quaternions at ‘b’ and ‘c’, store result at ‘a’. More... | |
#define | QSUB2(a, b, c) |
Subtract quaternion at ‘c’ from quaternion at ‘b’, store result at ‘a’. More... | |
#define | QSCALE(a, b, c) |
Scale quaternion at ‘b’ by scalar ‘c’, store result at ‘a’. More... | |
#define | QUNITIZE(a) |
Normalize quaternion 'a' to be a unit quaternion. More... | |
#define | QMAGSQ(a) |
Return scalar magnitude squared of quaternion at ‘a’. More... | |
#define | QMAGNITUDE(a) sqrt(QMAGSQ(a)) |
Return scalar magnitude of quaternion at ‘a’. More... | |
#define | QDOT(a, b) |
Compute dot product of quaternions at ‘a’ and ‘b’. More... | |
#define | QMUL(a, b, c) |
Compute quaternion product a = b * c. More... | |
#define | QCONJUGATE(a, b) |
Conjugate quaternion. More... | |
#define | QINVERSE(a, b) |
Multiplicative inverse quaternion. More... | |
#define | QBLEND2(a, b, c, d, e) |
Blend into quaternion ‘a’. More... | |
#define | V3RPP_DISJOINT(_l1, _h1, _l2, _h2) |
#define | V3RPP_DISJOINT_TOL(_l1, _h1, _l2, _h2, _t) |
#define | V3RPP_OVERLAP(_l1, _h1, _l2, _h2) |
#define | V3RPP_OVERLAP_TOL(_l1, _h1, _l2, _h2, _t) |
If two extents overlap within distance tolerance, return true. More... | |
#define | V3PNT_IN_RPP(_pt, _lo, _hi) |
Is the point within or on the boundary of the RPP? More... | |
#define | V3PNT_IN_RPP_TOL(_pt, _lo, _hi, _t) |
Within the distance tolerance, is the point within the RPP? More... | |
#define | V3PNT_OUT_RPP_TOL(_pt, _lo, _hi, _t) |
Is the point outside the RPP by at least the distance tolerance? This will not return true if the point is on the RPP. More... | |
#define | V3RPP1_IN_RPP2(_lo1, _hi1, _lo2, _hi2) |
Determine if one bounding box is within another. Also returns true if the boxes are the same. More... | |
#define | V3DIR_FROM_AZEL(_d, _a, _e) |
#define | AZEL_FROM_V3DIR(_a, _e, _d) |
#define | VSWAP(_a, _b) |
#define | V2SWAP(_a, _b) |
#define | HSWAP(_a, _b) |
#define | MAT_SWAP(_a, _b) |
#define | VINITALL(_v) {(_v), (_v), (_v)} |
#define | V2INITALL(_v) {(_v), (_v), (_v)} |
#define | HINITALL(_v) {(_v), (_v), (_v), (_v)} |
#define | VINIT_ZERO {0.0, 0.0, 0.0} |
#define | V2INIT_ZERO {0.0, 0.0} |
#define | HINIT_ZERO {0.0, 0.0, 0.0, 0.0} |
#define | MAT_INIT_IDN {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0} |
#define | MAT_INIT_ZERO {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} |
Typedefs | |
typedef double | fastf_t |
fastest 64-bit (or larger) floating point type More... | |
typedef fastf_t | vect2d_t[ELEMENTS_PER_VECT2D] |
2-tuple vector More... | |
typedef fastf_t * | vect2dp_t |
pointer to a 2-tuple vector More... | |
typedef fastf_t | point2d_t[ELEMENTS_PER_POINT2D] |
2-tuple point More... | |
typedef fastf_t * | point2dp_t |
pointer to a 2-tuple point More... | |
typedef fastf_t | vect_t[ELEMENTS_PER_VECT] |
3-tuple vector More... | |
typedef fastf_t * | vectp_t |
pointer to a 3-tuple vector More... | |
typedef fastf_t | point_t[ELEMENTS_PER_POINT] |
3-tuple point More... | |
typedef fastf_t * | pointp_t |
pointer to a 3-tuple point More... | |
typedef fastf_t | hvect_t[ELEMENTS_PER_HVECT] |
4-tuple vector More... | |
typedef hvect_t | quat_t |
4-element quaternion More... | |
typedef fastf_t | hpoint_t[ELEMENTS_PER_HPOINT] |
4-tuple point More... | |
typedef fastf_t | mat_t[ELEMENTS_PER_MAT] |
4x4 matrix More... | |
typedef fastf_t * | matp_t |
pointer to a 4x4 matrix More... | |
typedef fastf_t | plane_t[ELEMENTS_PER_PLANE] |
Definition of a plane equation. More... | |
typedef enum vmath_vector_component_ | vmath_vector_component |
typedef enum vmath_matrix_component_ | vmath_matrix_component |
Enumerations | |
enum | vmath_vector_component_ { X = 0 , Y = 1 , Z = 2 , W = 3 , H = W } |
enum | vmath_matrix_component_ { MSX = 0 , MDX = 3 , MSY = 5 , MDY = 7 , MSZ = 10 , MDZ = 11 , MSA = 15 } |
fundamental vector, matrix, quaternion math macros
VMATH defines commonly needed macros for 2D/3D/4D math involving:
points (point2d_t, point_t, and hpoint_t), vectors (vect2d_t, vect_t, and hvect_t), quaternions (quat_t), planes (plane_t), and 4x4 matrices (mat_t).
By default, all floating point numbers are stored in arrays using the 'fastf_t' type definition. It should be manually typedef'd to the "fastest" 64-bit floating point type available on the current hardware with at least 64 bits of precision. On 16 and 32 bit machines, this is typically "double", but on 64 bit machines, it could be "float".
Matrix array elements have the following positions in the matrix:
Note that while many people in the computer graphics field use post-multiplication with row vectors (i.e., vector * matrix * matrix ...) VMATH uses the more traditional representation of column vectors (i.e., ... matrix * matrix * vector). (The matrices in these two representations are the transposes of each other). Therefore, when transforming a vector by a matrix, pre-multiplication is used, i.e.:
view_vec = model2view_mat * model_vec
Furthermore, additional transformations are multiplied on the left, i.e.:
The most notable implication of this is the location of the "delta" (translation) values in the matrix, i.e.:
Note -
vect_t objects are 3-tuples
hvect_t objects are 4-tuples
Most of these macros require that the result be in separate storage, distinct from the input parameters, except where noted.
IMPLEMENTOR NOTES
When writing macros like this, it is very important that any variables declared within a macro code blocks start with an underscore in order to (hopefully) minimize any name conflicts with user-provided parameters, such as _f in the following example:
All of the macros that introduce a scope like the preceding example are written as do { } while (0) loops in order to require callers provide a trailing semicolon (e.g., ABC();). This helps preserve source code formatting.
Definition in file vmath.h.