Support for uniform tolerances.
More...
|
#define | BN_CK_TOL(_p) BU_CKMAG(_p, BN_TOL_MAGIC, "bn_tol") |
|
#define | BN_TOL_INIT(_p) |
|
#define | BN_TOL_INIT_ZERO { BN_TOL_MAGIC, 0.0, 0.0, 0.0, 1.0 } |
|
#define | BN_TOL_INIT_TOL {BN_TOL_MAGIC, BN_TOL_DIST, BN_TOL_DIST * BN_TOL_DIST, 1.0e-6, 1.0 - 1.0e-6 } |
|
#define | BN_TOL_INIT_SET_TOL(_p) |
|
#define | BN_TOL_IS_INITIALIZED(_p) (((struct bn_tol *)(_p) != (struct bn_tol *)0) && LIKELY((_p)->magic == BN_TOL_MAGIC)) |
|
#define | BN_TOL_DIST 0.0005 |
|
#define | BN_VECT_ARE_PARALLEL(_dot, _tol) (((_dot) <= -SMALL_FASTF) ? (NEAR_EQUAL((_dot), -1.0, (_tol)->perp)) : (NEAR_EQUAL((_dot), 1.0, (_tol)->perp))) |
|
#define | BN_VECT_ARE_PERP(_dot, _tol) (((_dot) < 0) ? ((-(_dot))<=(_tol)->perp) : ((_dot) <= (_tol)->perp)) |
|
Support for uniform tolerances.
A handy way of passing around the tolerance information needed to perform approximate floating-point calculations on geometry.
dist & dist_sq establish the distance tolerance.
If two points are closer together than dist, then they are to be considered the same point.
For example:
if (
MAGNITUDE(diff) < tol->dist) a & b are the same.
or, more efficiently:
if (MAQSQ(diff) < tol->dist_sq)
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
#define VSUB2(o, a, b)
Subtract 3D vector at ‘b’ from vector at ‘a’, store result at ‘o’.
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
#define MAGNITUDE(v)
Return scalar magnitude of the 3D vector ‘a’. This is otherwise known as the Euclidean norm of the pr...
perp & para establish the angular tolerance.
If two rays emanate from the same point, and their dot product is nearly one, then the two rays are the same, while if their dot product is nearly zero, then they are perpendicular.
For example:
if (fabs(
VDOT(a, b)) >= tol->para) a & b are parallel
if (fabs(
VDOT(a, b)) <= tol->perp) a & b are perpendicular
#define VDOT(a, b)
Compute dot product of vectors at ‘a’ and ‘b’.
- Note
- tol->dist_sq = tol->dist * tol->dist;
tol->para = 1 - tol->perp;
◆ BN_CK_TOL
asserts the validity of a bn_tol struct.
Definition at line 83 of file tol.h.
◆ BN_TOL_INIT
#define BN_TOL_INIT |
( |
|
_p | ) |
|
Value: { \
(_p)->dist = 0.0; \
(_p)->dist_sq = 0.0; \
(_p)->perp = 0.0; \
(_p)->para = 1.0; \
}
initializes a bn_tol struct to zero without allocating any memory.
Definition at line 88 of file tol.h.
◆ BN_TOL_INIT_ZERO
#define BN_TOL_INIT_ZERO { BN_TOL_MAGIC, 0.0, 0.0, 0.0, 1.0 } |
macro suitable for declaration statement zero-initialization of a bn_tol struct.
Definition at line 100 of file tol.h.
◆ BN_TOL_INIT_TOL
commonly used default initialization of a bn_tol struct.
Definition at line 105 of file tol.h.
◆ BN_TOL_INIT_SET_TOL
#define BN_TOL_INIT_SET_TOL |
( |
|
_p | ) |
|
Value: { \
(_p)->perp = 1.0e-6; \
(_p)->para = 1.0 - 1.0e-6; \
}
Definition at line 106 of file tol.h.
◆ BN_TOL_IS_INITIALIZED
returns truthfully whether a bn_tol struct has been initialized.
Definition at line 117 of file tol.h.
◆ BN_TOL_DIST
#define BN_TOL_DIST 0.0005 |
replaces the hard coded tolerance value
Definition at line 122 of file tol.h.
◆ BN_VECT_ARE_PARALLEL
#define BN_VECT_ARE_PARALLEL |
( |
|
_dot, |
|
|
|
_tol |
|
) |
| (((_dot) <= -SMALL_FASTF) ? (NEAR_EQUAL((_dot), -1.0, (_tol)->perp)) : (NEAR_EQUAL((_dot), 1.0, (_tol)->perp))) |
returns truthfully whether a given dot-product of two unspecified vectors are within a specified parallel tolerance.
Definition at line 128 of file tol.h.
◆ BN_VECT_ARE_PERP
#define BN_VECT_ARE_PERP |
( |
|
_dot, |
|
|
|
_tol |
|
) |
| (((_dot) < 0) ? ((-(_dot))<=(_tol)->perp) : ((_dot) <= (_tol)->perp)) |
returns truthfully whether a given dot-product of two unspecified vectors are within a specified perpendicularity tolerance.
Definition at line 135 of file tol.h.