std.math: allow comptime_float for radiansToDegrees and degreesToRadians
And some other minor things.
This commit is contained in:
@@ -285,10 +285,10 @@ pub inline fn tan(value: anytype) @TypeOf(value) {
|
||||
return @tan(value);
|
||||
}
|
||||
|
||||
// Convert an angle in radians to degrees. T must be a float type.
|
||||
/// Converts an angle in radians to degrees. T must be a float type.
|
||||
pub fn radiansToDegrees(comptime T: type, angle_in_radians: T) T {
|
||||
if (@typeInfo(T) != .Float)
|
||||
@compileError("T must be a float type.");
|
||||
if (@typeInfo(T) != .Float and @typeInfo(T) != .ComptimeFloat)
|
||||
@compileError("T must be a float type");
|
||||
return angle_in_radians * 180.0 / pi;
|
||||
}
|
||||
|
||||
@@ -300,10 +300,10 @@ test "radiansToDegrees" {
|
||||
try std.testing.expectApproxEqAbs(@as(f32, 360), radiansToDegrees(f32, 2.0 * pi), 1e-6);
|
||||
}
|
||||
|
||||
// Convert an angle in degrees to radians. T must be a float type.
|
||||
/// Converts an angle in degrees to radians. T must be a float type.
|
||||
pub fn degreesToRadians(comptime T: type, angle_in_degrees: T) T {
|
||||
if (@typeInfo(T) != .Float)
|
||||
@compileError("T must be a float type.");
|
||||
if (@typeInfo(T) != .Float and @typeInfo(T) != .ComptimeFloat)
|
||||
@compileError("T must be a float type");
|
||||
return angle_in_degrees * pi / 180.0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user