Files | |
file | vmath.h |
vector/matrix math | |
file | mat.c |
4 x 4 Matrix manipulation functions... | |
file | qmath.c |
Quaternion math routines. | |
Defines | |
#define | M_1_PI 0.31830988618379067153776752675 |
#define | M_2_PI 0.63661977236758134307553505349 |
#define | M_2_SQRTPI 1.12837916709551257389615890312 |
#define | M_E 2.71828182845904523536028747135 |
#define | M_EULER 0.57721566490153286060651209008 |
#define | M_LOG2E 1.44269504088896340735992468100 |
#define | M_LOG10E 0.43429448190325182765112891892 |
#define | M_LN10 2.30258509299404568401799145468 |
#define | M_LN2 0.69314718055994530941723212146 |
#define | M_LNPI 1.14472988584940017414342735135 |
#define | M_PI 3.14159265358979323846264338328 |
#define | M_PI_2 1.57079632679489661923132169164 |
#define | M_PI_4 0.78539816339744830966156608458 |
#define | M_SQRT1_2 0.70710678118654752440084436210 |
#define | M_SQRT2 1.41421356237309504880168872421 |
#define | M_SQRT3 1.73205080756887729352744634151 |
#define | M_SQRTPI 1.77245385090551602729816748334 |
#define | DEG2RAD 0.017453292519943295769236907684 |
#define | RAD2DEG 57.295779513082320876798154814105 |
#define | VDIVIDE_TOL (1.0e-20) |
#define | VUNITIZE_TOL (1.0e-15) |
#define | ELEMENTS_PER_VECT2D 2 |
# of fastf_t's per vect2d_t | |
#define | ELEMENTS_PER_POINT2D 2 |
# of fastf_t's per point2d_t | |
#define | ELEMENTS_PER_VECT 3 |
# of fastf_t's per vect_t | |
#define | ELEMENTS_PER_POINT 3 |
# of fastf_t's per point_t | |
#define | ELEMENTS_PER_HVECT 4 |
# of fastf_t's per hvect_t (homogeneous vector) | |
#define | ELEMENTS_PER_HPOINT 4 |
# of fastf_t's per hpt_t (homogeneous point) | |
#define | ELEMENTS_PER_PLANE 4 |
# of fastf_t's per plane_t | |
#define | ELEMENTS_PER_MAT (ELEMENTS_PER_PLANE*ELEMENTS_PER_PLANE) |
# of fastf_t's per mat_t | |
#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) ((a)[X]==(b)[X] && (a)[Y]==(b)[Y]) |
Compare two vectors for EXACT equality. Use carefully. Version for degree 2 vectors. FIXME: no such thing as exact. | |
#define | HEQUAL(a, b) ((a)[X]==(b)[X] && (a)[Y]==(b)[Y] && (a)[Z]==(b)[Z] && (a)[W]==(b)[W]) |
Compare two vectors for EXACT equality. Use carefully. Version for degree 4 vectors. FIXME: no such thing as exact. | |
#define | CLAMP(_v, _l, _h) if ((_v) < (_l)) _v = _l; else if ((_v) > (_h)) _v = _h |
#define | DIST_PT_PLANE(_pt, _pl) (VDOT(_pt, _pl) - (_pl)[W]) |
Compute distance from a point to a plane. | |
#define | DIST_PT_PT_SQ(_a, _b) |
Compute distance between two points. | |
#define | DIST_PT_PT(_a, _b) sqrt(DIST_PT_PT_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) |
multipy 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(d, s) |
Copy a matrix. | |
#define | VSET(a, b, c, d) |
Set 3D vector at `a' to have coordinates `b', `c', and `d'. | |
#define | V2SET(a, b, c) |
Set 2D vector at `a' to have coordinates `b' and `c'. | |
#define | HSET(a, b, c, d, e) |
Set 4D vector at `a' to homogenous coordinates `b', `c', `d', and `e'. | |
#define | VSETALL(a, s) |
Set all elements of 3D vector to same scalar value. | |
#define | V2SETALL(a, s) |
Set 2D vector elements to same scalar value. | |
#define | HSETALL(a, 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(a, b) |
Transfer 3D vector at `b' to vector at `a'. | |
#define | V2MOVE(a, b) |
Move a 2D vector. | |
#define | HMOVE(a, b) |
Move a homogeneous 4-tuple. | |
#define | VMOVEN(a, b, n) |
Transfer vector of length `n' at `b' to vector at `a'. | |
#define | VREVERSE(a, b) |
Reverse the direction of 3D vector `b' and store it in `a'. | |
#define | V2REVERSE(a, b) |
Reverse the direction of 2D vector `b' and store it in `a'. | |
#define | HREVERSE(a, b) |
Same as VREVERSE, but for a 4-tuple. Also useful on plane_t objects. | |
#define | VADD2(a, b, c) |
Add 3D vectors at `b' and `c', store result at `a'. | |
#define | V2ADD2(a, b, c) |
Add 2D vectors at `b' and `c', store result at `a'. | |
#define | HADD2(a, b, c) |
Add 4D vectors at `b' and `c', store result at `a'. | |
#define | VADD2N(a, b, c, n) |
Add vectors of length `n' at `b' and `c', store result at `a'. | |
#define | VSUB2(a, b, c) |
Subtract 3D vector at `c' from vector at `b', store result at `a'. | |
#define | V2SUB2(a, b, c) |
Subtract 2D vector at `c' from vector at `b', store result at `a'. | |
#define | HSUB2(a, b, c) |
Subtract 4D vector at `c' from vector at `b', store result at `a'. | |
#define | VSUB2N(a, b, c, n) |
Subtract `n' length vector at `c' from vector at `b', store result at `a'. | |
#define | VSUB3(a, b, c, d) |
3D Vectors: A = B - C - D | |
#define | V2SUB3(a, b, c, d) |
2D Vectors: A = B - C - D | |
#define | HSUB3(a, b, c, d) |
4D Vectors: A = B - C - D | |
#define | VSUB3N(a, b, c, d, n) |
Vectors: A = B - C - D for vectors of length `n'. | |
#define | VADD3(a, b, c, d) |
Add 3 3D vectors at `b', `c', and `d', store result at `a'. | |
#define | V2ADD3(a, b, c, d) |
Add 3 2D vectors at `b', `c', and `d', store result at `a'. | |
#define | HADD3(a, b, c, d) |
Add 3 4D vectors at `b', `c', and `d', store result at `a'. | |
#define | VADD3N(a, b, c, d, n) |
Add 3 vectors of length `n' at `b', `c', and `d', store result at `a'. | |
#define | VADD4(a, b, c, d, e) |
Add 4 vectors at `b', `c', `d', and `e', store result at `a'. | |
#define | V2ADD4(a, b, c, d, e) |
Add 4 2D vectors at `b', `c', `d', and `e', store result at `a'. | |
#define | HADD4(a, b, c, d, e) |
Add 4 4D vectors at `b', `c', `d', and `e', store result at `a'. | |
#define | VADD4N(a, b, c, d, e, n) |
Add 4 `n' length vectors at `b', `c', `d', and `e', store result at `a'. | |
#define | VSCALE(a, b, c) |
Scale 3D vector at `b' by scalar `c', store result at `a'. | |
#define | V2SCALE(a, b, c) |
Scale 2D vector at `b' by scalar `c', store result at `a'. | |
#define | HSCALE(a, b, c) |
Scale 4D vector at `b' by scalar `c', store result at `a'. | |
#define | VSCALEN(a, b, c, n) |
Scale vector of length `n' at `b' by scalar `c', store result at `a'. | |
#define | VUNITIZE(a) |
Normalize vector `a' to be a unit vector. | |
#define | VUNITIZE_RET(a, ret) |
If vector magnitude is too small, return an error code. | |
#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, n) |
#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, n) |
#define | VCOMB3(o, a, b, c, d, e, f) |
Combine together several vectors, scaled by a scalar. | |
#define | VCOMB3N(o, a, b, c, d, e, f, n) |
#define | VCOMB2(o, a, b, c, d) |
#define | VCOMB2N(o, a, b, c, d, n) |
#define | VJOIN4(a, b, c, d, e, f, g, h, i, j) |
#define | VJOIN3(a, b, c, d, e, f, g, h) |
#define | VJOIN2(a, b, c, d, e, f) |
Compose 3D vector at `a' of: Vector at `b' plus scalar `c' times vector at `d' plus scalar `e' times vector at `f'. | |
#define | V2JOIN2(a, b, c, d, e, f) |
Compose 2D vector at `a' of: Vector at `b' plus scalar `c' times vector at `d' plus scalar `e' times vector at `f'. | |
#define | HJOIN2(a, b, c, d, e, f) |
Compose 4D vector at `a' of: Vector at `b' plus scalar `c' times vector at `d' plus scalar `e' times vector at `f'. | |
#define | VJOIN2N(a, b, c, d, e, f, n) |
#define | VJOIN1(a, b, c, d) |
#define | V2JOIN1(a, b, c, d) |
#define | HJOIN1(a, b, c, d) |
#define | VJOIN1N(a, b, c, d, n) |
#define | VBLEND2(a, b, c, d, e) |
Blend into vector `a' scalar `b' times vector at `c' plus scalar `d' times vector at `e'. | |
#define | VBLEND2N(a, b, c, d, e, n) |
#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(a) ((a)[X]*(a)[X] + (a)[Y]*(a)[Y] + (a)[Z]*(a)[Z]) |
Return scalar magnitude squared of vector at `a'. | |
#define | MAG2SQ(a) ((a)[X]*(a)[X] + (a)[Y]*(a)[Y]) |
#define | MAGNITUDE(a) sqrt(MAGSQ(a)) |
Return scalar magnitude of vector at `a'. | |
#define | VCROSS(a, b, c) |
Store cross product of vectors at `b' and `c' in vector at `a'. Note that the "right hand rule" applies: If closing your right hand goes from `b' to `c', then your thumb points in the direction of the cross product. | |
#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 | VSUB2DOT(_pt2, _pt, _vec) |
Subtract two points to make a vector, dot with another vector. | |
#define | V2ARGS(a) (a)[X], (a)[Y] |
Turn a vector into comma-separated list of elements, for subroutine args. | |
#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) ? (double)(long)rint(_a) : (_a)) |
#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) (void)fprintf(stderr, "%s (%g, %g)\n", a, V2ARGS(b)); |
Print vector name and components on stderr. | |
#define | VPRINT(a, b) (void)fprintf(stderr, "%s (%g, %g, %g)\n", a, V3ARGS(b)); |
#define | HPRINT(a, b) (void)fprintf(stderr, "%s (%g, %g, %g, %g)\n", a, V4ARGS(b)); |
#define | V2INTCLAMPPRINT(a, b) (void)fprintf(stderr, "%s (%g, %g)\n", a, V2INTCLAMPARGS(b)); |
Included below are integer clamped versions of the previous print macros. | |
#define | VINTCLAMPPRINT(a, b) (void)fprintf(stderr, "%s (%g, %g, %g)\n", a, V3INTCLAMPARGS(b)); |
#define | HINTCLAMPPRINT(a, b) (void)fprintf(stderr, "%s (%g, %g, %g, %g)\n", a, V4INTCLAMPARGS(b)); |
#define | VELMUL(a, b, c) |
Vector element multiplication. Really: diagonal matrix X vect. | |
#define | VELMUL3(a, b, c, d) |
#define | VELDIV(a, b, c) |
Similar to VELMUL. | |
#define | VINVDIR(_inv, _dir) |
Given a direction vector, compute the inverses of each element. When division by zero would have occured, 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 | BN_VEC_NON_UNIT_LEN(_vec) (fabs(MAGSQ(_vec)) < 0.0001 || fabs(fabs(MAGSQ(_vec))-1) > 0.0001) |
Test a vector for non-unit length. | |
#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 | HDIVIDE(a, b) |
Divide out homogeneous parameter from hvect_t, creating vect_t. | |
#define | VADD2_2D(a, b, c) V2ADD2(a, b, c) |
Some 2-D versions of the 3-D macros given above. | |
#define | VSUB2_2D(a, b, c) V2SUB2(a, b, c) |
#define | MAGSQ_2D(a) MAG2SQ(a) |
#define | VDOT_2D(a, b) V2DOT(a, b) |
#define | VMOVE_2D(a, b) V2MOVE(a, b) |
#define | VSCALE_2D(a, b, c) V2SCALE(a, b, c) |
#define | VJOIN1_2D(a, b, c, d) V2JOIN1(a, b, c, d) |
#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)*(M_PI/180.0)), v) |
#define | QUAT_FROM_ROT_DEG(q, r, x, y, z) QUAT_FROM_ROT(q, ((r)*(M_PI/180.0)), 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 | V3PT_IN_RPP(_pt, _lo, _hi) |
Is the point within or on the boundary of the RPP? | |
#define | V3PT_IN_RPP_TOL(_pt, _lo, _hi, _t) |
Within the distance tolerance, is the point within the RPP? | |
#define | V3PT_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 | V3DIR_FROM_AZEL(_d, _a, _e) |
#define | AZEL_FROM_V3DIR(_a, _e, _d) |
#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 fastf_t | vect2d_t [ELEMENTS_PER_VECT2D] |
2-tuple vector | |
typedef fastf_t * | vect2dp_t |
pointer to a 2-tuple vector | |
typedef fastf_t | point2d_t [ELEMENTS_PER_POINT2D] |
2-tuple point | |
typedef fastf_t * | point2dp_t |
pointer to a 2-tuple point | |
typedef fastf_t | vect_t [ELEMENTS_PER_VECT] |
3-tuple vector | |
typedef fastf_t * | vectp_t |
pointer to a 3-tuple vector | |
typedef fastf_t | point_t [ELEMENTS_PER_POINT] |
3-tuple point | |
typedef fastf_t * | pointp_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_t * | matp_t |
pointer to a 4x4 matrix | |
typedef enum bn_vector_component_ | bn_vector_component |
typedef enum bn_matrix_component_ | bn_matrix_component |
typedef fastf_t | plane_t [ELEMENTS_PER_PLANE] |
Definition of a plane equation. | |
Enumerations | |
enum | bn_vector_component_ { X = 0, Y = 1, Z = 2, H = 3, W = H } |
enum | bn_matrix_component_ { MSX = 0, MDX = 3, MSY = 5, MDY = 7, MSZ = 10, MDZ = 11, MSA = 15 } |
Functions | |
void | quat_mat2quat (quat_t quat, const mat_t mat) |
void | quat_quat2mat (mat_t mat, const quat_t quat) |
double | quat_distance (const quat_t q1, const quat_t q2) |
void | quat_double (quat_t qout, const quat_t q1, const quat_t q2) |
void | quat_bisect (quat_t qout, const quat_t q1, const quat_t q2) |
void | quat_slerp (quat_t qout, const quat_t q1, const quat_t q2, double f) |
void | quat_sberp (quat_t qout, const quat_t q1, const quat_t qa, const quat_t qb, const quat_t q2, double f) |
void | quat_make_nearest (quat_t q1, const quat_t q2) |
void | quat_print (const char *title, const quat_t quat) |
void | quat_exp (quat_t out, const quat_t in) |
void | quat_log (quat_t out, const quat_t in) |
void | quat_mat2quat (register fastf_t *quat, register const fastf_t *mat) |
Convert Matrix to Quaternion. | |
void | quat_quat2mat (register fastf_t *mat, register const fastf_t *quat) |
Convert Quaternion to Matrix. | |
double | quat_distance (const fastf_t *q1, const fastf_t *q2) |
Gives the euclidean distance between two quaternions. | |
void | quat_double (fastf_t *qout, const fastf_t *q1, const fastf_t *q2) |
Gives the quaternion point representing twice the rotation from q1 to q2. Needed for patching Bezier curves together. A rather poor name admittedly. | |
void | quat_bisect (fastf_t *qout, const fastf_t *q1, const fastf_t *q2) |
Gives the bisector of quaternions q1 and q2. (Could be done with quat_slerp and factor 0.5) [I believe they must be unit quaternions this to work]. | |
void | quat_slerp (fastf_t *qout, const fastf_t *q1, const fastf_t *q2, double f) |
Do Spherical Linear Interpolation between two unit quaternions by the given factor. | |
void | quat_sberp (fastf_t *qout, const fastf_t *q1, const fastf_t *qa, const fastf_t *qb, const fastf_t *q2, double f) |
Spherical Bezier Interpolate between four quaternions by amount f. These are intended to be used as start and stop quaternions along with two control quaternions chosen to match spline segments with first order continuity. | |
void | quat_make_nearest (fastf_t *q1, const fastf_t *q2) |
Set the quaternion q1 to the quaternion which yields the smallest rotation from q2 (of the two versions of q1 which produce the same orientation). | |
void | quat_print (const char *title, const fastf_t *quat) |
void | quat_exp (fastf_t *out, const fastf_t *in) |
Exponentiate a quaternion, assuming that the scalar part is 0. Code by Ken Shoemake. | |
void | quat_log (fastf_t *out, const fastf_t *in) |
Take the natural logarithm of a unit quaternion. Code by Ken Shoemake. |
#define M_2_SQRTPI 1.12837916709551257389615890312 |
#define M_EULER 0.57721566490153286060651209008 |
#define M_PI 3.14159265358979323846264338328 |
pi
Definition at line 125 of file vmath.h.
Referenced by anim_dx_y_z2mat(), anim_dy_p_r2mat(), anim_dy_p_r2vmat(), anim_dz_y_x2mat(), anim_mat2ypr(), anim_mat2zyx(), and quat_slerp().
#define M_PI_2 1.57079632679489661923132169164 |
#define RAD2DEG 57.295779513082320876798154814105 |
#define VDIVIDE_TOL (1.0e-20) |
Definition at line 162 of file vmath.h.
Referenced by anim_dir2mat(), anim_dirn2mat(), anim_mat2ypr(), anim_mat2zyx(), bn_mat_ck(), quat_exp(), and quat_log().
#define VUNITIZE_TOL (1.0e-15) |
Definition at line 167 of file vmath.h.
Referenced by bn_coplanar(), main(), and mat2d_inverse().
#define ELEMENTS_PER_HVECT 4 |
#define ELEMENTS_PER_HPOINT 4 |
#define ELEMENTS_PER_MAT (ELEMENTS_PER_PLANE*ELEMENTS_PER_PLANE) |
#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 290 of file vmath.h.
Referenced by bn_aet_vec(), bn_coplanar(), bn_eigen2x2(), bn_isect_line2_line2(), bn_isect_line3_line3(), bn_isect_line_lseg(), bn_mat_angles(), bn_mat_ck(), bn_mat_is_equal(), bn_poly_quadratic_roots(), bn_poly_quartic_roots(), bn_vec_ortho(), and mat2d_inverse().
#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) |
Return truthfully whether a value is within a minimum representation tolerance from zero.
Use not recommended due to compilation-variant tolerance.
Definition at line 324 of file vmath.h.
Referenced by anim_mat2quat(), anim_mat2ypr(), anim_mat2zyx(), bn_cx_div(), bn_cx_sqrt(), bn_distsq_line3_line3(), bn_distsq_line3_pt3(), bn_does_ray_isect_tri(), bn_htov_move(), bn_isect_2planes(), bn_isect_planes(), bn_mat_angles(), bn_mat_angles_rad(), bn_mat_arb_rot(), bn_mat_inverse(), bn_mat_is_non_unif(), bn_mat_scale_about_pt(), bn_mkpoint_3planes(), bn_noise_fbm(), bn_noise_turb(), bn_poly_cubic_roots(), bn_poly_quartic_roots(), bn_table_merge2(), bn_vec_ortho(), bn_vec_perp(), find_spec_wgt(), tp_3axis(), and tp_3vector().
#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)) |
Return truthfully whether two values are within a specified epsilon distance from each other.
Definition at line 355 of file vmath.h.
Referenced by bn_aet_vec(), bn_between(), bn_coplanar(), bn_dist_line3_line3(), bn_isect_line3_line3(), and main().
#define VNEAR_EQUAL | ( | _a, | |||
_b, | |||||
_tol | ) |
(NEAR_EQUAL((_a)[X], (_b)[X], (_tol)) \ && NEAR_EQUAL((_a)[Y], (_b)[Y], (_tol)) \ && NEAR_EQUAL((_a)[Z], (_b)[Z], (_tol)))
Return truthfully whether two 3D vectors are approximately equal, within a specified absolute tolerance.
#define V2NEAR_EQUAL | ( | a, | |||
b, | |||||
tol | ) |
(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.
#define HNEAR_EQUAL | ( | _a, | |||
_b, | |||||
_tol | ) |
(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.
#define EQUAL | ( | _a, | |||
_b | ) | NEAR_EQUAL((_a), (_b), SMALL_FASTF) |
#define VEQUAL | ( | _a, | |||
_b | ) | VNEAR_EQUAL((_a), (_b), SMALL_FASTF) |
#define V2EQUAL | ( | a, | |||
b | ) | ((a)[X]==(b)[X] && (a)[Y]==(b)[Y]) |
#define HEQUAL | ( | a, | |||
b | ) | ((a)[X]==(b)[X] && (a)[Y]==(b)[Y] && (a)[Z]==(b)[Z] && (a)[W]==(b)[W]) |
#define CLAMP | ( | _v, | |||
_l, | |||||
_h | ) | if ((_v) < (_l)) _v = _l; else if ((_v) > (_h)) _v = _h |
#define DIST_PT_PLANE | ( | _pt, | |||
_pl | ) | (VDOT(_pt, _pl) - (_pl)[W]) |
#define DIST_PT_PT_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]) |
set translation values of 4x4 matrix from a vector.
Definition at line 438 of file vmath.h.
Referenced by bn_mat_scale_about_pt(), bn_mat_xform_about_pt(), bn_vlist_3string(), tp_3axis(), and tp_3symbol().
#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 445 of file vmath.h.
Referenced by bn_mat_scale_about_pt(), bn_mat_xform_about_pt(), and bn_wrt_point_direc().
#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 | ) |
{ \ (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; \ }
Zero a matrix.
In following are macro versions of librt/mat.c functions for when speed really matters.
Definition at line 595 of file vmath.h.
Referenced by bn_isect_planes(), and bn_mat_scale_about_pt().
#define MAT_IDN | ( | m | ) |
{ \ (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; \ }
Set matrix to identity.
Definition at line 603 of file vmath.h.
Referenced by bn_decode_mat(), bn_mat_angles(), bn_mat_angles_rad(), bn_mat_arb_rot(), bn_mat_fromto(), bn_mat_lookat(), bn_mat_scale_about_pt(), bn_mat_xform_about_pt(), bn_vlist_3string(), bn_wrt_point_direc(), PL_FORTRAN(), tp_3axis(), tp_3marker(), and tp_3symbol().
#define MAT_TRANSPOSE | ( | t, | |||
m | ) |
{ \ (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]; \ }
set t to the transpose of matrix m
Definition at line 611 of file vmath.h.
Referenced by bn_mat_trn().
#define MAT_COPY | ( | d, | |||
s | ) |
{ \ (d)[0] = (s)[0]; \ (d)[1] = (s)[1]; \ (d)[2] = (s)[2]; \ (d)[3] = (s)[3]; \ (d)[4] = (s)[4]; \ (d)[5] = (s)[5]; \ (d)[6] = (s)[6]; \ (d)[7] = (s)[7]; \ (d)[8] = (s)[8]; \ (d)[9] = (s)[9]; \ (d)[10] = (s)[10]; \ (d)[11] = (s)[11]; \ (d)[12] = (s)[12]; \ (d)[13] = (s)[13]; \ (d)[14] = (s)[14]; \ (d)[15] = (s)[15]; \ }
Copy a matrix.
Definition at line 631 of file vmath.h.
Referenced by bn_mat_inverse(), bn_mat_lookat(), and bn_mat_mul2().
#define VSET | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
Set 3D vector at `a' to have coordinates `b', `c', and `d'.
Definition at line 651 of file vmath.h.
Referenced by Add_vert(), Add_vert_and_norm(), anim_dir2mat(), anim_dirn2mat(), anim_steer_mat(), bn_aet_vec(), bn_eigen2x2(), bn_isect_2planes(), bn_isect_planes(), bn_mat_fromto(), bn_mat_lookat(), bn_vec_ae(), bn_vec_aed(), bn_vlist_2string(), bn_vlist_3string(), bn_wrt_point_direc(), PL_FORTRAN(), tp_2symbol(), tp_3axis(), tp_3marker(), and tp_3symbol().
#define V2SET | ( | a, | |||
b, | |||||
c | ) |
#define HSET | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e | ) |
#define VSETALL | ( | a, | |||
s | ) |
Set all elements of 3D vector to same scalar value.
Definition at line 673 of file vmath.h.
Referenced by bn_cmd_noise_slice(), bn_isect_2planes(), bn_math_cmd(), bn_vec_ortho(), and bn_vec_perp().
#define V2SETALL | ( | a, | |||
s | ) |
#define HSETALL | ( | a, | |||
s | ) |
#define VSETALLN | ( | v, | |||
s, | |||||
n | ) |
#define VMOVE | ( | a, | |||
b | ) |
Transfer 3D vector at `b' to vector at `a'.
Definition at line 696 of file vmath.h.
Referenced by Add_vert(), Add_vert_and_norm(), anim_dir2mat(), anim_dirn2mat(), anim_steer_mat(), bn_dist_pt3_line3(), bn_dist_pt3_lseg3(), bn_htov_move(), bn_isect_line3_line3(), bn_isect_line3_plane(), bn_isect_line_lseg(), bn_isect_pt_lseg(), bn_mat_ck(), bn_mat_fromto(), bn_vec_perp(), bn_vtoh_move(), quat_print(), and tp_3axis().
#define V2MOVE | ( | a, | |||
b | ) |
#define HMOVE | ( | a, | |||
b | ) |
#define VMOVEN | ( | a, | |||
b, | |||||
n | ) |
#define VREVERSE | ( | a, | |||
b | ) |
#define V2REVERSE | ( | a, | |||
b | ) |
#define HREVERSE | ( | a, | |||
b | ) |
#define VADD2 | ( | a, | |||
b, | |||||
c | ) |
#define V2ADD2 | ( | a, | |||
b, | |||||
c | ) |
#define HADD2 | ( | a, | |||
b, | |||||
c | ) |
{ \ register int _vadd2; \ for (_vadd2 = 0; _vadd2 < (n); _vadd2++) { \ (a)[_vadd2] = (b)[_vadd2] + (c)[_vadd2]; \ } \ }
Add vectors of length `n' at `b' and `c', store result at `a'.
Definition at line 774 of file vmath.h.
Referenced by anim_quat2mat().
#define VSUB2 | ( | a, | |||
b, | |||||
c | ) |
Subtract 3D vector at `c' from vector at `b', store result at `a'.
Definition at line 786 of file vmath.h.
Referenced by bn_3pts_collinear(), bn_3pts_distinct(), bn_dist_line3_line3(), bn_dist_line3_lseg3(), bn_dist_line3_pt3(), bn_dist_pt3_along_line3(), bn_dist_pt3_line3(), bn_dist_pt3_lseg3(), bn_dist_pt3_pt3(), bn_distsq_line3_line3(), bn_distsq_line3_pt3(), bn_does_ray_isect_tri(), bn_isect_line3_line3(), bn_isect_line_lseg(), bn_isect_lseg_rpp(), bn_isect_pt_lseg(), bn_mk_plane_3pts(), bn_npts_distinct(), tp_3axis(), and tp_3vector().
#define V2SUB2 | ( | a, | |||
b, | |||||
c | ) |
#define HSUB2 | ( | a, | |||
b, | |||||
c | ) |
#define VSUB3 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define V2SUB3 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define HSUB3 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define VADD3 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define V2ADD3 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define HADD3 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define VADD4 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e | ) |
#define V2ADD4 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e | ) |
#define HADD4 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e | ) |
#define VSCALE | ( | a, | |||
b, | |||||
c | ) |
Scale 3D vector at `b' by scalar `c', store result at `a'.
Definition at line 930 of file vmath.h.
Referenced by bn_coplanar(), bn_dist_line3_lseg3(), bn_distsq_line3_line3(), bn_htov_move(), bn_isect_line3_line3(), bn_isect_line_lseg(), bn_isect_pt_lseg(), bn_mk_plane_3pts(), bn_rotate_plane(), quat_exp(), quat_log(), tp_3axis(), and tp_3vector().
#define V2SCALE | ( | a, | |||
b, | |||||
c | ) |
#define HSCALE | ( | a, | |||
b, | |||||
c | ) |
#define VUNITIZE | ( | a | ) |
{ \ register double _f = MAGSQ(a); \ if (! NEAR_EQUAL(_f, 1.0, VUNITIZE_TOL)) { \ _f = sqrt(_f); \ if (_f < VDIVIDE_TOL) { \ VSETALL((a), 0.0); \ } else { \ _f = 1.0/_f; \ (a)[X] *= _f; (a)[Y] *= _f; (a)[Z] *= _f; \ } \ } \ }
Normalize vector `a' to be a unit vector.
Definition at line 962 of file vmath.h.
Referenced by bn_aet_vec(), bn_dist_pt3_line3(), bn_does_ray_isect_tri(), bn_eigen2x2(), bn_isect_line2_line2(), bn_isect_line3_plane(), bn_isect_line_lseg(), bn_mat_fromto(), bn_vec_ae(), and quat_print().
#define VUNITIZE_RET | ( | a, | |||
ret | ) |
#define VADD2SCALE | ( | o, | |||
a, | |||||
b, | |||||
s | ) |
#define VADD2SCALEN | ( | o, | |||
a, | |||||
b, | |||||
n | ) |
#define VSUB2SCALE | ( | o, | |||
a, | |||||
b, | |||||
s | ) |
#define VSUB2SCALEN | ( | o, | |||
a, | |||||
b, | |||||
n | ) |
#define VCOMB3 | ( | o, | |||
a, | |||||
b, | |||||
c, | |||||
d, | |||||
e, | |||||
f | ) |
#define VCOMB2 | ( | o, | |||
a, | |||||
b, | |||||
c, | |||||
d | ) |
#define VJOIN4 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e, | |||||
f, | |||||
g, | |||||
h, | |||||
i, | |||||
j | ) |
#define VJOIN3 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e, | |||||
f, | |||||
g, | |||||
h | ) |
#define VJOIN2 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e, | |||||
f | ) |
#define V2JOIN2 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e, | |||||
f | ) |
#define HJOIN2 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e, | |||||
f | ) |
{ \ (a)[X] = (b)[X] + (c) * (d)[X] + (e) * (f)[X]; \ (a)[Y] = (b)[Y] + (c) * (d)[Y] + (e) * (f)[Y]; \ (a)[Z] = (b)[Z] + (c) * (d)[Z] + (e) * (f)[Z]; \ (a)[W] = (b)[W] + (c) * (d)[W] + (e) * (f)[W]; \ }
Compose 4D vector at `a' of: Vector at `b' plus scalar `c' times vector at `d' plus scalar `e' times vector at `f'.
#define VJOIN1 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
{ \ (a)[X] = (b)[X] + (c) * (d)[X]; \ (a)[Y] = (b)[Y] + (c) * (d)[Y]; \ (a)[Z] = (b)[Z] + (c) * (d)[Z]; \ }
Definition at line 1113 of file vmath.h.
Referenced by bn_2line3_colinear(), bn_dist_line3_line3(), bn_dist_pt3_line3(), bn_dist_pt3_lseg3(), bn_distsq_line3_line3(), bn_does_ray_isect_tri(), bn_isect_lseg_rpp(), bn_math_cmd(), pdv_3ray(), and tp_3axis().
#define V2JOIN1 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define HJOIN1 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define VBLEND2 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e | ) |
{ \ (a)[X] = (b) * (c)[X] + (d) * (e)[X]; \ (a)[Y] = (b) * (c)[Y] + (d) * (e)[Y]; \ (a)[Z] = (b) * (c)[Z] + (d) * (e)[Z]; \ }
Blend into vector `a' scalar `b' times vector at `c' plus scalar `d' times vector at `e'.
Definition at line 1146 of file vmath.h.
Referenced by bn_distsq_line3_line3(), bn_math_cmd(), and quat_slerp().
#define VPROJECT | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define MAGSQ | ( | a | ) | ((a)[X]*(a)[X] + (a)[Y]*(a)[Y] + (a)[Z]*(a)[Z]) |
Return scalar magnitude squared of vector at `a'.
Definition at line 1173 of file vmath.h.
Referenced by bn_3pts_distinct(), bn_coplanar(), bn_dist_line3_line3(), bn_dist_line3_pt3(), bn_dist_pt3_line3(), bn_dist_pt3_lseg3(), bn_distsq_line3_line3(), bn_isect_line3_line3(), bn_isect_line_lseg(), bn_isect_pt_lseg(), bn_mat_is_non_unif(), bn_mk_plane_3pts(), bn_npts_distinct(), and bn_vec_ortho().
#define MAGNITUDE | ( | a | ) | sqrt(MAGSQ(a)) |
Return scalar magnitude of vector at `a'.
Definition at line 1177 of file vmath.h.
Referenced by anim_dirn2mat(), bn_2line3_colinear(), bn_3pts_collinear(), bn_dist_line3_line3(), bn_dist_line3_lseg3(), bn_dist_line3_pt3(), bn_dist_line_origin(), bn_dist_pt3_pt3(), bn_distsq_line3_line3(), bn_distsq_line3_pt3(), bn_isect_line3_line3(), bn_isect_line_lseg(), bn_isect_lseg3_lseg3(), bn_mk_plane_3pts(), bn_mkpoint_3planes(), quat_exp(), quat_log(), and tp_3vector().
#define VCROSS | ( | a, | |||
b, | |||||
c | ) |
{ \ (a)[X] = (b)[Y] * (c)[Z] - (b)[Z] * (c)[Y]; \ (a)[Y] = (b)[Z] * (c)[X] - (b)[X] * (c)[Z]; \ (a)[Z] = (b)[X] * (c)[Y] - (b)[Y] * (c)[X]; \ }
Store cross product of vectors at `b' and `c' in vector at `a'. Note that the "right hand rule" applies: If closing your right hand goes from `b' to `c', then your thumb points in the direction of the cross product.
If the angle from `b' to `c' goes clockwise, then the result vector points "into" the plane (inward normal). Example: b=(0, 1, 0), c=(1, 0, 0), then bXc=(0, 0, -1).
If the angle from `b' to `c' goes counter-clockwise, then the result vector points "out" of the plane. This outward pointing normal is the BRL-CAD convention.
Definition at line 1193 of file vmath.h.
Referenced by bn_aet_vec(), bn_does_ray_isect_tri(), bn_isect_2planes(), bn_mat_fromto(), bn_mk_plane_3pts(), bn_mkpoint_3planes(), bn_vec_perp(), and tp_3vector().
#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'.
Definition at line 1200 of file vmath.h.
Referenced by Add_vert_and_norm(), bn_2line3_colinear(), bn_3pts_collinear(), bn_aet_vec(), bn_angle_measure(), bn_coplanar(), bn_dist_line3_line3(), bn_dist_line3_lseg3(), bn_dist_line3_pt3(), bn_dist_line_origin(), bn_dist_pt3_along_line3(), bn_dist_pt3_line3(), bn_dist_pt3_lseg3(), bn_distsq_line3_line3(), bn_distsq_line3_pt3(), bn_does_ray_isect_tri(), bn_isect_line2_line2(), bn_isect_line3_line3(), bn_isect_line3_plane(), bn_isect_line_lseg(), bn_isect_pt_lseg(), bn_mat_ck(), bn_mat_fromto(), bn_mk_plane_3pts(), bn_mkpoint_3planes(), bn_rotate_plane(), and tp_3axis().
#define HDOT | ( | a, | |||
b | ) | ((a)[X]*(b)[X] + (a)[Y]*(b)[Y] + (a)[Z]*(b)[Z] + (a)[W]*(b)[W]) |
#define VSUB2DOT | ( | _pt2, | |||
_pt, | |||||
_vec | ) |
#define V2ARGS | ( | a | ) | (a)[X], (a)[Y] |
Turn a vector into comma-separated list of elements, for subroutine args.
Definition at line 1220 of file vmath.h.
Referenced by bn_dist_pt2_along_line2(), bn_isect_line2_line2(), bn_isect_line2_lseg2(), and bn_isect_lseg2_lseg2().
#define V3ARGS | ( | a | ) | (a)[X], (a)[Y], (a)[Z] |
Definition at line 1221 of file vmath.h.
Referenced by bn_dist_line3_line3(), bn_dist_pt2_lseg2(), bn_dist_pt3_line3(), bn_dist_pt3_lseg3(), bn_hlf_class(), bn_isect_line3_line3(), bn_isect_lseg3_lseg3(), bn_mat_fromto(), bn_mat_lookat(), bn_vec_ortho(), pdv_3cont(), pdv_3line(), pdv_3move(), pdv_3point(), and pdv_3space().
#define V4ARGS | ( | a | ) | (a)[X], (a)[Y], (a)[Z], (a)[W] |
Definition at line 1222 of file vmath.h.
Referenced by bn_isect_planes().
#define INTCLAMP | ( | _a | ) | (NEAR_EQUAL((_a), rint(_a), VUNITIZE_TOL) ? (double)(long)rint(_a) : (_a)) |
if a value is within computation tolerance of an integer, clamp the value to that integer.
NOTE: should use VDIVIDE_TOL here, but cannot yet until floats are replaced universally with fastf_t's since their epsilon is considerably less than that of a double.
Definition at line 1232 of file vmath.h.
Referenced by bn_encode_mat(), and bn_math_cmd().
#define V2INTCLAMPARGS | ( | a | ) | INTCLAMP((a)[X]), INTCLAMP((a)[Y]) |
integer clamped versions of the previous arg macros.
Definition at line 1235 of file vmath.h.
Referenced by bn_math_cmd().
#define V3INTCLAMPARGS | ( | a | ) | INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z]) |
integer clamped versions of the previous arg macros.
Definition at line 1237 of file vmath.h.
Referenced by bn_encode_vect(), and bn_math_cmd().
#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 1239 of file vmath.h.
Referenced by bn_encode_hvect(), and bn_encode_quat().
#define V2PRINT | ( | a, | |||
b | ) | (void)fprintf(stderr, "%s (%g, %g)\n", a, V2ARGS(b)); |
Print vector name and components on stderr.
Definition at line 1242 of file vmath.h.
Referenced by bn_isect_line2_lseg2(), and bn_isect_pt2_lseg2().
#define VPRINT | ( | a, | |||
b | ) | (void)fprintf(stderr, "%s (%g, %g, %g)\n", a, V3ARGS(b)); |
Definition at line 1244 of file vmath.h.
Referenced by bn_mat_lookat().
#define HPRINT | ( | a, | |||
b | ) | (void)fprintf(stderr, "%s (%g, %g, %g, %g)\n", a, V4ARGS(b)); |
#define V2INTCLAMPPRINT | ( | a, | |||
b | ) | (void)fprintf(stderr, "%s (%g, %g)\n", a, V2INTCLAMPARGS(b)); |
#define VINTCLAMPPRINT | ( | a, | |||
b | ) | (void)fprintf(stderr, "%s (%g, %g, %g)\n", a, V3INTCLAMPARGS(b)); |
#define HINTCLAMPPRINT | ( | a, | |||
b | ) | (void)fprintf(stderr, "%s (%g, %g, %g, %g)\n", a, V4INTCLAMPARGS(b)); |
#define VELMUL | ( | a, | |||
b, | |||||
c | ) |
#define VELMUL3 | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
#define VELDIV | ( | a, | |||
b, | |||||
c | ) |
#define VINVDIR | ( | _inv, | |||
_dir | ) |
{ \ if ((_dir)[X] < -SQRT_SMALL_FASTF || (_dir)[X] > SQRT_SMALL_FASTF) { \ (_inv)[X]=1.0/(_dir)[X]; \ } else { \ (_dir)[X] = 0.0; \ (_inv)[X] = INFINITY; \ } \ if ((_dir)[Y] < -SQRT_SMALL_FASTF || (_dir)[Y] > SQRT_SMALL_FASTF) { \ (_inv)[Y]=1.0/(_dir)[Y]; \ } else { \ (_dir)[Y] = 0.0; \ (_inv)[Y] = INFINITY; \ } \ if ((_dir)[Z] < -SQRT_SMALL_FASTF || (_dir)[Z] > SQRT_SMALL_FASTF) { \ (_inv)[Z]=1.0/(_dir)[Z]; \ } else { \ (_dir)[Z] = 0.0; \ (_inv)[Z] = INFINITY; \ } \ }
Given a direction vector, compute the inverses of each element. When division by zero would have occured, mark inverse as INFINITY.
#define MAT3X3VEC | ( | o, | |||
mat, | |||||
vec | ) |
{ \ (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]; \ }
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 | ) |
{ \ register 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; \ }
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 1350 of file vmath.h.
Referenced by bn_isect_planes(), bn_rotate_plane(), bn_vlist_3string(), tp_3axis(), and tp_3symbol().
#define PNT3X4MAT | ( | o, | |||
i, | |||||
m | ) |
{ \ register 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; \ }
Multiply an Absolute 3-Point by a full 4x4 matrix. Output and input points should be separate arrays.
#define MAT4X4PNT | ( | o, | |||
m, | |||||
i | ) |
{ \ (o)[X]=(m)[ 0]*(i)[X] + (m)[ 1]*(i)[Y] + (m)[ 2]*(i)[Z] + (m)[ 3]*(i)[H]; \ (o)[Y]=(m)[ 4]*(i)[X] + (m)[ 5]*(i)[Y] + (m)[ 6]*(i)[Z] + (m)[ 7]*(i)[H]; \ (o)[Z]=(m)[ 8]*(i)[X] + (m)[ 9]*(i)[Y] + (m)[10]*(i)[Z] + (m)[11]*(i)[H]; \ (o)[H]=(m)[12]*(i)[X] + (m)[13]*(i)[Y] + (m)[14]*(i)[Z] + (m)[15]*(i)[H]; \ }
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 | ) |
{ \ register 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; \ }
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 1386 of file vmath.h.
Referenced by bn_mat_fromto(), bn_mat_lookat(), bn_rotate_plane(), and tp_3axis().
#define MAT4XSCALOR | ( | o, | |||
m, | |||||
i | ) |
#define VEC3X4MAT | ( | o, | |||
i, | |||||
m | ) |
{ \ register 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; \ }
Multiply a Relative 3-Vector by most of a 4x4 matrix. Output and input vectors should be separate arrays.
#define VEC2X4MAT | ( | o, | |||
i, | |||||
m | ) |
#define BN_VEC_NON_UNIT_LEN | ( | _vec | ) | (fabs(MAGSQ(_vec)) < 0.0001 || fabs(fabs(MAGSQ(_vec))-1) > 0.0001) |
#define V_MIN | ( | r, | |||
s | ) | if ((r) > (s)) r = (s) |
#define VMIN | ( | r, | |||
s | ) |
#define VMAX | ( | r, | |||
s | ) |
#define VMINMAX | ( | min, | |||
max, | |||||
pt | ) |
#define HDIVIDE | ( | a, | |||
b | ) |
Some 2-D versions of the 3-D macros given above.
A better naming convention is V2MOVE() rather than VMOVE_2D().
DEPRECATED: These xxx_2D names are slated to go away, use the others.
THESE ARE ALL DEPRECATED.
Definition at line 1464 of file vmath.h.
Referenced by bn_isect_line2_lseg2().
Definition at line 1465 of file vmath.h.
Referenced by bn_dist_line2_point2(), bn_dist_pt2_along_line2(), bn_dist_pt2_lseg2(), bn_distsq_line2_point2(), bn_isect_pt2_lseg2(), and bn_pt2_pt2_equal().
#define MAGSQ_2D | ( | a | ) | MAG2SQ(a) |
Definition at line 1466 of file vmath.h.
Referenced by bn_dist_line2_point2(), bn_dist_pt2_lseg2(), bn_distsq_line2_point2(), bn_isect_line2_lseg2(), bn_isect_lseg2_lseg2(), bn_isect_pt2_lseg2(), and bn_pt2_pt2_equal().
#define VDOT_2D | ( | a, | |||
b | ) | V2DOT(a, b) |
Definition at line 1467 of file vmath.h.
Referenced by bn_dist_line2_point2(), bn_dist_pt2_along_line2(), bn_dist_pt2_lseg2(), bn_distsq_line2_point2(), and bn_isect_pt2_lseg2().
#define VMOVE_2D | ( | a, | |||
b | ) | V2MOVE(a, b) |
Definition at line 1468 of file vmath.h.
Referenced by bn_isect_pt2_lseg2().
Definition at line 1469 of file vmath.h.
Referenced by bn_isect_pt2_lseg2().
Definition at line 1470 of file vmath.h.
Referenced by bn_isect_line2_lseg2().
{ \ register 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); \ }
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)*(M_PI/180.0)), v) |
#define QSET | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e | ) |
#define QMOVE | ( | a, | |||
b | ) |
Transfer quaternion at `b' to quaternion at `a'.
Definition at line 1532 of file vmath.h.
Referenced by anim_quat2mat(), quat_make_nearest(), and quat_quat2mat().
#define QADD2 | ( | a, | |||
b, | |||||
c | ) |
#define QSUB2 | ( | a, | |||
b, | |||||
c | ) |
#define QSCALE | ( | a, | |||
b, | |||||
c | ) |
#define QUNITIZE | ( | a | ) |
{ \ register 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; \ }
Normalize quaternion 'a' to be a unit quaternion.
Definition at line 1570 of file vmath.h.
Referenced by anim_quat2mat(), quat_bisect(), quat_double(), and quat_quat2mat().
#define QMAGSQ | ( | a | ) |
#define QMAGNITUDE | ( | a | ) | sqrt(QMAGSQ(a)) |
Return scalar magnitude of quaternion at `a'.
Definition at line 1583 of file vmath.h.
Referenced by quat_distance().
#define QDOT | ( | a, | |||
b | ) |
#define QMUL | ( | a, | |||
b, | |||||
c | ) |
{ \ (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]; \ }
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 | ) |
#define QBLEND2 | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
e | ) |
{ \ (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]; \ }
Blend into quaternion `a'.
scalar `b' times quaternion at `c' plus scalar `d' times quaternion at `e'
Definition at line 1628 of file vmath.h.
Referenced by quat_slerp().
#define V3RPP_DISJOINT | ( | _l1, | |||
_h1, | |||||
_l2, | |||||
_h2 | ) |
((_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 parallelpipeds (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 | ) |
#define V3RPP_OVERLAP | ( | _l1, | |||
_h1, | |||||
_l2, | |||||
_h2 | ) |
#define V3RPP_OVERLAP_TOL | ( | _l1, | |||
_h1, | |||||
_l2, | |||||
_h2, | |||||
_t | ) |
#define V3PT_IN_RPP | ( | _pt, | |||
_lo, | |||||
_hi | ) |
#define V3PT_IN_RPP_TOL | ( | _pt, | |||
_lo, | |||||
_hi, | |||||
_t | ) |
(\ (_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?
FIXME: should not be using >= <=, '=' case is unreliable
#define V3PT_OUT_RPP_TOL | ( | _pt, | |||
_lo, | |||||
_hi, | |||||
_t | ) |
#define V3RPP1_IN_RPP2 | ( | _lo1, | |||
_hi1, | |||||
_lo2, | |||||
_hi2 | ) |
(\ (_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.
FIXME: should not be using >= <=, '=' case is unreliable
#define V3DIR_FROM_AZEL | ( | _d, | |||
_a, | |||||
_e | ) |
#define AZEL_FROM_V3DIR | ( | _a, | |||
_e, | |||||
_d | ) |
#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} |
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 1764 of file vmath.h.
Referenced by Add_vert(), and anim_steer_mat().
#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 fastf_t vect2d_t[ELEMENTS_PER_VECT2D] |
typedef fastf_t point2d_t[ELEMENTS_PER_POINT2D] |
typedef fastf_t* point2dp_t |
typedef enum bn_vector_component_ bn_vector_component |
Vector component names for homogeneous (4-tuple) vectors
typedef enum bn_matrix_component_ bn_matrix_component |
Locations of deltas (MD*) and scaling values (MS*) in a 4x4 Homogenous Transform matrix
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
enum bn_vector_component_ |
enum bn_matrix_component_ |
Referenced by bn_math_cmd().
Referenced by bn_math_cmd().
Referenced by bn_quat_distance_wrapper(), and quat_make_nearest().
Referenced by bn_math_cmd().
Referenced by bn_math_cmd().
Referenced by bn_math_cmd(), and quat_sberp().
void quat_sberp | ( | quat_t | qout, | |
const quat_t | q1, | |||
const quat_t | qa, | |||
const quat_t | qb, | |||
const quat_t | q2, | |||
double | f | |||
) |
Referenced by bn_math_cmd().
Referenced by bn_math_cmd().
void quat_print | ( | const char * | title, | |
const quat_t | quat | |||
) |
Referenced by bn_math_cmd().
Referenced by bn_math_cmd().
void quat_mat2quat | ( | register fastf_t * | quat, | |
register const fastf_t * | mat | |||
) |
void quat_quat2mat | ( | register fastf_t * | mat, | |
register const fastf_t * | quat | |||
) |
double quat_distance | ( | const fastf_t * | q1, | |
const fastf_t * | q2 | |||
) |
Gives the euclidean distance between two quaternions.
Q U A T _ D I S T A N C E
Definition at line 168 of file qmath.c.
References QMAGNITUDE, and QSUB2.
void quat_double | ( | fastf_t * | qout, | |
const fastf_t * | q1, | |||
const fastf_t * | q2 | |||
) |
void quat_bisect | ( | fastf_t * | qout, | |
const fastf_t * | q1, | |||
const fastf_t * | q2 | |||
) |
void quat_slerp | ( | fastf_t * | qout, | |
const fastf_t * | q1, | |||
const fastf_t * | q2, | |||
double | f | |||
) |
void quat_sberp | ( | fastf_t * | qout, | |
const fastf_t * | q1, | |||
const fastf_t * | qa, | |||
const fastf_t * | qb, | |||
const fastf_t * | q2, | |||
double | f | |||
) |
Spherical Bezier Interpolate between four quaternions by amount f. These are intended to be used as start and stop quaternions along with two control quaternions chosen to match spline segments with first order continuity.
Q U A T _ S B E R P Uses the method of successive bisection.
Definition at line 274 of file qmath.c.
References quat_slerp().
void quat_make_nearest | ( | fastf_t * | q1, | |
const fastf_t * | q2 | |||
) |
Set the quaternion q1 to the quaternion which yields the smallest rotation from q2 (of the two versions of q1 which produce the same orientation).
Q U A T _ M A K E _ N E A R E S T Note that smallest euclidian distance implies smallest great circle distance as well (since surface is convex).
Definition at line 302 of file qmath.c.
References QMOVE, QSCALE, and quat_distance().
void quat_print | ( | const char * | title, | |
const fastf_t * | quat | |||
) |
void quat_exp | ( | fastf_t * | out, | |
const fastf_t * | in | |||
) |