| ... | ... | @@ -285,10 +285,10 @@ pub inline fn tan(value: anytype) @TypeOf(value) { |
| 285 | 285 | return @tan(value); |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | | // Convert an angle in radians to degrees. T must be a float type. |
| 288 | /// Converts an angle in radians to degrees. T must be a float type. |
| 289 | 289 | pub fn radiansToDegrees(comptime T: type, angle_in_radians: T) T { |
| 290 | | if (@typeInfo(T) != .Float) |
| 291 | | @compileError("T must be a float type."); |
| 290 | if (@typeInfo(T) != .Float and @typeInfo(T) != .ComptimeFloat) |
| 291 | @compileError("T must be a float type"); |
| 292 | 292 | return angle_in_radians * 180.0 / pi; |
| 293 | 293 | } |
| 294 | 294 | |
| ... | ... | @@ -300,10 +300,10 @@ test "radiansToDegrees" { |
| 300 | 300 | try std.testing.expectApproxEqAbs(@as(f32, 360), radiansToDegrees(f32, 2.0 * pi), 1e-6); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | | // Convert an angle in degrees to radians. T must be a float type. |
| 303 | /// Converts an angle in degrees to radians. T must be a float type. |
| 304 | 304 | pub fn degreesToRadians(comptime T: type, angle_in_degrees: T) T { |
| 305 | | if (@typeInfo(T) != .Float) |
| 306 | | @compileError("T must be a float type."); |
| 305 | if (@typeInfo(T) != .Float and @typeInfo(T) != .ComptimeFloat) |
| 306 | @compileError("T must be a float type"); |
| 307 | 307 | return angle_in_degrees * pi / 180.0; |
| 308 | 308 | } |
| 309 | 309 | |