mirror of
https://github.com/bevyengine/bevy
synced 2024-09-20 14:32:06 +00:00
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:
parent
fae2200b1a
commit
344e28d095
1 changed files with 9 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue