pub struct Rigid {
pub rotation: [[f64; 3]; 3],
pub translation: [f64; 3],
}Expand description
Maps mesh B’s local coordinates into mesh A’s local coordinates:
p_a = rotation * p_b + translation.
rotation is row-major (rotation[i][j] is row i, column j) and must
be a proper rotation: orthonormal with determinant +1, within 1e-6 per
entry. Scale and reflection are not supported, so distances measured in A’s
space are distances between the meshes. Queries given anything else, or
non-finite values, fail with QueryError::InvalidInput.
B’s vertices are transformed in f64 when they are tested and never stored.
“Exact” intersection results are exact for those transformed f64
coordinates.
Fields§
§rotation: [[f64; 3]; 3]The rotation, row-major.
translation: [f64; 3]The translation, applied after the rotation.
Implementations§
Source§impl Rigid
impl Rigid
Sourcepub fn inverse(&self) -> Rigid
pub fn inverse(&self) -> Rigid
The transform that maps A’s coordinates back into B’s: the transposed
rotation and the translation -rotationᵀ * translation.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Checks that every value is finite and that the rotation is a proper
rotation (orthonormal with determinant +1) within 1e-6 per entry: the
check every mesh-vs-mesh query runs first.
§Errors
QueryError::InvalidInput for a non-finite value, a rotation that is
not orthonormal, or a reflection.
Sourcepub fn apply(&self, p: [f32; 3]) -> [f64; 3]
pub fn apply(&self, p: [f32; 3]) -> [f64; 3]
Maps a point of B into A’s space: rotation * p + translation, in
f64.
This is the exact arithmetic (same expression, same order) the queries
use to move B’s vertices, so points transformed with it agree bit for
bit with what the queries tested. To map a result point such as
MeshDistance::point_b back into B’s
space, use apply on Rigid::inverse.
use fast_mesh_query::Rigid;
// A quarter turn about z, then a step along x.
let xf = Rigid {
rotation: [[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]],
translation: [1.0, 0.0, 0.0],
};
assert_eq!(xf.validate(), Ok(()));
let in_a = xf.apply([1.0, 0.0, 0.0]);
assert_eq!(in_a, [1.0, 1.0, 0.0]);
let back = xf.inverse().apply(in_a.map(|v| v as f32));
assert_eq!(back, [1.0, 0.0, 0.0]);