diff --git a/src/math/vec.zig b/src/math/vec.zig index 707276b..76cc3c3 100644 --- a/src/math/vec.zig +++ b/src/math/vec.zig @@ -88,11 +88,11 @@ pub fn Vec(comptime nelem: comptime_int, comptime T: anytype) type { // 3-element operations pub usingnamespace if (nelem >= 3) struct { - pub inline fn sum3(self: Self) f32 { + pub inline fn sum3(self: Self) T { return self.x + self.y + self.z; } - pub inline fn dot3(a: Self, b: Self) f32 { + pub inline fn dot3(a: Self, b: Self) T { return a.mul(b).sum3(); } @@ -136,8 +136,8 @@ pub fn Vec(comptime nelem: comptime_int, comptime T: anytype) type { return zxy(sub(mul(zxy(a), b), mul(a, zxy(b)))); } - pub inline fn length3(self: Self) f32 { - return @sqrt(@maximum(std.math.f32_epsilon, self.dot3(self))); + pub inline fn length3(self: Self) T { + return @sqrt(@maximum(std.math.epsilon(T), self.dot3(self))); } pub inline fn normalize3(self: Self) Self {