-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Numerics
Milestone
Description
Background and Motivation
My use-case is working with quaternions, since the inputs for Quaternion.CreateFromYawPitchRoll(...) are in radians.
Proposed API
namespace System
{
public static class Math
{
+ public const double RadiansToDegrees = 57.295779513;
+ public const double DegreesToRadians = 0.0174532925;
}
public static class MathF
{
+ public const double RadiansToDegrees = 57.295779513f;
+ public const double DegreesToRadians = 0.0174532925f;
}
}Don't quote me on the values, and add more precision to the double variant. float should have 9 decimal places, and double should have 29.
Usage Examples
Vector3 input = new Vector3(10f, 20f, 30f) * MathF.DegreesToRadians;
Quaternion quaternion = Quaternion.CreateFromYawPitchRoll(input.Y, input.X, input.Z);Alternative Designs
- Use methods instead. Not ideal, since then you need more code to convert types with multiple numerical components:
- Constant:
vector * MathF.DegreesToRadians; - Method:
public Vector3 DegreesToRadians(this Vector3 vector) => new Vector2(MathF.DegreesToRadians(vector.X), MathF.DegreesToRadians(vector.Y));
- Constant:
Risks
None.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Numerics