From d23d662adb252990b2768b0180c8a96384a9d813 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 8 Sep 2023 16:55:11 -0700 Subject: [PATCH] math: add Vec element-wise >,>=,<,<= operators Signed-off-by: Stephen Gutekanst --- src/math/vec.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/math/vec.zig b/src/math/vec.zig index b85bcaae..89d2271e 100644 --- a/src/math/vec.zig +++ b/src/math/vec.zig @@ -126,6 +126,26 @@ pub fn Vec(comptime n_value: usize, comptime Scalar: type) type { return .{ .v = a.v * VecN.splat(s).v }; } + /// Element-wise a < b + pub inline fn less(a: VecN, b: Scalar) bool { + return a.v < b.v; + } + + /// Element-wise a <= b + pub inline fn lessEq(a: VecN, b: Scalar) bool { + return a.v <= b.v; + } + + /// Element-wise a > b + pub inline fn greater(a: VecN, b: Scalar) bool { + return a.v > b.v; + } + + /// Element-wise a >= b + pub inline fn greaterEq(a: VecN, b: Scalar) bool { + return a.v >= b.v; + } + /// Returns a vector with all components set to the `scalar` value: /// /// ```