math: various fixes
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
40a1ba0431
commit
b81e416e02
1 changed files with 5 additions and 5 deletions
|
|
@ -106,24 +106,24 @@ pub fn Vec(comptime n_value: usize, comptime Scalar: type) type {
|
||||||
|
|
||||||
/// Scalar addition
|
/// Scalar addition
|
||||||
pub inline fn addScalar(a: VecN, s: Scalar) VecN {
|
pub inline fn addScalar(a: VecN, s: Scalar) VecN {
|
||||||
return .{ .v = a.v + VecN.splat(s) };
|
return .{ .v = a.v + VecN.splat(s).v };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scalar subtraction
|
/// Scalar subtraction
|
||||||
pub inline fn subScalar(a: VecN, s: Scalar) VecN {
|
pub inline fn subScalar(a: VecN, s: Scalar) VecN {
|
||||||
return .{ .v = a.v - VecN.splat(s) };
|
return .{ .v = a.v - VecN.splat(s).v };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scalar division
|
/// Scalar division
|
||||||
pub inline fn divScalar(a: VecN, s: Scalar) VecN {
|
pub inline fn divScalar(a: VecN, s: Scalar) VecN {
|
||||||
return .{ .v = a.v / VecN.splat(s) };
|
return .{ .v = a.v / VecN.splat(s).v };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scalar multiplication.
|
/// Scalar multiplication.
|
||||||
///
|
///
|
||||||
/// See .dot() for the dot product
|
/// See .dot() for the dot product
|
||||||
pub inline fn mulScalar(a: VecN, s: Scalar) VecN {
|
pub inline fn mulScalar(a: VecN, s: Scalar) VecN {
|
||||||
return .{ .v = a.v * VecN.splat(s) };
|
return .{ .v = a.v * VecN.splat(s).v };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a vector with all components set to the `scalar` value:
|
/// Returns a vector with all components set to the `scalar` value:
|
||||||
|
|
@ -192,7 +192,7 @@ pub fn Vec(comptime n_value: usize, comptime Scalar: type) type {
|
||||||
/// a.lerp(b, 1.0) == b
|
/// a.lerp(b, 1.0) == b
|
||||||
/// ```
|
/// ```
|
||||||
pub inline fn lerp(a: VecN, b: VecN, amount: Scalar) VecN {
|
pub inline fn lerp(a: VecN, b: VecN, amount: Scalar) VecN {
|
||||||
return a.mulScalar(1.0 - amount) + b.mulScalar(amount);
|
return a.mulScalar(1.0 - amount).add(b.mulScalar(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates the dot product between vector a and b and returns scalar.
|
/// Calculates the dot product between vector a and b and returns scalar.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue