using System; namespace UnityEngine.XR.ARSubsystems { /// /// Represents a field of view as angles in radians from the center point. /// /// /// This struct is a C# representation of the OpenXR XrFovf struct. /// Refer to the Open XR specification. /// public readonly struct XRFov : IEquatable { /// /// Gets the angle in radians between the left edge and center of the frame. /// /// The angle in radians between the left edge and center of the frame. public float angleLeft => m_AngleLeft; readonly float m_AngleLeft; /// /// Gets the angle in radians between the right edge and center of the frame. /// /// The angle in radians between the right edge and center of the frame. public float angleRight => m_AngleRight; readonly float m_AngleRight; /// /// Gets the angle in radians between the upper edge and center of the frame. /// /// The angle in radians between the upper edge and center of the frame. public float angleUp => m_AngleUp; readonly float m_AngleUp; /// /// Gets the angle in radians between the lower edge and center of the frame. /// /// The angle in radians between the lower edge and center of the frame. public float angleDown => m_AngleDown; readonly float m_AngleDown; /// /// Constructor. /// /// The angle in radians between the left edge and center of the frame. /// The angle in radians between the right edge and center of the frame. /// The angle in radians between the upper edge and center of the frame. /// The angle in radians between the lower edge and center of the frame. public XRFov(float left, float right, float up, float down) { m_AngleLeft = left; m_AngleRight = right; m_AngleUp = up; m_AngleDown = down; } /// /// Returns this instance as a with the following field mappings: /// x | angleLeft /// y | angleRight /// z | angleUp /// w | angleDown /// /// This as a . public Vector4 AsVector4() => new(angleLeft, angleRight, angleUp, angleDown); /// /// Compares for equality. /// /// The other to compare against. /// if the represents the same object. /// Otherwise, . public bool Equals(XRFov other) { return angleLeft == other.angleLeft && angleRight == other.angleRight && angleUp == other.angleUp && angleDown == other.angleDown; } /// /// Compares for equality. /// /// An object to compare against. /// if is an and /// is also . Otherwise, . public override bool Equals(System.Object obj) => obj is XRFov fov && Equals(fov); /// /// Compares and for equality using . /// /// The left-hand-side of the comparison. /// The right-hand-side of the comparison. /// if compares equal to . /// Otherwise, . public static bool operator ==(XRFov lhs, XRFov rhs) => lhs.Equals(rhs); /// /// Compares and for inequality using . /// /// The left-hand-side of the comparison. /// The right-hand-side of the comparison. /// if compares equal to . /// Otherwise, . public static bool operator !=(XRFov lhs, XRFov rhs) => !lhs.Equals(rhs); /// /// Generates a hash code suitable for use in HashSet and Dictionary. /// /// A hash of this . public override int GetHashCode() { int hashCode = 486187739; unchecked { hashCode = (hashCode * 486187739) + angleLeft.GetHashCode(); hashCode = (hashCode * 486187739) + angleRight.GetHashCode(); hashCode = (hashCode * 486187739) + angleUp.GetHashCode(); hashCode = (hashCode * 486187739) + angleDown.GetHashCode(); } return hashCode; } /// /// Returns a string that represents the current object. /// /// The string. public override string ToString() => $"{{ left: {m_AngleLeft}, right: {m_AngleRight}, up: {m_AngleUp}, down: {m_AngleDown} }}"; } }