BRL-CAD
Loading...
Searching...
No Matches
Vector Math

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 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
 
#define ELEMENTS_PER_POINT2D   2
 number of fastf_t's per point2d_t
 
#define ELEMENTS_PER_VECT   3
 number of fastf_t's per vect_t
 
#define ELEMENTS_PER_POINT   3
 number of fastf_t's per point_t
 
#define ELEMENTS_PER_HVECT   4
 number of fastf_t's per hvect_t (homogeneous vector)
 
#define ELEMENTS_PER_HPOINT   4
 number of fastf_t's per hpt_t (homogeneous point)
 
#define ELEMENTS_PER_PLANE   4
 number of fastf_t's per plane_t
 
#define ELEMENTS_PER_MAT   (ELEMENTS_PER_PLANE*ELEMENTS_PER_PLANE)
 number of fastf_t's per mat_t
 
#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.
 
#define HEQUAL(_a, _b)   HNEAR_EQUAL((_a), (_b), SMALL_FASTF)
 Return truthfully whether two higher degree vectors are equal within a minimum representation tolerance.
 
#define DIST_PNT_PLANE(_pt, _pl)   (VDOT(_pt, _pl) - (_pl)[W])
 Compute distance from a point to a plane.
 
#define DIST_PNT_PNT_SQ(_a, _b)
 Compute distance between two points.
 
#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.
 
#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.
 
#define MAT_DELTAS_VEC(_m, _v)    MAT_DELTAS(_m, (_v)[X], (_v)[Y], (_v)[Z])
 set translation values of 4x4 matrix from a vector.
 
#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.
 
#define MAT_DELTAS_GET(_v, _m)
 get translation values of 4x4 matrix to a vector.
 
#define MAT_DELTAS_GET_NEG(_v, _m)
 get translation values of 4x4 matrix to a vector, reversed.
 
#define MAT_DELTAS_ADD(_m, _x, _y, _z)
 increment translation elements in a 4x4 matrix with x, y, z values.
 
#define MAT_DELTAS_ADD_VEC(_m, _v)
 increment translation elements in a 4x4 matrix from a vector.
 
#define MAT_DELTAS_SUB(_m, _x, _y, _z)
 decrement translation elements in a 4x4 matrix with x, y, z values.
 
#define MAT_DELTAS_SUB_VEC(_m, _v)
 decrement translation elements in a 4x4 matrix from a vector.
 
#define MAT_DELTAS_MUL(_m, _x, _y, _z)
 decrement translation elements in a 4x4 matrix with x, y, z values.
 
#define MAT_DELTAS_MUL_VEC(_m, _v)
 decrement translation elements in a 4x4 matrix from a vector.
 
#define MAT_SCALE(_m, _x, _y, _z)
 set scale of 4x4 matrix from xyz.
 
#define MAT_SCALE_VEC(_m, _v)
 set scale of 4x4 matrix from vector.
 
#define MAT_SCALE_ALL(_m, _s)   (_m)[MSA] = (_s)
 set uniform scale of 4x4 matrix from scalar.
 
#define MAT_SCALE_ADD(_m, _x, _y, _z)
 add to scaling elements in a 4x4 matrix from xyz.
 
#define MAT_SCALE_ADD_VEC(_m, _v)
 add to scaling elements in a 4x4 matrix from vector.
 
#define MAT_SCALE_SUB(_m, _x, _y, _z)
 subtract from scaling elements in a 4x4 matrix from xyz.
 
#define MAT_SCALE_SUB_VEC(_m, _v)
 subtract from scaling elements in a 4x4 matrix from vector.
 
#define MAT_SCALE_MUL(_m, _x, _y, _z)
 multiply scaling elements in a 4x4 matrix from xyz.
 
#define MAT_SCALE_MUL_VEC(_m, _v)
 multiply scaling elements in a 4x4 matrix from vector.
 
#define MAT_ZERO(m)
 Zero a matrix.
 
#define MAT_IDN(m)
 Set matrix to identity.
 
#define MAT_TRANSPOSE(t, m)
 set t to the transpose of matrix m
 
#define MAT_COPY(c, m)
 Copy a matrix ‘m’ into ‘c’.
 
#define VSET(o, a, b, c)
 Set 3D vector at ‘o’ to have coordinates ‘a’, ‘b’, and ‘c’.
 
#define V2SET(o, a, b)
 Set 2D vector at ‘o’ to have coordinates ‘a’ and ‘b’.
 
#define HSET(o, a, b, c, d)
 Set 4D vector at ‘o’ to homogeneous coordinates ‘a’, ‘b’, ‘c’, and ‘d’.
 
#define VSETALL(v, s)
 Set all elements of 3D vector to same scalar value.
 
#define V2SETALL(v, s)
 Set 2D vector elements to same scalar value.
 
#define HSETALL(v, s)
 Set 4D vector elements to same scalar value.
 
#define VSETALLN(v, s, n)
 Set all elements of N-vector to same scalar value.
 
#define VMOVE(o, v)
 Transfer 3D vector at ‘v’ to vector at ‘o’.
 
#define V2MOVE(o, v)
 Move a 2D vector at ‘v’ to vector at ‘o’.
 
#define HMOVE(o, v)
 Move a homogeneous 4-tuple at ‘v’ to ‘o’.
 
#define VMOVEN(o, v, n)
 Transfer vector of length ‘n’ at ‘v’ to vector at ‘o’.
 
#define VREVERSE(o, v)
 Reverse the direction of 3D vector ‘v’ and store it in ‘o’.
 
#define V2REVERSE(o, v)
 Reverse the direction of 2D vector ‘v’ and store it in ‘o’.
 
#define HREVERSE(o, v)
 Same as VREVERSE, but for a 4-tuple. Also useful on plane_t objects.
 
#define VADD2(o, a, b)
 Add 3D vectors at ‘a’ and ‘b’, store result at ‘o’.
 
#define V2ADD2(o, a, b)
 Add 2D vectors at ‘a’ and ‘b’, store result at ‘o’.
 
#define HADD2(o, a, b)
 Add 4D vectors at ‘a’ and ‘b’, store result at ‘o’.
 
#define VADD2N(o, a, b, n)
 Add vectors of length ‘n’ at ‘a’ and ‘b’, store result at ‘o’.
 
#define VSUB2(o, a, b)
 Subtract 3D vector at ‘b’ from vector at ‘a’, store result at ‘o’.
 
#define V2SUB2(o, a, b)
 Subtract 2D vector at ‘b’ from vector at ‘a’, store result at ‘o’.
 
#define HSUB2(o, a, b)
 Subtract 4D vector at ‘b’ from vector at ‘a’, store result at ‘o’.
 
#define VSUB2N(o, a, b, n)
 Subtract ‘n’ length vector at ‘b’ from ‘n’ length vector at ‘a’, store result at ‘o’.
 
#define VSUB3(o, a, b, c)
 3D Vectors: O = A - B - C
 
#define V2SUB3(o, a, b, c)
 2D Vectors: O = A - B - C
 
#define HSUB3(o, a, b, c)
 4D Vectors: O = A - B - C
 
#define VSUB3N(o, a, b, c, n)
 Vectors: O = A - B - C for vectors of length ‘n’.
 
#define VADD3(o, a, b, c)
 Add 3 3D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’.
 
#define V2ADD3(o, a, b, c)
 Add 3 2D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’.
 
#define HADD3(o, a, b, c)
 Add 3 4D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’.
 
#define VADD3N(o, a, b, c, n)
 Add 3 vectors of length ‘n’ at ‘a’, ‘b’, and ‘c’, store result at ‘o’.
 
#define VADD4(o, a, b, c, d)
 Add 4 vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.
 
#define V2ADD4(o, a, b, c, d)
 Add 4 2D vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.
 
#define HADD4(o, a, b, c, d)
 Add 4 4D vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.
 
#define VADD4N(o, a, b, c, d, n)
 Add 4 ‘n’ length vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.
 
#define VSCALE(o, v, s)
 Scale 3D vector at ‘v’ by scalar ‘s’, store result at ‘o’.
 
#define V2SCALE(o, v, s)
 Scale 2D vector at ‘v’ by scalar ‘s’, store result at ‘o’.
 
#define HSCALE(o, v, s)
 Scale 4D vector at ‘v’ by scalar ‘s’, store result at ‘o’.
 
#define VSCALEN(o, v, s, n)
 Scale vector of length ‘n’ at ‘v’ by scalar ‘s’, store result at ‘o’.
 
#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)
 Find the sum of two points, and scale the result. Often used to find the midpoint.
 
#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)
 Find the difference between two points, and scale result. Often used to compute bounding sphere radius given rpp points.
 
#define VSUB2SCALEN(o, a, b, s, n)
 Find the difference between two vectors of length ‘n’, and scale result by ‘s’.
 
#define VCOMB2(o, sa, va, sb, vb)
 Combine together 2 vectors, both scaled by scalars.
 
#define VCOMB2N(o, sa, a, sb, b, n)
 Combine together 2 vectors of length ‘n’, both scaled by scalars.
 
#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’.
 
#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’.
 
#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 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’.
 
#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 " ".
 
#define MAGSQ(v)   ((v)[X]*(v)[X] + (v)[Y]*(v)[Y] + (v)[Z]*(v)[Z])
 Return scalar magnitude squared of vector at ‘v’.
 
#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..
 
#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..
 
#define VCROSS(o, a, b)
 Store cross product of 3D vectors at ‘a’ and ‘b’ in vector at ‘o’.
 
#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’.
 
#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’.
 
#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’.
 
#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’.
 
#define VSUB2DOT(_pt2, _pt, _vec)
 Subtract two points to make a vector, dot with another vector. Returns the dot product scalar value.
 
#define V2ARGS(a)   (a)[X], (a)[Y]
 Turn a vector into comma-separated list of elements, for variable argument subroutines (e.g. printf()).
 
#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.
 
#define V3INTCLAMPARGS(a)   INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z])
 integer clamped versions of the previous arg macros.
 
#define V4INTCLAMPARGS(a)   INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z]), INTCLAMP((a)[W])
 integer clamped versions of the previous arg macros.
 
#define V2PRINT(a, b)    fprintf(stderr, "%s (%.6f, %.6g)\n", a, V2ARGS(b));
 Print vector name and components on stderr.
 
#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.
 
#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.
 
#define VELMUL3(o, a, b, c)
 
#define VELDIV(o, a, b)
 Similar to VELMUL.
 
#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.
 
#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)
 Multiply a 3-tuple by the 3x3 part of a mat_t.
 
#define MAT3X2VEC(o, mat, vec)
 Apply the 3x3 part of a mat_t to a 2-tuple (Z part=0).
 
#define VEC2X3MAT(o, i, m)
 Multiply a 2-tuple (Z=0) by the 3x3 part of a mat_t.
 
#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)
 Included below are macros to update min and max X, Y, Z values to contain a point.
 
#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.
 
#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.
 
#define QUAT_FROM_ROT(q, r, x, y, z)
 Quaternion math definitions.
 
#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’.
 
#define QMOVE(a, b)
 Transfer quaternion at ‘b’ to quaternion at ‘a’.
 
#define QADD2(a, b, c)
 Add quaternions at ‘b’ and ‘c’, store result at ‘a’.
 
#define QSUB2(a, b, c)
 Subtract quaternion at ‘c’ from quaternion at ‘b’, store result at ‘a’.
 
#define QSCALE(a, b, c)
 Scale quaternion at ‘b’ by scalar ‘c’, store result at ‘a’.
 
#define QUNITIZE(a)
 Normalize quaternion 'a' to be a unit quaternion.
 
#define QMAGSQ(a)
 Return scalar magnitude squared of quaternion at ‘a’.
 
#define QMAGNITUDE(a)   sqrt(QMAGSQ(a))
 Return scalar magnitude of quaternion at ‘a’.
 
#define QDOT(a, b)
 Compute dot product of quaternions at ‘a’ and ‘b’.
 
#define QMUL(a, b, c)
 Compute quaternion product a = b * c.
 
#define QCONJUGATE(a, b)
 Conjugate quaternion.
 
#define QINVERSE(a, b)
 Multiplicative inverse quaternion.
 
#define QBLEND2(a, b, c, d, e)
 Blend into quaternion ‘a’.
 
#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.
 
#define V3PNT_IN_RPP(_pt, _lo, _hi)
 Is the point within or on the boundary of the RPP?
 
#define V3PNT_IN_RPP_TOL(_pt, _lo, _hi, _t)
 Within the distance tolerance, is the point within the RPP?
 
#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.
 
#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
 
typedef fastf_t vect2d_t[ELEMENTS_PER_VECT2D]
 2-tuple vector
 
typedef fastf_tvect2dp_t
 pointer to a 2-tuple vector
 
typedef fastf_t point2d_t[ELEMENTS_PER_POINT2D]
 2-tuple point
 
typedef fastf_tpoint2dp_t
 pointer to a 2-tuple point
 
typedef fastf_t vect_t[ELEMENTS_PER_VECT]
 3-tuple vector
 
typedef fastf_tvectp_t
 pointer to a 3-tuple vector
 
typedef fastf_t point_t[ELEMENTS_PER_POINT]
 3-tuple point
 
typedef fastf_tpointp_t
 pointer to a 3-tuple point
 
typedef fastf_t hvect_t[ELEMENTS_PER_HVECT]
 4-tuple vector
 
typedef hvect_t quat_t
 4-element quaternion
 
typedef fastf_t hpoint_t[ELEMENTS_PER_HPOINT]
 4-tuple point
 
typedef fastf_t mat_t[ELEMENTS_PER_MAT]
 4x4 matrix
 
typedef fastf_tmatp_t
 pointer to a 4x4 matrix
 
typedef fastf_t plane_t[ELEMENTS_PER_PLANE]
 Definition of a plane equation.
 
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
}
 

Detailed Description

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES   1

Definition at line 110 of file vmath.h.

◆ M_

#define M_   XXX

all with 36-digits of precision

Definition at line 126 of file vmath.h.

◆ M_1_2PI

#define M_1_2PI   0.159154943091895335768883763372514362

1/(2*pi)

Definition at line 130 of file vmath.h.

◆ M_1_PI

#define M_1_PI   0.318309886183790671537767526745028724

1/pi

Definition at line 133 of file vmath.h.

◆ M_2_PI

#define M_2_PI   0.636619772367581343075535053490057448

2/pi

Definition at line 136 of file vmath.h.

◆ M_2_SQRTPI

#define M_2_SQRTPI   1.12837916709551257389615890312154517

2/sqrt(pi)

Definition at line 139 of file vmath.h.

◆ M_E

#define M_E   2.71828182845904523536028747135266250

e

Definition at line 142 of file vmath.h.

◆ M_EULER

#define M_EULER   0.577215664901532860606512090082402431

Euler's constant

Definition at line 145 of file vmath.h.

◆ M_LOG2E

#define M_LOG2E   1.44269504088896340735992468100189214

log_2(e)

Definition at line 148 of file vmath.h.

◆ M_LOG10E

#define M_LOG10E   0.434294481903251827651128918916605082

log_10(e)

Definition at line 151 of file vmath.h.

◆ M_LN2

#define M_LN2   0.693147180559945309417232121458176568

log_e(2)

Definition at line 154 of file vmath.h.

◆ M_LN10

#define M_LN10   2.30258509299404568401799145468436421

log_e(10)

Definition at line 157 of file vmath.h.

◆ M_LNPI

#define M_LNPI   1.14472988584940017414342735135305871 /** log_e(pi) */

Definition at line 160 of file vmath.h.

◆ M_PI

#define M_PI   3.14159265358979323846264338327950288

pi

Definition at line 163 of file vmath.h.

◆ M_2PI

#define M_2PI   6.28318530717958647692528676655900576

2*pi

Definition at line 166 of file vmath.h.

◆ M_PI_2

#define M_PI_2   1.57079632679489661923132169163975144

pi/2

Definition at line 169 of file vmath.h.

◆ M_PI_3

#define M_PI_3   1.04719755119659774615421446109316763

pi/3

Definition at line 172 of file vmath.h.

◆ M_PI_4

#define M_PI_4   0.785398163397448309615660845819875721

pi/4

Definition at line 175 of file vmath.h.

◆ M_SQRT1_2

#define M_SQRT1_2   0.707106781186547524400844362104849039

sqrt(1/2)

Definition at line 178 of file vmath.h.

◆ M_SQRT2

#define M_SQRT2   1.41421356237309504880168872420969808

sqrt(2)

Definition at line 181 of file vmath.h.

◆ M_SQRT3

#define M_SQRT3   1.73205080756887729352744634150587237

sqrt(3)

Definition at line 184 of file vmath.h.

◆ M_SQRTPI

#define M_SQRTPI   1.77245385090551602729816748334114518

sqrt(pi)

Definition at line 187 of file vmath.h.

◆ DEG2RAD

#define DEG2RAD   0.0174532925199432957692369076848861271

pi/180

Definition at line 191 of file vmath.h.

◆ RAD2DEG

#define RAD2DEG   57.2957795130823208767981548141051703

180/pi

Definition at line 194 of file vmath.h.

◆ MAX_FASTF

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

Definition at line 240 of file vmath.h.

◆ SQRT_MAX_FASTF

#define SQRT_MAX_FASTF   1.0e36 /* This squared just avoids overflow */

Definition at line 241 of file vmath.h.

◆ SMALL_FASTF

#define SMALL_FASTF   1.0e-77 /* Anything smaller is zero */

Definition at line 242 of file vmath.h.

◆ SQRT_SMALL_FASTF

#define SQRT_SMALL_FASTF   1.0e-39 /* This squared gives zero */

Definition at line 246 of file vmath.h.

◆ INFINITY

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

Definition at line 280 of file vmath.h.

◆ VDIVIDE_TOL

#define VDIVIDE_TOL   (1.0e-20)

Definition at line 293 of file vmath.h.

◆ VUNITIZE_TOL

#define VUNITIZE_TOL   (1.0e-15)

Definition at line 298 of file vmath.h.

◆ ELEMENTS_PER_VECT2D

#define ELEMENTS_PER_VECT2D   2

number of fastf_t's per vect2d_t

Definition at line 304 of file vmath.h.

◆ ELEMENTS_PER_POINT2D

#define ELEMENTS_PER_POINT2D   2

number of fastf_t's per point2d_t

Definition at line 307 of file vmath.h.

◆ ELEMENTS_PER_VECT

#define ELEMENTS_PER_VECT   3

number of fastf_t's per vect_t

Definition at line 310 of file vmath.h.

◆ ELEMENTS_PER_POINT

#define ELEMENTS_PER_POINT   3

number of fastf_t's per point_t

Definition at line 313 of file vmath.h.

◆ ELEMENTS_PER_HVECT

#define ELEMENTS_PER_HVECT   4

number of fastf_t's per hvect_t (homogeneous vector)

Definition at line 316 of file vmath.h.

◆ ELEMENTS_PER_HPOINT

#define ELEMENTS_PER_HPOINT   4

number of fastf_t's per hpt_t (homogeneous point)

Definition at line 319 of file vmath.h.

◆ ELEMENTS_PER_PLANE

#define ELEMENTS_PER_PLANE   4

number of fastf_t's per plane_t

Definition at line 322 of file vmath.h.

◆ ELEMENTS_PER_MAT

#define ELEMENTS_PER_MAT   (ELEMENTS_PER_PLANE*ELEMENTS_PER_PLANE)

number of fastf_t's per mat_t

Definition at line 325 of file vmath.h.

◆ INVALID

#define INVALID (   n)    (!((n) > -INFINITY && (n) < INFINITY))

Evaluates truthfully whether a number is not within valid range of INFINITY to -INFINITY exclusive (open set).

Definition at line 425 of file vmath.h.

◆ VINVALID

#define VINVALID (   v)    (INVALID((v)[X]) || INVALID((v)[Y]) || INVALID((v)[Z]))

Evaluates truthfully whether any components of a vector are not within a valid range.

Definition at line 431 of file vmath.h.

◆ V2INVALID

#define V2INVALID (   v)    (INVALID((v)[X]) || INVALID((v)[Y]))

Evaluates truthfully whether any components of a 2D vector are not within a valid range.

Definition at line 437 of file vmath.h.

◆ HINVALID

#define HINVALID (   v)    (INVALID((v)[X]) || INVALID((v)[Y]) || INVALID((v)[Z]) || INVALID((v)[W]))

Evaluates truthfully whether any components of a 4D vector are not within a valid range.

Definition at line 443 of file vmath.h.

◆ NEAR_ZERO

#define NEAR_ZERO (   val,
  epsilon 
)    (((val) > -epsilon) && ((val) < epsilon))

Return truthfully whether a value is within a specified epsilon distance from zero.

Definition at line 464 of file vmath.h.

◆ VNEAR_ZERO

#define VNEAR_ZERO (   v,
  tol 
)
Value:
(NEAR_ZERO(v[X], tol) \
&& NEAR_ZERO(v[Y], tol) \
&& NEAR_ZERO(v[Z], tol))
#define NEAR_ZERO(val, epsilon)
Definition vmath.h:464
@ Y
Definition vmath.h:401
@ X
Definition vmath.h:400
@ Z
Definition vmath.h:402

Return truthfully whether all elements of a given vector are within a specified epsilon distance from zero.

Definition at line 471 of file vmath.h.

◆ V2NEAR_ZERO

#define V2NEAR_ZERO (   v,
  tol 
)    (NEAR_ZERO(v[X], tol) && NEAR_ZERO(v[Y], tol))

Test for all elements of ‘v’ being smaller than ‘tol’. Version for degree 2 vectors.

Definition at line 480 of file vmath.h.

◆ HNEAR_ZERO

#define HNEAR_ZERO (   v,
  tol 
)
Value:
(NEAR_ZERO(v[X], tol) \
&& NEAR_ZERO(v[Y], tol) \
&& NEAR_ZERO(v[Z], tol) \
&& NEAR_ZERO(h[W], tol))
@ W
Definition vmath.h:403

Test for all elements of ‘v’ being smaller than ‘tol’. Version for degree 2 vectors.

Definition at line 486 of file vmath.h.

◆ ZERO

#define ZERO (   _a)    NEAR_ZERO((_a), SMALL_FASTF)

Return truthfully whether a value is within a minimum representation tolerance from zero.

Definition at line 497 of file vmath.h.

◆ VZERO

#define VZERO (   _a)    VNEAR_ZERO((_a), SMALL_FASTF)

Return truthfully whether a vector is within a minimum representation tolerance from zero.

Definition at line 503 of file vmath.h.

◆ V2ZERO

#define V2ZERO (   _a)    V2NEAR_ZERO((_a), SMALL_FASTF)

Return truthfully whether a 2d vector is within a minimum representation tolerance from zero.

Definition at line 509 of file vmath.h.

◆ HZERO

#define HZERO (   _a)    HNEAR_ZERO((_a), SMALL_FASTF)

Return truthfully whether a homogenized 4-element vector is within a minimum representation tolerance from zero.

Definition at line 515 of file vmath.h.

◆ NEAR_EQUAL

#define NEAR_EQUAL (   _a,
  _b,
  _tol 
)    NEAR_ZERO((_a) - (_b), (_tol))

Return truthfully whether two values are within a specified epsilon distance from each other.

Definition at line 522 of file vmath.h.

◆ VNEAR_EQUAL

#define VNEAR_EQUAL (   _a,
  _b,
  _tol 
)
Value:
(NEAR_EQUAL((_a)[X], (_b)[X], (_tol)) \
&& NEAR_EQUAL((_a)[Y], (_b)[Y], (_tol)) \
&& NEAR_EQUAL((_a)[Z], (_b)[Z], (_tol)))
Definition dvec.h:74
#define NEAR_EQUAL(_a, _b, _tol)
Definition vmath.h:522

Return truthfully whether two 3D vectors are approximately equal, within a specified absolute tolerance.

Definition at line 528 of file vmath.h.

◆ V2NEAR_EQUAL

#define V2NEAR_EQUAL (   a,
  b,
  tol 
)
Value:
(NEAR_EQUAL((a)[X], (b)[X], tol) \
&& NEAR_EQUAL((a)[Y], (b)[Y], tol))

Return truthfully whether two 2D vectors are approximately equal, within a specified absolute tolerance.

Definition at line 537 of file vmath.h.

◆ HNEAR_EQUAL

#define HNEAR_EQUAL (   _a,
  _b,
  _tol 
)
Value:
(NEAR_EQUAL((_a)[X], (_b)[X], (_tol)) \
&& NEAR_EQUAL((_a)[Y], (_b)[Y], (_tol)) \
&& NEAR_EQUAL((_a)[Z], (_b)[Z], (_tol)) \
&& NEAR_EQUAL((_a)[W], (_b)[W], (_tol)))

Return truthfully whether two 4D vectors are approximately equal, within a specified absolute tolerance.

Definition at line 545 of file vmath.h.

◆ EQUAL

#define EQUAL (   _a,
  _b 
)    NEAR_EQUAL((_a), (_b), SMALL_FASTF)

Return truthfully whether two values are within a minimum representation tolerance from each other.

Definition at line 555 of file vmath.h.

◆ VEQUAL

#define VEQUAL (   _a,
  _b 
)    VNEAR_EQUAL((_a), (_b), SMALL_FASTF)

Return truthfully whether two vectors are equal within a minimum representation tolerance.

Definition at line 562 of file vmath.h.

◆ V2EQUAL

#define V2EQUAL (   _a,
  _b 
)    V2NEAR_EQUAL((_a), (_b), SMALL_FASTF)

Return truthfully whether two 2D vectors are equal within a minimum representation tolerance.

Definition at line 568 of file vmath.h.

◆ HEQUAL

#define HEQUAL (   _a,
  _b 
)    HNEAR_EQUAL((_a), (_b), SMALL_FASTF)

Return truthfully whether two higher degree vectors are equal within a minimum representation tolerance.

Definition at line 574 of file vmath.h.

◆ DIST_PNT_PLANE

#define DIST_PNT_PLANE (   _pt,
  _pl 
)    (VDOT(_pt, _pl) - (_pl)[W])

Compute distance from a point to a plane.

Definition at line 578 of file vmath.h.

◆ DIST_PNT_PNT_SQ

#define DIST_PNT_PNT_SQ (   _a,
  _b 
)
Value:
((_a)[X]-(_b)[X])*((_a)[X]-(_b)[X]) + \
((_a)[Y]-(_b)[Y])*((_a)[Y]-(_b)[Y]) + \
((_a)[Z]-(_b)[Z])*((_a)[Z]-(_b)[Z])

Compute distance between two points.

Definition at line 581 of file vmath.h.

◆ DIST_PNT_PNT

#define DIST_PNT_PNT (   _a,
  _b 
)    sqrt(DIST_PNT_PNT_SQ(_a, _b))

Definition at line 585 of file vmath.h.

◆ DIST_PNT2_PNT2_SQ

#define DIST_PNT2_PNT2_SQ (   _a,
  _b 
)
Value:
((_a)[X]-(_b)[X])*((_a)[X]-(_b)[X]) + \
((_a)[Y]-(_b)[Y])*((_a)[Y]-(_b)[Y])

Compute distance between two 2D points.

Definition at line 588 of file vmath.h.

◆ DIST_PNT2_PNT2

#define DIST_PNT2_PNT2 (   _a,
  _b 
)    sqrt(DIST_PNT2_PNT2_SQ(_a, _b))

Definition at line 591 of file vmath.h.

◆ MAT_DELTAS

#define MAT_DELTAS (   _m,
  _x,
  _y,
  _z 
)
Value:
do { \
(_m)[MDX] = (_x); \
(_m)[MDY] = (_y); \
(_m)[MDZ] = (_z); \
} while (0)
@ MDZ
Definition vmath.h:417
@ MDX
Definition vmath.h:413
@ MDY
Definition vmath.h:415

set translation values of 4x4 matrix with x, y, z values.

Definition at line 594 of file vmath.h.

◆ MAT_DELTAS_VEC

#define MAT_DELTAS_VEC (   _m,
  _v 
)     MAT_DELTAS(_m, (_v)[X], (_v)[Y], (_v)[Z])

set translation values of 4x4 matrix from a vector.

Definition at line 601 of file vmath.h.

◆ MAT_DELTAS_VEC_NEG

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

Definition at line 608 of file vmath.h.

◆ MAT_DELTAS_GET

#define MAT_DELTAS_GET (   _v,
  _m 
)
Value:
do { \
(_v)[X] = (_m)[MDX]; \
(_v)[Y] = (_m)[MDY]; \
(_v)[Z] = (_m)[MDZ]; \
} while (0)

get translation values of 4x4 matrix to a vector.

Definition at line 612 of file vmath.h.

◆ MAT_DELTAS_GET_NEG

#define MAT_DELTAS_GET_NEG (   _v,
  _m 
)
Value:
do { \
(_v)[X] = -(_m)[MDX]; \
(_v)[Y] = -(_m)[MDY]; \
(_v)[Z] = -(_m)[MDZ]; \
} while (0)

get translation values of 4x4 matrix to a vector, reversed.

Definition at line 622 of file vmath.h.

◆ MAT_DELTAS_ADD

#define MAT_DELTAS_ADD (   _m,
  _x,
  _y,
  _z 
)
Value:
do { \
(_m)[MDX] += (_x); \
(_m)[MDY] += (_y); \
(_m)[MDZ] += (_z); \
} while (0)

increment translation elements in a 4x4 matrix with x, y, z values.

Definition at line 632 of file vmath.h.

◆ MAT_DELTAS_ADD_VEC

#define MAT_DELTAS_ADD_VEC (   _m,
  _v 
)
Value:
do { \
(_m)[MDX] += (_v)[X]; \
(_m)[MDY] += (_v)[Y]; \
(_m)[MDZ] += (_v)[Z]; \
} while (0)

increment translation elements in a 4x4 matrix from a vector.

Definition at line 642 of file vmath.h.

◆ MAT_DELTAS_SUB

#define MAT_DELTAS_SUB (   _m,
  _x,
  _y,
  _z 
)
Value:
do { \
(_m)[MDX] -= (_x); \
(_m)[MDY] -= (_y); \
(_m)[MDZ] -= (_z); \
} while (0)

decrement translation elements in a 4x4 matrix with x, y, z values.

Definition at line 652 of file vmath.h.

◆ MAT_DELTAS_SUB_VEC

#define MAT_DELTAS_SUB_VEC (   _m,
  _v 
)
Value:
do { \
(_m)[MDX] -= (_v)[X]; \
(_m)[MDY] -= (_v)[Y]; \
(_m)[MDZ] -= (_v)[Z]; \
} while (0)

decrement translation elements in a 4x4 matrix from a vector.

Definition at line 662 of file vmath.h.

◆ MAT_DELTAS_MUL

#define MAT_DELTAS_MUL (   _m,
  _x,
  _y,
  _z 
)
Value:
do { \
(_m)[MDX] *= (_x); \
(_m)[MDY] *= (_y); \
(_m)[MDZ] *= (_z); \
} while (0)

decrement translation elements in a 4x4 matrix with x, y, z values.

Definition at line 672 of file vmath.h.

◆ MAT_DELTAS_MUL_VEC

#define MAT_DELTAS_MUL_VEC (   _m,
  _v 
)
Value:
do { \
(_m)[MDX] *= (_v)[X]; \
(_m)[MDY] *= (_v)[Y]; \
(_m)[MDZ] *= (_v)[Z]; \
} while (0)

decrement translation elements in a 4x4 matrix from a vector.

Definition at line 682 of file vmath.h.

◆ MAT_SCALE

#define MAT_SCALE (   _m,
  _x,
  _y,
  _z 
)
Value:
do { \
(_m)[MSX] = _x; \
(_m)[MSY] = _y; \
(_m)[MSZ] = _z; \
} while (0)
@ MSX
Definition vmath.h:412
@ MSZ
Definition vmath.h:416
@ MSY
Definition vmath.h:414

set scale of 4x4 matrix from xyz.

Definition at line 689 of file vmath.h.

◆ MAT_SCALE_VEC

#define MAT_SCALE_VEC (   _m,
  _v 
)
Value:
do { \
(_m)[MSX] = (_v)[X]; \
(_m)[MSY] = (_v)[Y]; \
(_m)[MSZ] = (_v)[Z]; \
} while (0)

set scale of 4x4 matrix from vector.

Definition at line 696 of file vmath.h.

◆ MAT_SCALE_ALL

#define MAT_SCALE_ALL (   _m,
  _s 
)    (_m)[MSA] = (_s)

set uniform scale of 4x4 matrix from scalar.

Definition at line 703 of file vmath.h.

◆ MAT_SCALE_ADD

#define MAT_SCALE_ADD (   _m,
  _x,
  _y,
  _z 
)
Value:
do { \
(_m)[MSX] += _x; \
(_m)[MSY] += _y; \
(_m)[MSZ] += _z; \
} while (0)

add to scaling elements in a 4x4 matrix from xyz.

Definition at line 706 of file vmath.h.

◆ MAT_SCALE_ADD_VEC

#define MAT_SCALE_ADD_VEC (   _m,
  _v 
)
Value:
do { \
(_m)[MSX] += (_v)[X]; \
(_m)[MSY] += (_v)[Y]; \
(_m)[MSZ] += (_v)[Z]; \
} while (0)

add to scaling elements in a 4x4 matrix from vector.

Definition at line 713 of file vmath.h.

◆ MAT_SCALE_SUB

#define MAT_SCALE_SUB (   _m,
  _x,
  _y,
  _z 
)
Value:
do { \
(_m)[MSX] -= _x; \
(_m)[MSY] -= _y; \
(_m)[MSZ] -= _z; \
} while (0)

subtract from scaling elements in a 4x4 matrix from xyz.

Definition at line 720 of file vmath.h.

◆ MAT_SCALE_SUB_VEC

#define MAT_SCALE_SUB_VEC (   _m,
  _v 
)
Value:
do { \
(_m)[MSX] -= (_v)[X]; \
(_m)[MSY] -= (_v)[Y]; \
(_m)[MSZ] -= (_v)[Z]; \
} while (0)

subtract from scaling elements in a 4x4 matrix from vector.

Definition at line 730 of file vmath.h.

◆ MAT_SCALE_MUL

#define MAT_SCALE_MUL (   _m,
  _x,
  _y,
  _z 
)
Value:
do { \
(_m)[MSX] *= _x; \
(_m)[MSY] *= _y; \
(_m)[MSZ] *= _z; \
} while (0)

multiply scaling elements in a 4x4 matrix from xyz.

Definition at line 737 of file vmath.h.

◆ MAT_SCALE_MUL_VEC

#define MAT_SCALE_MUL_VEC (   _m,
  _v 
)
Value:
do { \
(_m)[MSX] *= (_v)[X]; \
(_m)[MSY] *= (_v)[Y]; \
(_m)[MSZ] *= (_v)[Z]; \
} while (0)

multiply scaling elements in a 4x4 matrix from vector.

Definition at line 744 of file vmath.h.

◆ MAT_ZERO

#define MAT_ZERO (   m)
Value:
do { \
(m)[0] = (m)[1] = (m)[2] = (m)[3] = \
(m)[4] = (m)[5] = (m)[6] = (m)[7] = \
(m)[8] = (m)[9] = (m)[10] = (m)[11] = \
(m)[12] = (m)[13] = (m)[14] = (m)[15] = 0.0; \
} while (0)

Zero a matrix.

In following are macro versions of librt/mat.c functions for when speed really matters.

Definition at line 758 of file vmath.h.

◆ MAT_IDN

#define MAT_IDN (   m)
Value:
do { \
(m)[1] = (m)[2] = (m)[3] = (m)[4] = \
(m)[6] = (m)[7] = (m)[8] = (m)[9] = \
(m)[11] = (m)[12] = (m)[13] = (m)[14] = 0.0; \
(m)[0] = (m)[5] = (m)[10] = (m)[15] = 1.0; \
} while (0)

Set matrix to identity.

Definition at line 766 of file vmath.h.

◆ MAT_TRANSPOSE

#define MAT_TRANSPOSE (   t,
 
)
Value:
do { \
(t)[0] = (m)[0]; \
(t)[4] = (m)[1]; \
(t)[8] = (m)[2]; \
(t)[12] = (m)[3]; \
(t)[1] = (m)[4]; \
(t)[5] = (m)[5]; \
(t)[9] = (m)[6]; \
(t)[13] = (m)[7]; \
(t)[2] = (m)[8]; \
(t)[6] = (m)[9]; \
(t)[10] = (m)[10]; \
(t)[14] = (m)[11]; \
(t)[3] = (m)[12]; \
(t)[7] = (m)[13]; \
(t)[11] = (m)[14]; \
(t)[15] = (m)[15]; \
} while (0)

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

Definition at line 779 of file vmath.h.

◆ MAT_COPY

#define MAT_COPY (   c,
 
)
Value:
do { \
(c)[0] = (m)[0]; \
(c)[1] = (m)[1]; \
(c)[2] = (m)[2]; \
(c)[3] = (m)[3]; \
(c)[4] = (m)[4]; \
(c)[5] = (m)[5]; \
(c)[6] = (m)[6]; \
(c)[7] = (m)[7]; \
(c)[8] = (m)[8]; \
(c)[9] = (m)[9]; \
(c)[10] = (m)[10]; \
(c)[11] = (m)[11]; \
(c)[12] = (m)[12]; \
(c)[13] = (m)[13]; \
(c)[14] = (m)[14]; \
(c)[15] = (m)[15]; \
} while (0)

Copy a matrix ‘m’ into ‘c’.

Definition at line 799 of file vmath.h.

◆ VSET

#define VSET (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a); \
(o)[Y] = (b); \
(o)[Z] = (c); \
} while (0)

Set 3D vector at ‘o’ to have coordinates ‘a’, ‘b’, and ‘c’.

Definition at line 819 of file vmath.h.

◆ V2SET

#define V2SET (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a); \
(o)[Y] = (b); \
} while (0)

Set 2D vector at ‘o’ to have coordinates ‘a’ and ‘b’.

Definition at line 826 of file vmath.h.

◆ HSET

#define HSET (   o,
  a,
  b,
  c,
 
)
Value:
do { \
(o)[X] = (a); \
(o)[Y] = (b); \
(o)[Z] = (c); \
(o)[W] = (d); \
} while (0)

Set 4D vector at ‘o’ to homogeneous coordinates ‘a’, ‘b’, ‘c’, and ‘d’.

Definition at line 832 of file vmath.h.

◆ VSETALL

#define VSETALL (   v,
 
)
Value:
do { \
(v)[X] = (v)[Y] = (v)[Z] = (s); \
} while (0)

Set all elements of 3D vector to same scalar value.

Definition at line 841 of file vmath.h.

◆ V2SETALL

#define V2SETALL (   v,
 
)
Value:
do { \
(v)[X] = (v)[Y] = (s); \
} while (0)

Set 2D vector elements to same scalar value.

Definition at line 846 of file vmath.h.

◆ HSETALL

#define HSETALL (   v,
 
)
Value:
do { \
(v)[X] = (v)[Y] = (v)[Z] = (v)[W] = (s); \
} while (0)

Set 4D vector elements to same scalar value.

Definition at line 851 of file vmath.h.

◆ VSETALLN

#define VSETALLN (   v,
  s,
 
)
Value:
do { \
size_t _j; \
for (_j=0; _j < (size_t)(n); _j++) v[_j]=(s); \
} while (0)

Set all elements of N-vector to same scalar value.

Definition at line 857 of file vmath.h.

◆ VMOVE

#define VMOVE (   o,
 
)
Value:
do { \
(o)[X] = (v)[X]; \
(o)[Y] = (v)[Y]; \
(o)[Z] = (v)[Z]; \
} while (0)

Transfer 3D vector at ‘v’ to vector at ‘o’.

Definition at line 864 of file vmath.h.

◆ V2MOVE

#define V2MOVE (   o,
 
)
Value:
do { \
(o)[X] = (v)[X]; \
(o)[Y] = (v)[Y]; \
} while (0)

Move a 2D vector at ‘v’ to vector at ‘o’.

Definition at line 871 of file vmath.h.

◆ HMOVE

#define HMOVE (   o,
 
)
Value:
do { \
(o)[X] = (v)[X]; \
(o)[Y] = (v)[Y]; \
(o)[Z] = (v)[Z]; \
(o)[W] = (v)[W]; \
} while (0)

Move a homogeneous 4-tuple at ‘v’ to ‘o’.

Definition at line 877 of file vmath.h.

◆ VMOVEN

#define VMOVEN (   o,
  v,
 
)
Value:
do { \
size_t _vmove; \
for (_vmove = 0; _vmove < (size_t)(n); _vmove++) { \
(o)[_vmove] = (v)[_vmove]; \
} \
} while (0)

Transfer vector of length ‘n’ at ‘v’ to vector at ‘o’.

Definition at line 885 of file vmath.h.

◆ VREVERSE

#define VREVERSE (   o,
 
)
Value:
do { \
(o)[X] = -(v)[X]; \
(o)[Y] = -(v)[Y]; \
(o)[Z] = -(v)[Z]; \
} while (0)

Reverse the direction of 3D vector ‘v’ and store it in ‘o’.

NOTE: Reversing in place works (i.e., VREVERSE(v, v))

Definition at line 898 of file vmath.h.

◆ V2REVERSE

#define V2REVERSE (   o,
 
)
Value:
do { \
(o)[X] = -(v)[X]; \
(o)[Y] = -(v)[Y]; \
} while (0)

Reverse the direction of 2D vector ‘v’ and store it in ‘o’.

NOTE: Reversing in place works (i.e., V2REVERSE(v, v))

Definition at line 909 of file vmath.h.

◆ HREVERSE

#define HREVERSE (   o,
 
)
Value:
do { \
(o)[X] = -(v)[X]; \
(o)[Y] = -(v)[Y]; \
(o)[Z] = -(v)[Z]; \
(o)[W] = -(v)[W]; \
} while (0)

Same as VREVERSE, but for a 4-tuple. Also useful on plane_t objects.

NOTE: Reversing in place works (i.e., HREVERSE(v, v))

Definition at line 920 of file vmath.h.

◆ VADD2

#define VADD2 (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X]; \
(o)[Y] = (a)[Y] + (b)[Y]; \
(o)[Z] = (a)[Z] + (b)[Z]; \
} while (0)

Add 3D vectors at ‘a’ and ‘b’, store result at ‘o’.

Definition at line 928 of file vmath.h.

◆ V2ADD2

#define V2ADD2 (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X]; \
(o)[Y] = (a)[Y] + (b)[Y]; \
} while (0)

Add 2D vectors at ‘a’ and ‘b’, store result at ‘o’.

Definition at line 935 of file vmath.h.

◆ HADD2

#define HADD2 (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X]; \
(o)[Y] = (a)[Y] + (b)[Y]; \
(o)[Z] = (a)[Z] + (b)[Z]; \
(o)[W] = (a)[W] + (b)[W]; \
} while (0)

Add 4D vectors at ‘a’ and ‘b’, store result at ‘o’.

Definition at line 941 of file vmath.h.

◆ VADD2N

#define VADD2N (   o,
  a,
  b,
 
)
Value:
do { \
size_t _vadd2; \
for (_vadd2 = 0; _vadd2 < (size_t)(n); _vadd2++) { \
(o)[_vadd2] = (a)[_vadd2] + (b)[_vadd2]; \
} \
} while (0)

Add vectors of length ‘n’ at ‘a’ and ‘b’, store result at ‘o’.

Definition at line 952 of file vmath.h.

◆ VSUB2

#define VSUB2 (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[X] - (b)[X]; \
(o)[Y] = (a)[Y] - (b)[Y]; \
(o)[Z] = (a)[Z] - (b)[Z]; \
} while (0)

Subtract 3D vector at ‘b’ from vector at ‘a’, store result at ‘o’.

Definition at line 964 of file vmath.h.

◆ V2SUB2

#define V2SUB2 (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[X] - (b)[X]; \
(o)[Y] = (a)[Y] - (b)[Y]; \
} while (0)

Subtract 2D vector at ‘b’ from vector at ‘a’, store result at ‘o’.

Definition at line 974 of file vmath.h.

◆ HSUB2

#define HSUB2 (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[X] - (b)[X]; \
(o)[Y] = (a)[Y] - (b)[Y]; \
(o)[Z] = (a)[Z] - (b)[Z]; \
(o)[W] = (a)[W] - (b)[W]; \
} while (0)

Subtract 4D vector at ‘b’ from vector at ‘a’, store result at ‘o’.

Definition at line 983 of file vmath.h.

◆ VSUB2N

#define VSUB2N (   o,
  a,
  b,
 
)
Value:
do { \
size_t _vsub2; \
for (_vsub2 = 0; _vsub2 < (size_t)(n); _vsub2++) { \
(o)[_vsub2] = (a)[_vsub2] - (b)[_vsub2]; \
} \
} while (0)

Subtract ‘n’ length vector at ‘b’ from ‘n’ length vector at ‘a’, store result at ‘o’.

Definition at line 994 of file vmath.h.

◆ VSUB3

#define VSUB3 (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] - (b)[X] - (c)[X]; \
(o)[Y] = (a)[Y] - (b)[Y] - (c)[Y]; \
(o)[Z] = (a)[Z] - (b)[Z] - (c)[Z]; \
} while (0)

3D Vectors: O = A - B - C

Definition at line 1003 of file vmath.h.

◆ V2SUB3

#define V2SUB3 (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] - (b)[X] - (c)[X]; \
(o)[Y] = (a)[Y] - (b)[Y] - (c)[Y]; \
} while (0)

2D Vectors: O = A - B - C

Definition at line 1010 of file vmath.h.

◆ HSUB3

#define HSUB3 (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] - (b)[X] - (c)[X]; \
(o)[Y] = (a)[Y] - (b)[Y] - (c)[Y]; \
(o)[Z] = (a)[Z] - (b)[Z] - (c)[Z]; \
(o)[W] = (a)[W] - (b)[W] - (c)[W]; \
} while (0)

4D Vectors: O = A - B - C

Definition at line 1016 of file vmath.h.

◆ VSUB3N

#define VSUB3N (   o,
  a,
  b,
  c,
 
)
Value:
do { \
size_t _vsub3; \
for (_vsub3 = 0; _vsub3 < (size_t)(n); _vsub3++) { \
(o)[_vsub3] = (a)[_vsub3] - (b)[_vsub3] - (c)[_vsub3]; \
} \
} while (0)

Vectors: O = A - B - C for vectors of length ‘n’.

Definition at line 1024 of file vmath.h.

◆ VADD3

#define VADD3 (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X] + (c)[X]; \
(o)[Y] = (a)[Y] + (b)[Y] + (c)[Y]; \
(o)[Z] = (a)[Z] + (b)[Z] + (c)[Z]; \
} while (0)

Add 3 3D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’.

Definition at line 1033 of file vmath.h.

◆ V2ADD3

#define V2ADD3 (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X] + (c)[X]; \
(o)[Y] = (a)[Y] + (b)[Y] + (c)[Y]; \
} while (0)

Add 3 2D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’.

Definition at line 1040 of file vmath.h.

◆ HADD3

#define HADD3 (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X] + (c)[X]; \
(o)[Y] = (a)[Y] + (b)[Y] + (c)[Y]; \
(o)[Z] = (a)[Z] + (b)[Z] + (c)[Z]; \
(o)[W] = (a)[W] + (b)[W] + (c)[W]; \
} while (0)

Add 3 4D vectors at ‘a’, ‘b’, and ‘c’, store result at ‘o’.

Definition at line 1046 of file vmath.h.

◆ VADD3N

#define VADD3N (   o,
  a,
  b,
  c,
 
)
Value:
do { \
size_t _vadd3; \
for (_vadd3 = 0; _vadd3 < (size_t)(n); _vadd3++) { \
(o)[_vadd3] = (a)[_vadd3] + (b)[_vadd3] + (c)[_vadd3]; \
} \
} while (0)

Add 3 vectors of length ‘n’ at ‘a’, ‘b’, and ‘c’, store result at ‘o’.

Definition at line 1057 of file vmath.h.

◆ VADD4

#define VADD4 (   o,
  a,
  b,
  c,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X] + (c)[X] + (d)[X]; \
(o)[Y] = (a)[Y] + (b)[Y] + (c)[Y] + (d)[Y]; \
(o)[Z] = (a)[Z] + (b)[Z] + (c)[Z] + (d)[Z]; \
} while (0)

Add 4 vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.

Definition at line 1069 of file vmath.h.

◆ V2ADD4

#define V2ADD4 (   o,
  a,
  b,
  c,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X] + (c)[X] + (d)[X]; \
(o)[Y] = (a)[Y] + (b)[Y] + (c)[Y] + (d)[Y]; \
} while (0)

Add 4 2D vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.

Definition at line 1079 of file vmath.h.

◆ HADD4

#define HADD4 (   o,
  a,
  b,
  c,
 
)
Value:
do { \
(o)[X] = (a)[X] + (b)[X] + (c)[X] + (d)[X]; \
(o)[Y] = (a)[Y] + (b)[Y] + (c)[Y] + (d)[Y]; \
(o)[Z] = (a)[Z] + (b)[Z] + (c)[Z] + (d)[Z]; \
(o)[W] = (a)[W] + (b)[W] + (c)[W] + (d)[W]; \
} while (0)

Add 4 4D vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.

Definition at line 1088 of file vmath.h.

◆ VADD4N

#define VADD4N (   o,
  a,
  b,
  c,
  d,
 
)
Value:
do { \
size_t _vadd4; \
for (_vadd4 = 0; _vadd4 < (size_t)(n); _vadd4++) { \
(o)[_vadd4] = (a)[_vadd4] + (b)[_vadd4] + (c)[_vadd4] + (d)[_vadd4]; \
} \
} while (0)

Add 4 ‘n’ length vectors at ‘a’, ‘b’, ‘c’, and ‘d’, store result at ‘o’.

Definition at line 1099 of file vmath.h.

◆ VSCALE

#define VSCALE (   o,
  v,
 
)
Value:
do { \
(o)[X] = (v)[X] * (s); \
(o)[Y] = (v)[Y] * (s); \
(o)[Z] = (v)[Z] * (s); \
} while (0)

Scale 3D vector at ‘v’ by scalar ‘s’, store result at ‘o’.

Definition at line 1108 of file vmath.h.

◆ V2SCALE

#define V2SCALE (   o,
  v,
 
)
Value:
do { \
(o)[X] = (v)[X] * (s); \
(o)[Y] = (v)[Y] * (s); \
} while (0)

Scale 2D vector at ‘v’ by scalar ‘s’, store result at ‘o’.

Definition at line 1115 of file vmath.h.

◆ HSCALE

#define HSCALE (   o,
  v,
 
)
Value:
do { \
(o)[X] = (v)[X] * (s); \
(o)[Y] = (v)[Y] * (s); \
(o)[Z] = (v)[Z] * (s); \
(o)[W] = (v)[W] * (s); \
} while (0)

Scale 4D vector at ‘v’ by scalar ‘s’, store result at ‘o’.

Definition at line 1121 of file vmath.h.

◆ VSCALEN

#define VSCALEN (   o,
  v,
  s,
 
)
Value:
do { \
size_t _vscale; \
for (_vscale = 0; _vscale < (size_t)(n); _vscale++) { \
(o)[_vscale] = (v)[_vscale] * (s); \
} \
} while (0)

Scale vector of length ‘n’ at ‘v’ by scalar ‘s’, store result at ‘o’.

Definition at line 1132 of file vmath.h.

◆ VUNITIZE

#define VUNITIZE (   v)
Value:
do { \
double _f = MAGSQ(v); \
if (! NEAR_EQUAL(_f, 1.0, VUNITIZE_TOL)) { \
_f = sqrt(_f); \
VSETALL((v), 0.0); \
} else { \
_f = 1.0/_f; \
(v)[X] *= _f; (v)[Y] *= _f; (v)[Z] *= _f; \
} \
} \
} while (0)
#define VDIVIDE_TOL
Definition vmath.h:293
#define MAGSQ(v)
Return scalar magnitude squared of vector at ‘v’.
Definition vmath.h:1387
#define VUNITIZE_TOL
Definition vmath.h:298

Normalize vector ‘v’ to be a unit vector.

Definition at line 1140 of file vmath.h.

◆ V2UNITIZE

#define V2UNITIZE (   v)
Value:
do { \
double _f = MAG2SQ(v); \
if (! NEAR_EQUAL(_f, 1.0, VUNITIZE_TOL)) { \
_f = sqrt(_f); \
V2SETALL((v), 0.0); \
} else { \
_f = 1.0/_f; \
(v)[X] *= _f; (v)[Y] *= _f; \
} \
} \
} while (0)
#define MAG2SQ(v)
Definition vmath.h:1388

Normalize 2D vector ‘v’ to be a unit vector.

Definition at line 1154 of file vmath.h.

◆ VADD2SCALE

#define VADD2SCALE (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = ((a)[X] + (b)[X]) * (s); \
(o)[Y] = ((a)[Y] + (b)[Y]) * (s); \
(o)[Z] = ((a)[Z] + (b)[Z]) * (s); \
} while (0)

Find the sum of two points, and scale the result. Often used to find the midpoint.

Definition at line 1171 of file vmath.h.

◆ VADD2SCALEN

#define VADD2SCALEN (   o,
  a,
  b,
  s,
 
)
Value:
do { \
size_t _vadd2scale; \
_vadd2scale < (size_t)(n); \
_vadd2scale++) { \
(o)[_vadd2scale] = ((a)[_vadd2scale] + (b)[_vadd2scale]) * (s); \
} \
} while (0)

Find the sum of two vectors of length ‘n’, and scale the result by ‘s’. Often used to find the midpoint.

Definition at line 1181 of file vmath.h.

◆ VSUB2SCALE

#define VSUB2SCALE (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = ((a)[X] - (b)[X]) * (s); \
(o)[Y] = ((a)[Y] - (b)[Y]) * (s); \
(o)[Z] = ((a)[Z] - (b)[Z]) * (s); \
} while (0)

Find the difference between two points, and scale result. Often used to compute bounding sphere radius given rpp points.

Definition at line 1194 of file vmath.h.

◆ VSUB2SCALEN

#define VSUB2SCALEN (   o,
  a,
  b,
  s,
 
)
Value:
do { \
size_t _vsub2scale; \
_vsub2scale < (size_t)(n); \
_vsub2scale++) { \
(o)[_vsub2scale] = ((a)[_vsub2scale] - (b)[_vsub2scale]) * (s); \
} \
} while (0)

Find the difference between two vectors of length ‘n’, and scale result by ‘s’.

Definition at line 1204 of file vmath.h.

◆ VCOMB2

#define VCOMB2 (   o,
  sa,
  va,
  sb,
  vb 
)
Value:
do { \
(o)[X] = (sa) * (va)[X] + (sb) * (vb)[X]; \
(o)[Y] = (sa) * (va)[Y] + (sb) * (vb)[Y]; \
(o)[Z] = (sa) * (va)[Z] + (sb) * (vb)[Z]; \
} while (0)

Combine together 2 vectors, both scaled by scalars.

Definition at line 1216 of file vmath.h.

◆ VCOMB2N

#define VCOMB2N (   o,
  sa,
  a,
  sb,
  b,
 
)
Value:
do { \
size_t _vcomb2; \
for (_vcomb2 = 0; \
_vcomb2 < (size_t)(n); \
_vcomb2++) { \
(o)[_vcomb2] = (sa) * (va)[_vcomb2] + (sb) * (vb)[_vcomb2]; \
} \
} while (0)

Combine together 2 vectors of length ‘n’, both scaled by scalars.

Definition at line 1226 of file vmath.h.

◆ VJOIN3

#define VJOIN3 (   o,
  a,
  sb,
  b,
  sc,
  c,
  sd,
 
)
Value:
do { \
(o)[X] = (a)[X] + (sb)*(b)[X] + (sc)*(c)[X] + (sd)*(d)[X]; \
(o)[Y] = (a)[Y] + (sb)*(b)[Y] + (sc)*(c)[Y] + (sd)*(d)[Y]; \
(o)[Z] = (a)[Z] + (sb)*(b)[Z] + (sc)*(c)[Z] + (sd)*(d)[Z]; \
} while (0)

Join three scaled vectors to a base ‘a’, storing the result in ‘o’.

Definition at line 1238 of file vmath.h.

◆ VJOIN2

#define VJOIN2 (   o,
  a,
  sb,
  b,
  sc,
 
)
Value:
do { \
(o)[X] = (a)[X] + (sb) * (b)[X] + (sc) * (c)[X]; \
(o)[Y] = (a)[Y] + (sb) * (b)[Y] + (sc) * (c)[Y]; \
(o)[Z] = (a)[Z] + (sb) * (b)[Z] + (sc) * (c)[Z]; \
} while (0)

Compose 3D vector at ‘o’ of: Vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’ plus scalar ‘sc’ times vector at ‘c’.

Definition at line 1251 of file vmath.h.

◆ V2JOIN2

#define V2JOIN2 (   o,
  a,
  sb,
  b,
  sc,
 
)
Value:
do { \
(o)[X] = (a)[X] + (sb) * (b)[X] + (sc) * (c)[X]; \
(o)[Y] = (a)[Y] + (sb) * (b)[Y] + (sc) * (c)[Y]; \
} while (0)

Compose 2D vector at ‘o’ of: Vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’ plus scalar ‘sc’ times vector at ‘c’.

Definition at line 1263 of file vmath.h.

◆ HJOIN2

#define HJOIN2 (   o,
  a,
  sb,
  b,
  sc,
 
)
Value:
do { \
(o)[X] = (a)[X] + (sb) * (b)[X] + (sc) * (c)[X]; \
(o)[Y] = (a)[Y] + (sb) * (b)[Y] + (sc) * (c)[Y]; \
(o)[Z] = (a)[Z] + (sb) * (b)[Z] + (sc) * (c)[Z]; \
(o)[W] = (a)[W] + (sb) * (b)[W] + (sc) * (c)[W]; \
} while (0)

Compose 4D vector at ‘o’ of: Vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’ plus scalar ‘sc’ times vector at ‘c’.

Definition at line 1274 of file vmath.h.

◆ VJOIN2N

#define VJOIN2N (   o,
  a,
  sb,
  b,
  sc,
  c,
 
)
Value:
do { \
size_t _vjoin2; \
for (_vjoin2 = 0; \
_vjoin2 < (size_t)(n); \
_vjoin2++) { \
(o)[_vjoin2] = (a)[_vjoin2] + (sb) * (b)[_vjoin2] + (sc) * (c)[_vjoin2]; \
} \
} while (0)

Definition at line 1281 of file vmath.h.

◆ VJOIN1

#define VJOIN1 (   o,
  a,
  sb,
 
)
Value:
do { \
(o)[X] = (a)[X] + (sb) * (b)[X]; \
(o)[Y] = (a)[Y] + (sb) * (b)[Y]; \
(o)[Z] = (a)[Z] + (sb) * (b)[Z]; \
} while (0)

Compose 3D vector at ‘o’ of: vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’

This is basically a shorthand for VSCALE();VADD2();.

Definition at line 1298 of file vmath.h.

◆ V2JOIN1

#define V2JOIN1 (   o,
  a,
  sb,
 
)
Value:
do { \
(o)[X] = (a)[X] + (sb) * (b)[X]; \
(o)[Y] = (a)[Y] + (sb) * (b)[Y]; \
} while (0)

Compose 2D vector at ‘o’ of: vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’

This is basically a shorthand for V2SCALE();V2ADD2();.

Definition at line 1311 of file vmath.h.

◆ HJOIN1

#define HJOIN1 (   o,
  a,
  sb,
 
)
Value:
do { \
(o)[X] = (a)[X] + (sb) * (b)[X]; \
(o)[Y] = (a)[Y] + (sb) * (b)[Y]; \
(o)[Z] = (a)[Z] + (sb) * (b)[Z]; \
(o)[W] = (a)[W] + (sb) * (b)[W]; \
} while (0)

Compose 4D vector at ‘o’ of: vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’

This is basically a shorthand for HSCALE();HADD2();.

Definition at line 1323 of file vmath.h.

◆ VJOIN1N

#define VJOIN1N (   o,
  a,
  sb,
  b,
 
)
Value:
do { \
size_t _vjoin1; \
for (_vjoin1 = 0; \
_vjoin1 < (size_t)(n); \
_vjoin1++) { \
(o)[_vjoin1] = (a)[_vjoin1] + (sb) * (b)[_vjoin1]; \
} \
} while (0)

Compose ‘n’-D vector at ‘o’ of: vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’

This is basically a shorthand for VSCALEN();VADD2N();.

Definition at line 1337 of file vmath.h.

◆ VBLEND2

#define VBLEND2 (   o,
  sa,
  a,
  sb,
 
)
Value:
do { \
(o)[X] = (sa) * (a)[X] + (sb) * (b)[X]; \
(o)[Y] = (sa) * (a)[Y] + (sb) * (b)[Y]; \
(o)[Z] = (sa) * (a)[Z] + (sb) * (b)[Z]; \
} while (0)

Blend into vector ‘o’ scalar ‘sa’ times vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’.

Definition at line 1352 of file vmath.h.

◆ VBLEND2N

#define VBLEND2N (   o,
  sa,
  a,
  sb,
  b,
 
)
Value:
do { \
size_t _vblend2; \
for (_vblend2 = 0; \
_vblend2 < (size_t)(n); \
_vblend2++) { \
(b)[_vblend2] = (sa) * (a)[_vblend2] + (sb) * (b)[_vblend2]; \
} \
} while (0)

Blend into vector ‘o’ scalar ‘sa’ times vector at ‘a’ plus scalar ‘sb’ times vector at ‘b’.

Definition at line 1363 of file vmath.h.

◆ VPROJECT

#define VPROJECT (   a,
  b,
  c,
 
)
Value:
do { \
VSCALE(c, b, VDOT(a, b) / VDOT(b, b)); \
VSUB2(d, a, c); \
} while (0)
#define VDOT(a, b)
Compute dot product of vectors at ‘a’ and ‘b’.
Definition vmath.h:1439

Project vector ‘a’ onto ‘b’ vector ‘c’ is the component of ‘a’ parallel to ‘b’ " `d' " " " " " orthogonal " ".

Todo:
consistency, the result should come first

Definition at line 1381 of file vmath.h.

◆ MAGSQ

#define MAGSQ (   v)    ((v)[X]*(v)[X] + (v)[Y]*(v)[Y] + (v)[Z]*(v)[Z])

Return scalar magnitude squared of vector at ‘v’.

Definition at line 1387 of file vmath.h.

◆ MAG2SQ

#define MAG2SQ (   v)    ((v)[X]*(v)[X] + (v)[Y]*(v)[Y])

Definition at line 1388 of file vmath.h.

◆ MAGNITUDE

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

Definition at line 1395 of file vmath.h.

◆ MAGNITUDE2

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

Definition at line 1401 of file vmath.h.

◆ VCROSS

#define VCROSS (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[Y] * (b)[Z] - (a)[Z] * (b)[Y]; \
(o)[Y] = (a)[Z] * (b)[X] - (a)[X] * (b)[Z]; \
(o)[Z] = (a)[X] * (b)[Y] - (a)[Y] * (b)[X]; \
} while (0)

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.

Definition at line 1418 of file vmath.h.

◆ V2CROSS

#define V2CROSS (   a,
 
)    ((a)[X] * (b)[Y] - (a)[Y] * (b)[X])

Return the analog of a cross product for 2D vectors ‘a’ and ‘b’ as a scalar value. If a = (ax, ay) and b = (bx, by), then the analog of a x b is det(a*b) = ax*by - ay*bx

Definition at line 1429 of file vmath.h.

◆ HCROSS

#define HCROSS (   a,
  b,
 
)
Todo:
implement me

Definition at line 1435 of file vmath.h.

◆ VDOT

#define VDOT (   a,
 
)    ((a)[X]*(b)[X] + (a)[Y]*(b)[Y] + (a)[Z]*(b)[Z])

Compute dot product of vectors at ‘a’ and ‘b’.

Definition at line 1439 of file vmath.h.

◆ V2DOT

#define V2DOT (   a,
 
)    ((a)[X]*(b)[X] + (a)[Y]*(b)[Y])

Definition at line 1441 of file vmath.h.

◆ HDOT

#define HDOT (   a,
 
)    ((a)[X]*(b)[X] + (a)[Y]*(b)[Y] + (a)[Z]*(b)[Z] + (a)[W]*(b)[W])

Definition at line 1443 of file vmath.h.

◆ VLERP

#define VLERP (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] * (1 - (t)) + (b)[X] * (t); \
(o)[Y] = (a)[Y] * (1 - (t)) + (b)[Y] * (t); \
(o)[Z] = (a)[Z] * (1 - (t)) + (b)[Z] * (t); \
} while (0)

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.

Definition at line 1455 of file vmath.h.

◆ V2LERP

#define V2LERP (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] * (1 - (t)) + (b)[X] * (t); \
(o)[Y] = (a)[Y] * (1 - (t)) + (b)[Y] * (t); \
} while (0)

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.

Definition at line 1470 of file vmath.h.

◆ HLERP

#define HLERP (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] * (1 - (t)) + (b)[X] * (t); \
(o)[Y] = (a)[Y] * (1 - (t)) + (b)[Y] * (t); \
(o)[Z] = (a)[Z] * (1 - (t)) + (b)[Z] * (t); \
(o)[W] = (a)[W] * (1 - (t)) + (b)[W] * (t); \
} while (0)

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.

Definition at line 1484 of file vmath.h.

◆ VSUB2DOT

#define VSUB2DOT (   _pt2,
  _pt,
  _vec 
)
Value:
(\
((_pt2)[X] - (_pt)[X]) * (_vec)[X] + \
((_pt2)[Y] - (_pt)[Y]) * (_vec)[Y] + \
((_pt2)[Z] - (_pt)[Z]) * (_vec)[Z])

Subtract two points to make a vector, dot with another vector. Returns the dot product scalar value.

Definition at line 1496 of file vmath.h.

◆ V2ARGS

#define V2ARGS (   a)    (a)[X], (a)[Y]

Turn a vector into comma-separated list of elements, for variable argument subroutines (e.g. printf()).

Definition at line 1505 of file vmath.h.

◆ V3ARGS

#define V3ARGS (   a)    (a)[X], (a)[Y], (a)[Z]

Definition at line 1506 of file vmath.h.

◆ V4ARGS

#define V4ARGS (   a)    (a)[X], (a)[Y], (a)[Z], (a)[W]

Definition at line 1507 of file vmath.h.

◆ INTCLAMP

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

Definition at line 1518 of file vmath.h.

◆ VINTCLAMP

#define VINTCLAMP (   _v)
Value:
do { \
(_v)[X] = INTCLAMP((_v)[X]); \
(_v)[Y] = INTCLAMP((_v)[Y]); \
(_v)[Z] = INTCLAMP((_v)[Z]); \
} while (0)
#define INTCLAMP(_a)
Definition vmath.h:1518

Clamp a 3D vector's elements to nearby integer values.

Definition at line 1521 of file vmath.h.

◆ V2INTCLAMP

#define V2INTCLAMP (   _v)
Value:
do { \
(_v)[X] = INTCLAMP((_v)[X]); \
(_v)[Y] = INTCLAMP((_v)[Y]); \
} while (0)

Clamp a 2D vector's elements to nearby integer values.

Definition at line 1528 of file vmath.h.

◆ HINTCLAMP

#define HINTCLAMP (   _v)
Value:
do { \
(_v)[W] = INTCLAMP((_v)[W]); \
} while (0)

Clamp a 4D vector's elements to nearby integer values.

Definition at line 1534 of file vmath.h.

◆ V2INTCLAMPARGS

#define V2INTCLAMPARGS (   a)    INTCLAMP((a)[X]), INTCLAMP((a)[Y])

integer clamped versions of the previous arg macros.

Definition at line 1541 of file vmath.h.

◆ V3INTCLAMPARGS

#define V3INTCLAMPARGS (   a)    INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z])

integer clamped versions of the previous arg macros.

Definition at line 1543 of file vmath.h.

◆ V4INTCLAMPARGS

#define V4INTCLAMPARGS (   a)    INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z]), INTCLAMP((a)[W])

integer clamped versions of the previous arg macros.

Definition at line 1545 of file vmath.h.

◆ V2PRINT

#define V2PRINT (   a,
 
)     fprintf(stderr, "%s (%.6f, %.6g)\n", a, V2ARGS(b));

Print vector name and components on stderr.

Definition at line 1548 of file vmath.h.

◆ VPRINT

#define VPRINT (   a,
 
)     fprintf(stderr, "%s (%.6f, %.6f, %.6f)\n", a, V3ARGS(b));

Definition at line 1550 of file vmath.h.

◆ HPRINT

#define HPRINT (   a,
 
)     fprintf(stderr, "%s (%.6f, %.6f, %.6f, %.6f)\n", a, V4ARGS(b));

Definition at line 1552 of file vmath.h.

◆ V2INTCLAMPPRINT

#define V2INTCLAMPPRINT (   a,
 
)     fprintf(stderr, "%s (%g, %g)\n", a, V2INTCLAMPARGS(b));

Included below are integer clamped versions of the previous print macros.

Definition at line 1560 of file vmath.h.

◆ VINTCLAMPPRINT

#define VINTCLAMPPRINT (   a,
 
)     fprintf(stderr, "%s (%g, %g, %g)\n", a, V3INTCLAMPARGS(b));

Definition at line 1562 of file vmath.h.

◆ HINTCLAMPPRINT

#define HINTCLAMPPRINT (   a,
 
)     fprintf(stderr, "%s (%g, %g, %g, %g)\n", a, V4INTCLAMPARGS(b));

Definition at line 1564 of file vmath.h.

◆ VELMUL

#define VELMUL (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[X] * (b)[X]; \
(o)[Y] = (a)[Y] * (b)[Y]; \
(o)[Z] = (a)[Z] * (b)[Z]; \
} while (0)

Vector element multiplication. Really: diagonal matrix X vect.

Definition at line 1569 of file vmath.h.

◆ VELMUL3

#define VELMUL3 (   o,
  a,
  b,
 
)
Value:
do { \
(o)[X] = (a)[X] * (b)[X] * (c)[X]; \
(o)[Y] = (a)[Y] * (b)[Y] * (c)[Y]; \
(o)[Z] = (a)[Z] * (b)[Z] * (c)[Z]; \
} while (0)

Definition at line 1575 of file vmath.h.

◆ VELDIV

#define VELDIV (   o,
  a,
 
)
Value:
do { \
(o)[X] = (a)[X] / (b)[X]; \
(o)[Y] = (a)[Y] / (b)[Y]; \
(o)[Z] = (a)[Z] / (b)[Z]; \
} while (0)

Similar to VELMUL.

Definition at line 1582 of file vmath.h.

◆ VINVDIR

#define VINVDIR (   _inv,
  _dir 
)
Value:
do { \
(_inv)[X]=1.0/(_dir)[X]; \
} else { \
(_dir)[X] = 0.0; \
(_inv)[X] = INFINITY; \
} \
(_inv)[Y]=1.0/(_dir)[Y]; \
} else { \
(_dir)[Y] = 0.0; \
(_inv)[Y] = INFINITY; \
} \
(_inv)[Z]=1.0/(_dir)[Z]; \
} else { \
(_dir)[Z] = 0.0; \
(_inv)[Z] = INFINITY; \
} \
} while (0)
#define INFINITY
Definition vmath.h:280
#define SQRT_SMALL_FASTF
Definition vmath.h:246

Given a direction vector, compute the inverses of each element. When division by zero would have occurred, mark inverse as INFINITY.

Definition at line 1592 of file vmath.h.

◆ MAT3X3VEC

#define MAT3X3VEC (   o,
  mat,
  vec 
)
Value:
do { \
(o)[X] = (mat)[X]*(vec)[X]+(mat)[Y]*(vec)[Y] + (mat)[ 2]*(vec)[Z]; \
(o)[Y] = (mat)[4]*(vec)[X]+(mat)[5]*(vec)[Y] + (mat)[ 6]*(vec)[Z]; \
(o)[Z] = (mat)[8]*(vec)[X]+(mat)[9]*(vec)[Y] + (mat)[10]*(vec)[Z]; \
} while (0)

Apply the 3x3 part of a mat_t to a 3-tuple. This rotates a vector without scaling it (changing its length).

Definition at line 1617 of file vmath.h.

◆ VEC3X3MAT

#define VEC3X3MAT (   o,
  i,
 
)
Value:
do { \
(o)[X] = (i)[X]*(m)[X] + (i)[Y]*(m)[4] + (i)[Z]*(m)[8]; \
(o)[Y] = (i)[X]*(m)[1] + (i)[Y]*(m)[5] + (i)[Z]*(m)[9]; \
(o)[Z] = (i)[X]*(m)[2] + (i)[Y]*(m)[6] + (i)[Z]*(m)[10]; \
} while (0)

Multiply a 3-tuple by the 3x3 part of a mat_t.

Definition at line 1624 of file vmath.h.

◆ MAT3X2VEC

#define MAT3X2VEC (   o,
  mat,
  vec 
)
Value:
do { \
(o)[X] = (mat)[0]*(vec)[X] + (mat)[Y]*(vec)[Y]; \
(o)[Y] = (mat)[4]*(vec)[X] + (mat)[5]*(vec)[Y]; \
(o)[Z] = (mat)[8]*(vec)[X] + (mat)[9]*(vec)[Y]; \
} while (0)

Apply the 3x3 part of a mat_t to a 2-tuple (Z part=0).

Definition at line 1631 of file vmath.h.

◆ VEC2X3MAT

#define VEC2X3MAT (   o,
  i,
 
)
Value:
do { \
(o)[X] = (i)[X]*(m)[0] + (i)[Y]*(m)[4]; \
(o)[Y] = (i)[X]*(m)[1] + (i)[Y]*(m)[5]; \
(o)[Z] = (i)[X]*(m)[2] + (i)[Y]*(m)[6]; \
} while (0)

Multiply a 2-tuple (Z=0) by the 3x3 part of a mat_t.

Definition at line 1638 of file vmath.h.

◆ MAT4X3PNT

#define MAT4X3PNT (   o,
  m,
 
)
Value:
do { \
double _f; \
_f = 1.0/((m)[12]*(i)[X] + (m)[13]*(i)[Y] + (m)[14]*(i)[Z] + (m)[15]); \
(o)[X]=((m)[0]*(i)[X] + (m)[1]*(i)[Y] + (m)[ 2]*(i)[Z] + (m)[3]) * _f; \
(o)[Y]=((m)[4]*(i)[X] + (m)[5]*(i)[Y] + (m)[ 6]*(i)[Z] + (m)[7]) * _f; \
(o)[Z]=((m)[8]*(i)[X] + (m)[9]*(i)[Y] + (m)[10]*(i)[Z] + (m)[11])* _f; \
} while (0)

Apply a 4x4 matrix to a 3-tuple which is an absolute Point in space. Output and input points should be separate arrays.

Definition at line 1648 of file vmath.h.

◆ PNT3X4MAT

#define PNT3X4MAT (   o,
  i,
 
)
Value:
do { \
double _f; \
_f = 1.0/((i)[X]*(m)[3] + (i)[Y]*(m)[7] + (i)[Z]*(m)[11] + (m)[15]); \
(o)[X]=((i)[X]*(m)[0] + (i)[Y]*(m)[4] + (i)[Z]*(m)[8] + (m)[12]) * _f; \
(o)[Y]=((i)[X]*(m)[1] + (i)[Y]*(m)[5] + (i)[Z]*(m)[9] + (m)[13]) * _f; \
(o)[Z]=((i)[X]*(m)[2] + (i)[Y]*(m)[6] + (i)[Z]*(m)[10] + (m)[14])* _f; \
} while (0)

Multiply an Absolute 3-Point by a full 4x4 matrix. Output and input points should be separate arrays.

Definition at line 1660 of file vmath.h.

◆ MAT4X4PNT

#define MAT4X4PNT (   o,
  m,
 
)
Value:
do { \
(o)[X]=(m)[ 0]*(i)[X] + (m)[ 1]*(i)[Y] + (m)[ 2]*(i)[Z] + (m)[ 3]*(i)[W]; \
(o)[Y]=(m)[ 4]*(i)[X] + (m)[ 5]*(i)[Y] + (m)[ 6]*(i)[Z] + (m)[ 7]*(i)[W]; \
(o)[Z]=(m)[ 8]*(i)[X] + (m)[ 9]*(i)[Y] + (m)[10]*(i)[Z] + (m)[11]*(i)[W]; \
(o)[W]=(m)[12]*(i)[X] + (m)[13]*(i)[Y] + (m)[14]*(i)[Z] + (m)[15]*(i)[W]; \
} while (0)

Multiply an Absolute hvect_t 4-Point by a full 4x4 matrix. Output and input points should be separate arrays.

Definition at line 1672 of file vmath.h.

◆ MAT4X3VEC

#define MAT4X3VEC (   o,
  m,
 
)
Value:
do { \
double _f; \
_f = 1.0/((m)[15]); \
(o)[X] = ((m)[0]*(i)[X] + (m)[1]*(i)[Y] + (m)[ 2]*(i)[Z]) * _f; \
(o)[Y] = ((m)[4]*(i)[X] + (m)[5]*(i)[Y] + (m)[ 6]*(i)[Z]) * _f; \
(o)[Z] = ((m)[8]*(i)[X] + (m)[9]*(i)[Y] + (m)[10]*(i)[Z]) * _f; \
} while (0)

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.

Definition at line 1684 of file vmath.h.

◆ MAT4XSCALOR

#define MAT4XSCALOR (   o,
  m,
 
)
Value:
do { \
(o) = (i) / (m)[15]; \
} while (0)

Definition at line 1692 of file vmath.h.

◆ VEC3X4MAT

#define VEC3X4MAT (   o,
  i,
 
)
Value:
do { \
double _f; \
_f = 1.0/((m)[15]); \
(o)[X] = ((i)[X]*(m)[0] + (i)[Y]*(m)[4] + (i)[Z]*(m)[8]) * _f; \
(o)[Y] = ((i)[X]*(m)[1] + (i)[Y]*(m)[5] + (i)[Z]*(m)[9]) * _f; \
(o)[Z] = ((i)[X]*(m)[2] + (i)[Y]*(m)[6] + (i)[Z]*(m)[10]) * _f; \
} while (0)

Multiply a Relative 3-Vector by most of a 4x4 matrix. Output and input vectors should be separate arrays.

Definition at line 1700 of file vmath.h.

◆ VEC2X4MAT

#define VEC2X4MAT (   o,
  i,
 
)
Value:
do { \
double _f; \
_f = 1.0/((m)[15]); \
(o)[X] = ((i)[X]*(m)[0] + (i)[Y]*(m)[4]) * _f; \
(o)[Y] = ((i)[X]*(m)[1] + (i)[Y]*(m)[5]) * _f; \
(o)[Z] = ((i)[X]*(m)[2] + (i)[Y]*(m)[6]) * _f; \
} while (0)

Multiply a Relative 2-Vector by most of a 4x4 matrix.

Definition at line 1709 of file vmath.h.

◆ V_MIN

#define V_MIN (   r,
 
)    if ((r) > (s)) r = (s)

Included below are macros to update min and max X, Y, Z values to contain a point.

Definition at line 1722 of file vmath.h.

◆ V_MAX

#define V_MAX (   r,
 
)    if ((r) < (s)) r = (s)

Definition at line 1724 of file vmath.h.

◆ VMIN

#define VMIN (   r,
 
)
Value:
do { \
V_MIN((r)[X], (s)[X]); V_MIN((r)[Y], (s)[Y]); V_MIN((r)[Z], (s)[Z]); \
} while (0)
#define V_MIN(r, s)
Included below are macros to update min and max X, Y, Z values to contain a point.
Definition vmath.h:1722

Definition at line 1729 of file vmath.h.

◆ VMAX

#define VMAX (   r,
 
)
Value:
do { \
V_MAX((r)[X], (s)[X]); V_MAX((r)[Y], (s)[Y]); V_MAX((r)[Z], (s)[Z]); \
} while (0)
#define V_MAX(r, s)
Definition vmath.h:1724

Definition at line 1736 of file vmath.h.

◆ VMINMAX

#define VMINMAX (   min,
  max,
  pt 
)
Value:
do { \
VMIN((min), (pt)); VMAX((max), (pt)); \
} while (0)
#define VMAX(r, s)
Definition vmath.h:1736

Definition at line 1743 of file vmath.h.

◆ V2MIN

#define V2MIN (   r,
 
)
Value:
do { \
V_MIN((r)[X], (s)[X]); V_MIN((r)[Y], (s)[Y]); \
} while (0)

Included below are macros to update min and max X, Y values to contain a point.

Definition at line 1752 of file vmath.h.

◆ V2MAX

#define V2MAX (   r,
 
)
Value:
do { \
V_MAX((r)[X], (s)[X]); V_MAX((r)[Y], (s)[Y]); \
} while (0)

Definition at line 1756 of file vmath.h.

◆ V2MINMAX

#define V2MINMAX (   min,
  max,
  pt 
)
Value:
do { \
V2MIN((min), (pt)); V2MAX((max), (pt)); \
} while (0)
#define V2MAX(r, s)
Definition vmath.h:1756

Definition at line 1760 of file vmath.h.

◆ CLAMP

#define CLAMP (   _v,
  _l,
  _h 
)    V_MAX((_v), (_l)); else V_MIN((_v), (_h))

clamp a value to a low/high number.

Definition at line 1767 of file vmath.h.

◆ HDIVIDE

#define HDIVIDE (   o,
 
)
Value:
do { \
(o)[X] = (v)[X] / (v)[W]; \
(o)[Y] = (v)[Y] / (v)[W]; \
(o)[Z] = (v)[Z] / (v)[W]; \
} while (0)

Divide out homogeneous parameter from hvect_t, creating vect_t.

Definition at line 1774 of file vmath.h.

◆ QUAT_FROM_ROT

#define QUAT_FROM_ROT (   q,
  r,
  x,
  y,
  z 
)
Value:
do { \
fastf_t _rot = (r) * 0.5; \
QSET(q, x, y, z, cos(_rot)); \
VUNITIZE(q); \
_rot = sin(_rot); /* _rot is really just a temp variable now */ \
VSCALE(q, q, _rot); \
} while (0)
double fastf_t
fastest 64-bit (or larger) floating point type
Definition vmath.h:333

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

Definition at line 1803 of file vmath.h.

◆ QUAT_FROM_VROT

#define QUAT_FROM_VROT (   q,
  r,
 
)
Value:
do { \
fastf_t _rot = (r) * 0.5; \
VMOVE(q, v); \
VUNITIZE(q); \
(q)[W] = cos(_rot); \
_rot = sin(_rot); /* _rot is really just a temp variable now */ \
VSCALE(q, q, _rot); \
} while (0)

Definition at line 1811 of file vmath.h.

◆ QUAT_FROM_VROT_DEG

#define QUAT_FROM_VROT_DEG (   q,
  r,
 
)     QUAT_FROM_VROT(q, ((r)*DEG2RAD), v)

Definition at line 1820 of file vmath.h.

◆ QUAT_FROM_ROT_DEG

#define QUAT_FROM_ROT_DEG (   q,
  r,
  x,
  y,
  z 
)     QUAT_FROM_ROT(q, ((r)*DEG2RAD), x, y, z)

Definition at line 1823 of file vmath.h.

◆ QSET

#define QSET (   a,
  b,
  c,
  d,
 
)
Value:
do { \
(a)[X] = (b); \
(a)[Y] = (c); \
(a)[Z] = (d); \
(a)[W] = (e); \
} while (0)

Set quaternion at ‘a’ to have coordinates ‘b’, ‘c’, ‘d’, and ‘e’.

Definition at line 1831 of file vmath.h.

◆ QMOVE

#define QMOVE (   a,
 
)
Value:
do { \
(a)[X] = (b)[X]; \
(a)[Y] = (b)[Y]; \
(a)[Z] = (b)[Z]; \
(a)[W] = (b)[W]; \
} while (0)

Transfer quaternion at ‘b’ to quaternion at ‘a’.

Definition at line 1839 of file vmath.h.

◆ QADD2

#define QADD2 (   a,
  b,
 
)
Value:
do { \
(a)[X] = (b)[X] + (c)[X]; \
(a)[Y] = (b)[Y] + (c)[Y]; \
(a)[Z] = (b)[Z] + (c)[Z]; \
(a)[W] = (b)[W] + (c)[W]; \
} while (0)

Add quaternions at ‘b’ and ‘c’, store result at ‘a’.

Definition at line 1847 of file vmath.h.

◆ QSUB2

#define QSUB2 (   a,
  b,
 
)
Value:
do { \
(a)[X] = (b)[X] - (c)[X]; \
(a)[Y] = (b)[Y] - (c)[Y]; \
(a)[Z] = (b)[Z] - (c)[Z]; \
(a)[W] = (b)[W] - (c)[W]; \
} while (0)

Subtract quaternion at ‘c’ from quaternion at ‘b’, store result at ‘a’.

Definition at line 1858 of file vmath.h.

◆ QSCALE

#define QSCALE (   a,
  b,
 
)
Value:
do { \
(a)[X] = (b)[X] * (c); \
(a)[Y] = (b)[Y] * (c); \
(a)[Z] = (b)[Z] * (c); \
(a)[W] = (b)[W] * (c); \
} while (0)

Scale quaternion at ‘b’ by scalar ‘c’, store result at ‘a’.

Definition at line 1869 of file vmath.h.

◆ QUNITIZE

#define QUNITIZE (   a)
Value:
do { \
double _f; \
_f = QMAGNITUDE(a); \
if (_f < VDIVIDE_TOL) _f = 0.0; else _f = 1.0/_f; \
(a)[X] *= _f; (a)[Y] *= _f; (a)[Z] *= _f; (a)[W] *= _f; \
} while (0)
#define QMAGNITUDE(a)
Return scalar magnitude of quaternion at ‘a’.
Definition vmath.h:1890

Normalize quaternion 'a' to be a unit quaternion.

Definition at line 1877 of file vmath.h.

◆ QMAGSQ

#define QMAGSQ (   a)
Value:
((a)[X]*(a)[X] + (a)[Y]*(a)[Y] \
+ (a)[Z]*(a)[Z] + (a)[W]*(a)[W])

Return scalar magnitude squared of quaternion at ‘a’.

Definition at line 1885 of file vmath.h.

◆ QMAGNITUDE

#define QMAGNITUDE (   a)    sqrt(QMAGSQ(a))

Return scalar magnitude of quaternion at ‘a’.

Definition at line 1890 of file vmath.h.

◆ QDOT

#define QDOT (   a,
 
)
Value:
((a)[X]*(b)[X] + (a)[Y]*(b)[Y] \
+ (a)[Z]*(b)[Z] + (a)[W]*(b)[W])

Compute dot product of quaternions at ‘a’ and ‘b’.

Definition at line 1893 of file vmath.h.

◆ QMUL

#define QMUL (   a,
  b,
 
)
Value:
do { \
(a)[W] = (b)[W]*(c)[W] - (b)[X]*(c)[X] - (b)[Y]*(c)[Y] - (b)[Z]*(c)[Z]; \
(a)[X] = (b)[W]*(c)[X] + (b)[X]*(c)[W] + (b)[Y]*(c)[Z] - (b)[Z]*(c)[Y]; \
(a)[Y] = (b)[W]*(c)[Y] + (b)[Y]*(c)[W] + (b)[Z]*(c)[X] - (b)[X]*(c)[Z]; \
(a)[Z] = (b)[W]*(c)[Z] + (b)[Z]*(c)[W] + (b)[X]*(c)[Y] - (b)[Y]*(c)[X]; \
} while (0)

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

Definition at line 1904 of file vmath.h.

◆ QCONJUGATE

#define QCONJUGATE (   a,
 
)
Value:
do { \
(a)[X] = -(b)[X]; \
(a)[Y] = -(b)[Y]; \
(a)[Z] = -(b)[Z]; \
(a)[W] = (b)[W]; \
} while (0)

Conjugate quaternion.

Definition at line 1912 of file vmath.h.

◆ QINVERSE

#define QINVERSE (   a,
 
)
Value:
do { \
double _f = QMAGSQ(b); \
if (_f < VDIVIDE_TOL) _f = 0.0; else _f = 1.0/_f; \
(a)[X] = -(b)[X] * _f; \
(a)[Y] = -(b)[Y] * _f; \
(a)[Z] = -(b)[Z] * _f; \
(a)[W] = (b)[W] * _f; \
} while (0)
#define QMAGSQ(a)
Return scalar magnitude squared of quaternion at ‘a’.
Definition vmath.h:1885

Multiplicative inverse quaternion.

Definition at line 1920 of file vmath.h.

◆ QBLEND2

#define QBLEND2 (   a,
  b,
  c,
  d,
 
)
Value:
do { \
(a)[X] = (b) * (c)[X] + (d) * (e)[X]; \
(a)[Y] = (b) * (c)[Y] + (d) * (e)[Y]; \
(a)[Z] = (b) * (c)[Z] + (d) * (e)[Z]; \
(a)[W] = (b) * (c)[W] + (d) * (e)[W]; \
} while (0)

Blend into quaternion ‘a’.

scalar ‘b’ times quaternion at ‘c’ plus scalar ‘d’ times quaternion at ‘e’

Definition at line 1935 of file vmath.h.

◆ V3RPP_DISJOINT

#define V3RPP_DISJOINT (   _l1,
  _h1,
  _l2,
  _h2 
)
Value:
((_l1)[X] > (_h2)[X] || (_l1)[Y] > (_h2)[Y] || (_l1)[Z] > (_h2)[Z] || \
(_l2)[X] > (_h1)[X] || (_l2)[Y] > (_h1)[Y] || (_l2)[Z] > (_h1)[Z])

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.

Definition at line 1952 of file vmath.h.

◆ V3RPP_DISJOINT_TOL

#define V3RPP_DISJOINT_TOL (   _l1,
  _h1,
  _l2,
  _h2,
  _t 
)
Value:
((_l1)[X] > (_h2)[X] + (_t) || \
(_l1)[Y] > (_h2)[Y] + (_t) || \
(_l1)[Z] > (_h2)[Z] + (_t) || \
(_l2)[X] > (_h1)[X] + (_t) || \
(_l2)[Y] > (_h1)[Y] + (_t) || \
(_l2)[Z] > (_h1)[Z] + (_t))

Compare two bounding boxes and return true if they are disjoint by at least distance tolerance.

Definition at line 1960 of file vmath.h.

◆ V3RPP_OVERLAP

#define V3RPP_OVERLAP (   _l1,
  _h1,
  _l2,
  _h2 
)
Value:
(! ((_l1)[X] > (_h2)[X] || (_l1)[Y] > (_h2)[Y] || (_l1)[Z] > (_h2)[Z] || \
(_l2)[X] > (_h1)[X] || (_l2)[Y] > (_h1)[Y] || (_l2)[Z] > (_h1)[Z]))

Compare two bounding boxes and return true If they overlap.

Definition at line 1969 of file vmath.h.

◆ V3RPP_OVERLAP_TOL

#define V3RPP_OVERLAP_TOL (   _l1,
  _h1,
  _l2,
  _h2,
  _t 
)
Value:
(! ((_l1)[X] > (_h2)[X] + (_t) || \
(_l1)[Y] > (_h2)[Y] + (_t) || \
(_l1)[Z] > (_h2)[Z] + (_t) || \
(_l2)[X] > (_h1)[X] + (_t) || \
(_l2)[Y] > (_h1)[Y] + (_t) || \
(_l2)[Z] > (_h1)[Z] + (_t)))

If two extents overlap within distance tolerance, return true.

Definition at line 1977 of file vmath.h.

◆ V3PNT_IN_RPP

#define V3PNT_IN_RPP (   _pt,
  _lo,
  _hi 
)
Value:
(\
(_pt)[X] >= (_lo)[X] && (_pt)[X] <= (_hi)[X] && \
(_pt)[Y] >= (_lo)[Y] && (_pt)[Y] <= (_hi)[Y] && \
(_pt)[Z] >= (_lo)[Z] && (_pt)[Z] <= (_hi)[Z])

Is the point within or on the boundary of the RPP?

Todo:
should not be using >= <=, '=' case is unreliable

Definition at line 1991 of file vmath.h.

◆ V3PNT_IN_RPP_TOL

#define V3PNT_IN_RPP_TOL (   _pt,
  _lo,
  _hi,
  _t 
)
Value:
(\
(_pt)[X] >= (_lo)[X]-(_t) && (_pt)[X] <= (_hi)[X]+(_t) && \
(_pt)[Y] >= (_lo)[Y]-(_t) && (_pt)[Y] <= (_hi)[Y]+(_t) && \
(_pt)[Z] >= (_lo)[Z]-(_t) && (_pt)[Z] <= (_hi)[Z]+(_t))

Within the distance tolerance, is the point within the RPP?

Todo:
should not be using >= <=, '=' case is unreliable

Definition at line 2002 of file vmath.h.

◆ V3PNT_OUT_RPP_TOL

#define V3PNT_OUT_RPP_TOL (   _pt,
  _lo,
  _hi,
  _t 
)
Value:
(\
(_pt)[X] < (_lo)[X]-(_t) || (_pt)[X] > (_hi)[X]+(_t) || \
(_pt)[Y] < (_lo)[Y]-(_t) || (_pt)[Y] > (_hi)[Y]+(_t) || \
(_pt)[Z] < (_lo)[Z]-(_t) || (_pt)[Z] > (_hi)[Z]+(_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.

Definition at line 2011 of file vmath.h.

◆ V3RPP1_IN_RPP2

#define V3RPP1_IN_RPP2 (   _lo1,
  _hi1,
  _lo2,
  _hi2 
)
Value:
(\
(_lo1)[X] >= (_lo2)[X] && (_hi1)[X] <= (_hi2)[X] && \
(_lo1)[Y] >= (_lo2)[Y] && (_hi1)[Y] <= (_hi2)[Y] && \
(_lo1)[Z] >= (_lo2)[Z] && (_hi1)[Z] <= (_hi2)[Z])

Determine if one bounding box is within another. Also returns true if the boxes are the same.

Todo:
should not be using >= <=, '=' case is unreliable

Definition at line 2023 of file vmath.h.

◆ VSWAP

#define VSWAP (   _a,
  _b 
)
Value:
do { \
_t = (_a)[X]; \
(_a)[X] = (_b)[X]; \
(_b)[X] = _t; \
_t = (_a)[Y]; \
(_a)[Y] = (_b)[Y]; \
(_b)[Y] = _t; \
_t = (_a)[Z]; \
(_a)[Z] = (_b)[Z]; \
(_b)[Z] = _t; \
} while (0)

Swap two 3D vectors

Definition at line 2030 of file vmath.h.

◆ V2SWAP

#define V2SWAP (   _a,
  _b 
)
Value:
do { \
_t = (_a)[X]; \
(_a)[X] = (_b)[X]; \
(_b)[X] = _t; \
_t = (_a)[Y]; \
(_a)[Y] = (_b)[Y]; \
(_b)[Y] = _t; \
} while (0)

Swap two 2D vectors

Definition at line 2044 of file vmath.h.

◆ HSWAP

#define HSWAP (   _a,
  _b 
)
Value:
do { \
_t = (_a)[X]; \
(_a)[X] = (_b)[X]; \
(_b)[X] = _t; \
_t = (_a)[Y]; \
(_a)[Y] = (_b)[Y]; \
(_b)[Y] = _t; \
_t = (_a)[Z]; \
(_a)[Z] = (_b)[Z]; \
(_b)[Z] = _t; \
_t = (_a)[W]; \
(_a)[W] = (_b)[W]; \
(_b)[W] = _t; \
} while (0)

Swap two 4D vectors

Definition at line 2055 of file vmath.h.

◆ MAT_SWAP

#define MAT_SWAP (   _a,
  _b 
)
Value:
do { \
MAT_COPY((_a), (_b)); \
MAT_COPY((_b), _t); \
} while (0)
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition vmath.h:369

Swap two 4x4 matrices

Definition at line 2072 of file vmath.h.

◆ VINITALL

#define VINITALL (   _v)    {(_v), (_v), (_v)}

3D vector macro suitable for declaration statement initialization. this sets all vector elements to the specified value similar to VSETALL() but as an initializer array declaration instead of as a statement.

Definition at line 2087 of file vmath.h.

◆ V2INITALL

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

Definition at line 2095 of file vmath.h.

◆ HINITALL

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

Definition at line 2103 of file vmath.h.

◆ VINIT_ZERO

#define VINIT_ZERO   {0.0, 0.0, 0.0}

3D vector macro suitable for declaration statement initialization. this sets all vector elements to zero similar to calling VSETALL(0.0) but as an initializer array declaration instead of as a statement.

Definition at line 2111 of file vmath.h.

◆ V2INIT_ZERO

#define V2INIT_ZERO   {0.0, 0.0}

2D vector macro suitable for declaration statement initialization. this sets all vector elements to zero similar to calling V2SETALL(0.0) but as an initializer array declaration instead of as a statement.

Definition at line 2119 of file vmath.h.

◆ HINIT_ZERO

#define HINIT_ZERO   {0.0, 0.0, 0.0, 0.0}

4D homogeneous vector macro suitable for declaration statement initialization. this sets all vector elements to zero similar to calling VSETALLN(hvect_t,0.0,4) but as an initializer array declaration instead of as a statement.

Definition at line 2127 of file vmath.h.

◆ MAT_INIT_IDN

#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}

matrix macro suitable for declaration statement initialization. this sets up an identity matrix similar to calling MAT_IDN but as an initializer array declaration instead of as a statement.

Definition at line 2134 of file vmath.h.

◆ MAT_INIT_ZERO

#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}

matrix macro suitable for declaration statement initialization. this sets up a zero matrix similar to calling MAT_ZERO but as an initializer array declaration instead of as a statement.

Definition at line 2141 of file vmath.h.

Typedef Documentation

◆ fastf_t

fastest 64-bit (or larger) floating point type

Definition at line 333 of file vmath.h.

◆ vect2d_t

2-tuple vector

Definition at line 336 of file vmath.h.

◆ vect2dp_t

pointer to a 2-tuple vector

Definition at line 339 of file vmath.h.

◆ point2d_t

2-tuple point

Definition at line 342 of file vmath.h.

◆ point2dp_t

pointer to a 2-tuple point

Definition at line 345 of file vmath.h.

◆ vect_t

3-tuple vector

Definition at line 348 of file vmath.h.

◆ vectp_t

pointer to a 3-tuple vector

Definition at line 351 of file vmath.h.

◆ point_t

3-tuple point

Definition at line 354 of file vmath.h.

◆ pointp_t

pointer to a 3-tuple point

Definition at line 357 of file vmath.h.

◆ hvect_t

4-tuple vector

Definition at line 360 of file vmath.h.

◆ quat_t

4-element quaternion

Definition at line 363 of file vmath.h.

◆ hpoint_t

4-tuple point

Definition at line 366 of file vmath.h.

◆ mat_t

4x4 matrix

Definition at line 369 of file vmath.h.

◆ matp_t

pointer to a 4x4 matrix

Definition at line 372 of file vmath.h.

◆ plane_t

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

Definition at line 396 of file vmath.h.

◆ vmath_vector_component

Vector component names for homogeneous (4-tuple) vectors

◆ vmath_matrix_component

Locations of deltas (MD*) and scaling values (MS*) in a 4x4 Homogeneous Transform matrix

Enumeration Type Documentation

◆ vmath_vector_component_

Vector component names for homogeneous (4-tuple) vectors

Enumerator

Definition at line 399 of file vmath.h.

◆ vmath_matrix_component_

Locations of deltas (MD*) and scaling values (MS*) in a 4x4 Homogeneous Transform matrix

Enumerator
MSX 
MDX 
MSY 
MDY 
MSZ 
MDZ 
MSA 

Definition at line 411 of file vmath.h.