Skip to content

Commit

Permalink
math: add Vec element-wise >,>=,<,<= operators
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
slimsag committed Sep 8, 2023
1 parent b81e416 commit d23d662
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/math/vec.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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:
///
/// ```
Expand Down

0 comments on commit d23d662

Please sign in to comment.