From 991edf98377482859e5dbe732182a40528e97743 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 19 Feb 2022 11:07:15 +0100 Subject: [PATCH] Derive same set of traits for most math types This set includes `Eq`, `Ord`, and `Hash`, which is made possible by the `Scalar` type. --- src/math/aabb.rs | 1 + src/math/point.rs | 2 +- src/math/segment.rs | 2 +- src/math/triangle.rs | 2 +- src/math/vector.rs | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/math/aabb.rs b/src/math/aabb.rs index 80798a758..db1ba105f 100644 --- a/src/math/aabb.rs +++ b/src/math/aabb.rs @@ -3,6 +3,7 @@ use parry3d_f64::bounding_volume::BoundingVolume as _; use super::{Point, Vector}; /// An axis-aligned bounding box (AABB) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct Aabb { /// The minimum coordinates of the AABB pub min: Point, diff --git a/src/math/point.rs b/src/math/point.rs index 839159753..1b0571241 100644 --- a/src/math/point.rs +++ b/src/math/point.rs @@ -12,7 +12,7 @@ use super::{Scalar, Vector}; /// /// The goal of this type is to eventually implement `Eq` and `Hash`, making it /// easier to work with vectors. This is a work in progress. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct Point([Scalar; D]); impl Point { diff --git a/src/math/segment.rs b/src/math/segment.rs index 11d3ae273..6b0937841 100644 --- a/src/math/segment.rs +++ b/src/math/segment.rs @@ -1,7 +1,7 @@ use super::Point; /// A line segment, defined by its two end points -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct Segment { pub a: Point, pub b: Point, diff --git a/src/math/triangle.rs b/src/math/triangle.rs index cff5e9739..d1f230da4 100644 --- a/src/math/triangle.rs +++ b/src/math/triangle.rs @@ -1,7 +1,7 @@ use super::Point; /// A triangle -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct Triangle { pub a: Point<3>, pub b: Point<3>, diff --git a/src/math/vector.rs b/src/math/vector.rs index d122da117..26d78cc4a 100644 --- a/src/math/vector.rs +++ b/src/math/vector.rs @@ -12,7 +12,7 @@ use super::Scalar; /// /// The goal of this type is to eventually implement `Eq` and `Hash`, making it /// easier to work with vectors. This is a work in progress. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct Vector([Scalar; D]); impl Vector {