BRL-CAD
|
Files | |
file | vmath.h |
fundamental vector, matrix, quaternion math macros | |
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 } |
#define M_1_2PI 0.159154943091895335768883763372514362 |
#define M_2_SQRTPI 1.12837916709551257389615890312154517 |
#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_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 */ |
Definitions about limits of floating point representation Eventually, should be tied to type of hardware (IEEE, IBM, Cray) used to implement the fastf_t type.
MAX_FASTF - Very close to the largest value that can be held by a fastf_t without overflow. Typically specified as an integer power of ten, to make the value easy to spot when printed. TODO: macro function syntax instead of constant (DEPRECATED)
SQRT_MAX_FASTF - sqrt(MAX_FASTF), or slightly smaller. Any number larger than this, if squared, can be expected to * produce an overflow. TODO: macro function syntax instead of constant (DEPRECATED)
SMALL_FASTF - Very close to the smallest value that can be represented while still being greater than zero. Any number smaller than this (and non-negative) can be considered to be zero; dividing by such a number can be expected to produce a divide-by-zero error. All divisors should be checked against this value before actual division is performed. TODO: macro function syntax instead of constant (DEPRECATED)
SQRT_SMALL_FASTF - sqrt(SMALL_FASTF), or slightly larger. The value of this is quite a lot larger than that of SMALL_FASTF. Any number smaller than this, when squared, can be expected to produce a zero result. TODO: macro function syntax instead of constant (DEPRECATED)
#define SQRT_MAX_FASTF 1.0e36 /* This squared just avoids overflow */ |
#define SQRT_SMALL_FASTF 1.0e-39 /* This squared gives zero */ |
#define SMALL SQRT_SMALL_FASTF |
#define INFINITY ((fastf_t)1.0e38) |
It is necessary to have a representation of 1.0/0.0 or log(0), i.e., "infinity" that fits within the dynamic range of the machine being used. This constant places an upper bound on the size object which can be represented in the model. With IEEE 754 floating point, this may print as 'inf' and is represented with all 1 bits in the biased-exponent field and all 0 bits in the fraction with the sign indicating positive (0) or negative (1) infinity. However, we do not assume or rely on IEEE 754 floating point.
#define ELEMENTS_PER_VECT2D 2 |
#define ELEMENTS_PER_POINT2D 2 |
#define ELEMENTS_PER_POINT 3 |
#define ELEMENTS_PER_HVECT 4 |
#define ELEMENTS_PER_HPOINT 4 |
#define ELEMENTS_PER_PLANE 4 |
#define ELEMENTS_PER_MAT (ELEMENTS_PER_PLANE*ELEMENTS_PER_PLANE) |
#define NEAR_ZERO | ( | val, | |
epsilon | |||
) | (((val) > -epsilon) && ((val) < epsilon)) |
#define VNEAR_ZERO | ( | v, | |
tol | |||
) |
Return truthfully whether all elements of a given vector are within a specified epsilon distance from zero.
#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 | |||
) |
Return truthfully whether two 3D vectors are approximately equal, within a specified absolute tolerance.
#define V2NEAR_EQUAL | ( | a, | |
b, | |||
tol | |||
) |
Return truthfully whether two 2D vectors are approximately equal, within a specified absolute tolerance.
#define HNEAR_EQUAL | ( | _a, | |
_b, | |||
_tol | |||
) |
Return truthfully whether two 4D vectors are approximately equal, within a specified absolute tolerance.
#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) |
#define HEQUAL | ( | _a, | |
_b | |||
) | HNEAR_EQUAL((_a), (_b), SMALL_FASTF) |
#define DIST_PNT_PNT_SQ | ( | _a, | |
_b | |||
) |
#define DIST_PNT_PNT | ( | _a, | |
_b | |||
) | sqrt(DIST_PNT_PNT_SQ(_a, _b)) |
#define DIST_PNT2_PNT2_SQ | ( | _a, | |
_b | |||
) |
#define DIST_PNT2_PNT2 | ( | _a, | |
_b | |||
) | sqrt(DIST_PNT2_PNT2_SQ(_a, _b)) |
#define MAT_DELTAS | ( | _m, | |
_x, | |||
_y, | |||
_z | |||
) |
#define MAT_DELTAS_VEC | ( | _m, | |
_v | |||
) | MAT_DELTAS(_m, (_v)[X], (_v)[Y], (_v)[Z]) |
#define MAT_DELTAS_VEC_NEG | ( | _m, | |
_v | |||
) | MAT_DELTAS(_m, -(_v)[X], -(_v)[Y], -(_v)[Z]) |
#define MAT_DELTAS_GET | ( | _v, | |
_m | |||
) |
#define MAT_DELTAS_GET_NEG | ( | _v, | |
_m | |||
) |
#define MAT_DELTAS_ADD | ( | _m, | |
_x, | |||
_y, | |||
_z | |||
) |
#define MAT_DELTAS_ADD_VEC | ( | _m, | |
_v | |||
) |
#define MAT_DELTAS_SUB | ( | _m, | |
_x, | |||
_y, | |||
_z | |||
) |
#define MAT_DELTAS_SUB_VEC | ( | _m, | |
_v | |||
) |
#define MAT_DELTAS_MUL | ( | _m, | |
_x, | |||
_y, | |||
_z | |||
) |
#define MAT_DELTAS_MUL_VEC | ( | _m, | |
_v | |||
) |
#define MAT_SCALE | ( | _m, | |
_x, | |||
_y, | |||
_z | |||
) |
#define MAT_SCALE_VEC | ( | _m, | |
_v | |||
) |
#define MAT_SCALE_ALL | ( | _m, | |
_s | |||
) | (_m)[MSA] = (_s) |
#define MAT_SCALE_ADD | ( | _m, | |
_x, | |||
_y, | |||
_z | |||
) |
#define MAT_SCALE_ADD_VEC | ( | _m, | |
_v | |||
) |
#define MAT_SCALE_SUB | ( | _m, | |
_x, | |||
_y, | |||
_z | |||
) |
#define MAT_SCALE_SUB_VEC | ( | _m, | |
_v | |||
) |
#define MAT_SCALE_MUL | ( | _m, | |
_x, | |||
_y, | |||
_z | |||
) |
#define MAT_SCALE_MUL_VEC | ( | _m, | |
_v | |||
) |
#define MAT_ZERO | ( | m | ) |
Zero a matrix.
In following are macro versions of librt/mat.c functions for when speed really matters.
#define MAT_IDN | ( | m | ) |
#define MAT_TRANSPOSE | ( | t, | |
m | |||
) |
set t to the transpose of matrix m
NOTE: This implementation will not transpose in-place or overlapping matrices (e.g., MAT_TRANSPOSE(m, m) will be wrong).
#define MAT_COPY | ( | c, | |
m | |||
) |
Copy a matrix ‘m’ into ‘c’.
#define VSET | ( | o, | |
a, | |||
b, | |||
c | |||
) |
#define V2SET | ( | o, | |
a, | |||
b | |||
) |
#define HSET | ( | o, | |
a, | |||
b, | |||
c, | |||
d | |||
) |
#define VSETALL | ( | v, | |
s | |||
) |
#define V2SETALL | ( | v, | |
s | |||
) |
#define HSETALL | ( | v, | |
s | |||
) |
#define VSETALLN | ( | v, | |
s, | |||
n | |||
) |
#define VMOVE | ( | o, | |
v | |||
) |
#define V2MOVE | ( | o, | |
v | |||
) |
#define HMOVE | ( | o, | |
v | |||
) |
#define VMOVEN | ( | o, | |
v, | |||
n | |||
) |
#define VREVERSE | ( | o, | |
v | |||
) |
#define V2REVERSE | ( | o, | |
v | |||
) |
#define HREVERSE | ( | o, | |
v | |||
) |
#define VADD2 | ( | o, | |
a, | |||
b | |||
) |
#define V2ADD2 | ( | o, | |
a, | |||
b | |||
) |
#define HADD2 | ( | o, | |
a, | |||
b | |||
) |
#define VADD2N | ( | o, | |
a, | |||
b, | |||
n | |||
) |
#define VSUB2 | ( | o, | |
a, | |||
b | |||
) |
#define V2SUB2 | ( | o, | |
a, | |||
b | |||
) |
#define HSUB2 | ( | o, | |
a, | |||
b | |||
) |
#define VSUB2N | ( | o, | |
a, | |||
b, | |||
n | |||
) |
#define VSUB3 | ( | o, | |
a, | |||
b, | |||
c | |||
) |
#define V2SUB3 | ( | o, | |
a, | |||
b, | |||
c | |||
) |
#define HSUB3 | ( | o, | |
a, | |||
b, | |||
c | |||
) |
#define VADD3 | ( | o, | |
a, | |||
b, | |||
c | |||
) |
#define V2ADD3 | ( | o, | |
a, | |||
b, | |||
c | |||
) |
#define HADD3 | ( | o, | |
a, | |||
b, | |||
c | |||
) |
#define VADD4 | ( | o, | |
a, | |||
b, | |||
c, | |||
d | |||
) |
#define V2ADD4 | ( | o, | |
a, | |||
b, | |||
c, | |||
d | |||
) |
#define HADD4 | ( | o, | |
a, | |||
b, | |||
c, | |||
d | |||
) |
Add 4 4D vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.
#define VSCALE | ( | o, | |
v, | |||
s | |||
) |
#define V2SCALE | ( | o, | |
v, | |||
s | |||
) |
#define HSCALE | ( | o, | |
v, | |||
s | |||
) |
#define VSCALEN | ( | o, | |
v, | |||
s, | |||
n | |||
) |
#define VUNITIZE | ( | v | ) |
Normalize vector ‘v’ to be a unit vector.
#define V2UNITIZE | ( | v | ) |
Normalize 2D vector ‘v’ to be a unit vector.
#define VADD2SCALE | ( | o, | |
a, | |||
b, | |||
s | |||
) |
#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.
#define VSUB2SCALE | ( | o, | |
a, | |||
b, | |||
s | |||
) |
#define VSUB2SCALEN | ( | o, | |
a, | |||
b, | |||
s, | |||
n | |||
) |
Find the difference between two vectors of length ‘n’, and scale result by ‘s’.
#define VCOMB3 | ( | o, | |
a, | |||
b, | |||
c, | |||
d, | |||
e, | |||
f | |||
) |
Combine together three vectors, all scaled by scalars.
DEPRECATED: API inconsistent, use combo of other macros.
Combine together three vectors of length ‘n’, all scaled by scalars.
DEPRECATED: API inconsistent, use combo of other macros.
#define VCOMB2 | ( | o, | |
sa, | |||
va, | |||
sb, | |||
vb | |||
) |
#define VCOMB2N | ( | o, | |
sa, | |||
a, | |||
sb, | |||
b, | |||
n | |||
) |
#define VJOIN4 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
i, | |||
j | |||
) |
#define VJOIN3 | ( | o, | |
a, | |||
sb, | |||
b, | |||
sc, | |||
c, | |||
sd, | |||
d | |||
) |
Join three scaled vectors to a base ‘a’, storing the result in ‘o’.
#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’.
#define V2JOIN2 | ( | o, | |
a, | |||
sb, | |||
b, | |||
sc, | |||
c | |||
) |
#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’.
#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 | |||
) |
#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’.
#define VPROJECT | ( | a, | |
b, | |||
c, | |||
d | |||
) |
Project vector ‘a’ onto ‘b’ vector ‘c’ is the component of ‘a’ parallel to ‘b’ " `d' " " " " " orthogonal " ".
FIXME: consistency, the result should come first
#define MAGNITUDE | ( | v | ) | sqrt(MAGSQ(v)) |
#define MAGNITUDE2 | ( | v | ) | sqrt(MAG2SQ(v)) |
#define VCROSS | ( | o, | |
a, | |||
b | |||
) |
Store cross product of 3D vectors at ‘a’ and ‘b’ in vector at ‘o’.
NOTE: The "right hand rule" applies. If closing your right hand goes from ‘a’ to ‘b’, then your thumb points in the direction of the cross product.
If the angle from ‘a’ to ‘b’ goes clockwise, then the result vector points "into" the plane (inward normal). Example: a=(0, 1, 0), b=(1, 0, 0), then aXb=(0, 0, -1).
If the angle from ‘a’ to ‘b’ goes counter-clockwise, then the result vector points "out" of the plane. This outward pointing normal is the BRL-CAD convention.
#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’.
NOTE: We intentionally use the form "o = a*(1-t) + b*t" which is mathematically equivalent to "o = a + (b-a)*t". The latter might result in fewer math operations but cannot guarantee o==v1 when t==1 due to floating-point arithmetic error.
#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’.
NOTE: We intentionally use the form "o = a*(1-t) + b*t" which is mathematically equivalent to "o = a + (b-a)*t". The latter might result in fewer math operations but cannot guarantee o==v1 when t==1 due to floating-point arithmetic error.
#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’.
NOTE: We intentionally use the form "o = a*(1-t) + b*t" which is mathematically equivalent to "o = a + (b-a)*t". The latter might result in fewer math operations but cannot guarantee o==v1 when t==1 due to floating-point arithmetic error.
#define VSUB2DOT | ( | _pt2, | |
_pt, | |||
_vec | |||
) |
#define INTCLAMP | ( | _a | ) | (NEAR_EQUAL((_a), rint(_a), VUNITIZE_TOL) ? rint(_a) : (_a)) |
Clamp values within tolerance of an integer to that value.
For example, INTCLAMP(10.0000123123) evaluates to 10.0
NOTE: should use VDIVIDE_TOL here, but cannot yet. we use VUINITIZE_TOL until floats are replaced universally with fastf_t's since their epsilon is considerably less than that of a double.
#define VINTCLAMP | ( | _v | ) |
#define V2INTCLAMP | ( | _v | ) |
#define HINTCLAMP | ( | _v | ) |
#define V2INTCLAMPPRINT | ( | a, | |
b | |||
) | fprintf(stderr, "%s (%g, %g)\n", a, V2INTCLAMPARGS(b)); |
#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 | |||
) |
#define VELMUL3 | ( | o, | |
a, | |||
b, | |||
c | |||
) |
#define VELDIV | ( | o, | |
a, | |||
b | |||
) |
#define VINVDIR | ( | _inv, | |
_dir | |||
) |
#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).
#define VEC3X3MAT | ( | o, | |
i, | |||
m | |||
) |
#define MAT3X2VEC | ( | o, | |
mat, | |||
vec | |||
) |
#define VEC2X3MAT | ( | o, | |
i, | |||
m | |||
) |
#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.
#define PNT3X4MAT | ( | o, | |
i, | |||
m | |||
) |
Multiply an Absolute 3-Point by a full 4x4 matrix. Output and input points should be separate arrays.
#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.
#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.
#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.
#define VEC2X4MAT | ( | o, | |
i, | |||
m | |||
) |
Multiply a Relative 2-Vector by most of a 4x4 matrix.
#define V_MIN | ( | r, | |
s | |||
) | if ((r) > (s)) r = (s) |
#define VMIN | ( | r, | |
s | |||
) |
#define VMAX | ( | r, | |
s | |||
) |
#define VMINMAX | ( | min, | |
max, | |||
pt | |||
) |
#define V2MIN | ( | r, | |
s | |||
) |
#define V2MAX | ( | r, | |
s | |||
) |
#define V2MINMAX | ( | min, | |
max, | |||
pt | |||
) |
#define HDIVIDE | ( | o, | |
v | |||
) |
Quaternion math definitions.
Note that the [W] component will be put in the last (i.e., third) place rather than the first [X] (i.e., [0]) place, so that the X, Y, and Z elements will be compatible with vectors. Only QUAT_FROM_VROT macros depend on component locations, however.
Create Quaternion from Vector and Rotation about vector.
To produce a quaternion representing a rotation by PI radians about X-axis:
VSET(axis, 1, 0, 0); QUAT_FROM_VROT(quat, M_PI, axis); or QUAT_FROM_ROT(quat, M_PI, 1.0, 0.0, 0.0, 0.0);
Alternatively, in degrees: QUAT_FROM_ROT_DEG(quat, 180.0, 1.0, 0.0, 0.0, 0.0);
#define QUAT_FROM_VROT | ( | q, | |
r, | |||
v | |||
) |
#define QUAT_FROM_VROT_DEG | ( | q, | |
r, | |||
v | |||
) | QUAT_FROM_VROT(q, ((r)*DEG2RAD), v) |
#define QSET | ( | a, | |
b, | |||
c, | |||
d, | |||
e | |||
) |
#define QMOVE | ( | a, | |
b | |||
) |
#define QADD2 | ( | a, | |
b, | |||
c | |||
) |
#define QSUB2 | ( | a, | |
b, | |||
c | |||
) |
#define QSCALE | ( | a, | |
b, | |||
c | |||
) |
#define QUNITIZE | ( | a | ) |
Normalize quaternion 'a' to be a unit quaternion.
#define QMAGSQ | ( | a | ) |
#define QMAGNITUDE | ( | a | ) | sqrt(QMAGSQ(a)) |
#define QDOT | ( | a, | |
b | |||
) |
#define QMUL | ( | a, | |
b, | |||
c | |||
) |
Compute quaternion product a = b * c.
a[W] = b[W]*c[W] - VDOT(b, c); VCROSS(temp, b, c); VJOIN2(a, temp, b[W], c, c[W], b);
#define QCONJUGATE | ( | a, | |
b | |||
) |
#define QINVERSE | ( | a, | |
b | |||
) |
Multiplicative inverse quaternion.
#define QBLEND2 | ( | a, | |
b, | |||
c, | |||
d, | |||
e | |||
) |
Blend into quaternion ‘a’.
scalar ‘b’ times quaternion at ‘c’ plus scalar ‘d’ times quaternion at ‘e’
#define V3RPP_DISJOINT | ( | _l1, | |
_h1, | |||
_l2, | |||
_h2 | |||
) |
Macros for dealing with 3-D "extents", aka bounding boxes, that are represented as axis-aligned right parallelepipeds (RPPs). This is stored as two points: a min point, and a max point. RPP 1 is defined by lo1, hi1, RPP 2 by lo2, hi2. Compare two bounding boxes and return true if they are disjoint.
#define V3RPP_DISJOINT_TOL | ( | _l1, | |
_h1, | |||
_l2, | |||
_h2, | |||
_t | |||
) |
Compare two bounding boxes and return true if they are disjoint by at least distance tolerance.
#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.
#define V3PNT_IN_RPP | ( | _pt, | |
_lo, | |||
_hi | |||
) |
Is the point within or on the boundary of the RPP?
FIXME: should not be using >= <=, '=' case is unreliable
#define V3PNT_IN_RPP_TOL | ( | _pt, | |
_lo, | |||
_hi, | |||
_t | |||
) |
Within the distance tolerance, is the point within the RPP?
FIXME: should not be using >= <=, '=' case is unreliable
#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.
#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.
FIXME: should not be using >= <=, '=' case is unreliable
#define V3DIR_FROM_AZEL | ( | _d, | |
_a, | |||
_e | |||
) |
#define AZEL_FROM_V3DIR | ( | _a, | |
_e, | |||
_d | |||
) |
Convert a direction vector to azimuth/elevation (in radians).
#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)} |
2D vector macro suitable for declaration statement initialization. this sets all vector elements to the specified value similar to VSETALLN(hvect_t,val,2) but as an initializer array declaration instead of as a statement.
#define HINITALL | ( | _v | ) | {(_v), (_v), (_v), (_v)} |
4D homogeneous vector macro suitable for declaration statement initialization. this sets all vector elements to the specified value similar to VSETALLN(hvect_t,val,4) but as an initializer array declaration instead of as a statement.
#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} |
typedef double fastf_t |
typedef fastf_t vect2d_t[ELEMENTS_PER_VECT2D] |
typedef fastf_t point2d_t[ELEMENTS_PER_POINT2D] |
typedef fastf_t* point2dp_t |
typedef fastf_t vect_t[ELEMENTS_PER_VECT] |
typedef fastf_t point_t[ELEMENTS_PER_POINT] |
typedef fastf_t hvect_t[ELEMENTS_PER_HVECT] |
typedef fastf_t hpoint_t[ELEMENTS_PER_HPOINT] |
typedef fastf_t mat_t[ELEMENTS_PER_MAT] |
typedef fastf_t plane_t[ELEMENTS_PER_PLANE] |
Definition of a plane equation.
A plane is defined by a unit-length outward pointing normal vector (N), and the perpendicular (shortest) distance from the origin to the plane (in element N[W]).
The plane consists of all points P=(x, y, z) such that
VDOT(P, N) - N[W] == 0
that is,
N[X]*x + N[Y]*y + N[Z]*z - N[W] == 0
The inside of the halfspace bounded by the plane consists of all points P such that
VDOT(P, N) - N[W] <= 0
A ray with direction D is classified w.r.t. the plane by
VDOT(D, N) < 0 ray enters halfspace defined by plane
VDOT(D, N) == 0 ray is parallel to plane
VDOT(D, N) > 0 ray exits halfspace defined by plane
typedef enum vmath_vector_component_ vmath_vector_component |
Vector component names for homogeneous (4-tuple) vectors
typedef enum vmath_matrix_component_ vmath_matrix_component |
Locations of deltas (MD*) and scaling values (MS*) in a 4x4 Homogeneous Transform matrix