mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
19 lines
577 B
C#
19 lines
577 B
C#
namespace Target
|
|
{
|
|
internal class Angle
|
|
{
|
|
// Use same precision for constants as original code
|
|
private const float PI = 3.14159f;
|
|
private const float DegreesPerRadian = 57.296f;
|
|
|
|
private readonly float _radians;
|
|
|
|
private Angle(float radians) => _radians = radians;
|
|
|
|
public static Angle InDegrees(float degrees) => new (degrees / DegreesPerRadian);
|
|
public static Angle InRotations(float rotations) => new (2 * PI * rotations);
|
|
|
|
public static implicit operator float(Angle angle) => angle._radians;
|
|
}
|
|
}
|