Skip to content

[API Proposal]: Quaternion.Zero is missing #57253

@michael-hawker

Description

@michael-hawker

Background and motivation

Vector2, Vector3, and Vector4 when created with new() are all zeroed out and have corresponding .Zero static properties. Quaternion on the otherhand only has the Identity static property and doesn't have the corresponding Zero one to represent its base state when created with new().

API Proposal

namespace System.Numerics
{
     public class Quaternion
     {
        /// <summary>Gets a newly initialized quaternion.</summary>
        /// <value>A quaternion whose values are <c>(0, 0, 0, 0)</c>.</value>
        public static Quaternion Zero
        {
            get => new();
        }
     }
}

API Usage

// New Quaternion
var q = Quaternion.Zero;
q.X = 0.5;

// Checking
if (q == Quaternion.Zero)
{
  // Was uninitialized
}

Risks

No breaking changes, adds value to matching base struct types in the System.Numerics package for base initialization state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved in API review, it can be implementedarea-System.Numericshelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions