From 6af72f454a371a30071e9f22264f3d70a72acf4f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 9 Sep 2022 11:44:10 +0200 Subject: [PATCH 1/2] Derive some traits for `Winding` --- crates/fj-math/src/triangle.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/fj-math/src/triangle.rs b/crates/fj-math/src/triangle.rs index 4d2612110..cbafd436e 100644 --- a/crates/fj-math/src/triangle.rs +++ b/crates/fj-math/src/triangle.rs @@ -114,6 +114,7 @@ pub struct NotATriangle { } /// Winding direction of a triangle. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub enum Winding { /// Counter-clockwise Ccw, From 3397f3ec72d98ed8d096e2dee27e73d1803c9a9e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 9 Sep 2022 12:50:53 +0200 Subject: [PATCH 2/2] Add `Vector<2>::cross` --- crates/fj-math/src/vector.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/fj-math/src/vector.rs b/crates/fj-math/src/vector.rs index 79a580d8f..9b2a59e44 100644 --- a/crates/fj-math/src/vector.rs +++ b/crates/fj-math/src/vector.rs @@ -127,6 +127,11 @@ impl Vector<2> { pub fn unit_v() -> Self { Vector::from([1., 0.]) } + + /// Compute the 2D cross product with another vector + pub fn cross(&self, other: &Self) -> Scalar { + (self.u * other.v) - (self.v * other.u) + } } impl Vector<3> {