Change Tetrahedron default origin to (0, 0, 0) (#12867)

# Objective

- Fixes #12837.

## Solution

- Update `Tetrahedron` default vertices to `[0.5, 0.5, 0.5]`, `[-0.5,
0.5, -0.5]`, `[-0.5, -0.5, 0.5]` and `[0.5, -0.5, -0.5]` respectively.
- Update `tetrahedron_math` tests to account for change in default
vertices.
This commit is contained in:
Antony 2024-04-03 19:00:54 -04:00 committed by GitHub
parent fae2200b1a
commit 344e28d095
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -834,14 +834,14 @@ impl Primitive3d for Tetrahedron {}
impl Default for Tetrahedron {
/// Returns the default [`Tetrahedron`] with the vertices
/// `[0.0, 0.5, 0.0]`, `[-0.5, -0.5, 0.0]`, `[0.5, -0.5, 0.0]` and `[0.0, 0.0, 0.5]`.
/// `[0.5, 0.5, 0.5]`, `[-0.5, 0.5, -0.5]`, `[-0.5, -0.5, 0.5]` and `[0.5, -0.5, -0.5]`.
fn default() -> Self {
Self {
vertices: [
Vec3::new(0.0, 0.5, 0.0),
Vec3::new(-0.5, -0.5, 0.0),
Vec3::new(0.5, -0.5, 0.0),
Vec3::new(0.0, 0.0, 0.5),
Vec3::new(0.5, 0.5, 0.5),
Vec3::new(-0.5, 0.5, -0.5),
Vec3::new(-0.5, -0.5, 0.5),
Vec3::new(0.5, -0.5, -0.5),
],
}
}
@ -1085,20 +1085,17 @@ mod tests {
);
assert_relative_eq!(tetrahedron.centroid(), Vec3::new(-0.225, -0.375, 1.55));
assert_eq!(Tetrahedron::default().area(), 1.4659258, "incorrect area");
assert_eq!(Tetrahedron::default().area(), 3.4641016, "incorrect area");
assert_eq!(
Tetrahedron::default().volume(),
0.083333336,
0.33333334,
"incorrect volume"
);
assert_eq!(
Tetrahedron::default().signed_volume(),
0.083333336,
-0.33333334,
"incorrect signed volume"
);
assert_relative_eq!(
Tetrahedron::default().centroid(),
Vec3::new(0.0, -0.125, 0.125)
);
assert_relative_eq!(Tetrahedron::default().centroid(), Vec3::ZERO);
}
}