Struct Half2
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
Represents a two dimensional mathematical vector with half-precision floats.
[DataContract]
public struct Half2 : IEquatable<Half2>, ISpanFormattable, IFormattable- Implements
Constructors
Half2(Half)
Initializes a new instance of the Half2 structure.
public Half2(Half value)Parameters
- valueHalf
- The value to set for both the X and Y components. 
Half2(Half, Half)
Initializes a new instance of the Half2 structure.
public Half2(Half x, Half y)Parameters
Half2(Half[])
Initializes a new instance of the Half2 struct.
public Half2(Half[] values)Parameters
- valuesHalf[]
- The values to assign to the X and Y components of the vector. This must be an array with two elements. 
Exceptions
- ArgumentNullException
- Thrown when - valuesis- null.
- ArgumentOutOfRangeException
- Thrown when - valuescontains more or less than two elements.
Half2(float)
Initializes a new instance of the Half2 structure.
public Half2(float value)Parameters
- valuefloat
- The value to set for both the X and Y components. 
Half2(float, float)
Initializes a new instance of the Half2 structure.
public Half2(float x, float y)Parameters
Fields
One
A Half2 with all of its components set to one.
public static readonly Half2 OneField Value
SizeInBytes
The size of the Half2 type, in bytes.
public static readonly int SizeInBytesField Value
UnitX
The X unit Half2 (1, 0).
public static readonly Half2 UnitXField Value
UnitY
The Y unit Half2 (0, 1).
public static readonly Half2 UnitYField Value
X
Gets or sets the X component of the vector.
public Half XField Value
- Half
- The X component of the vector. 
Y
Gets or sets the Y component of the vector.
public Half YField Value
- Half
- The Y component of the vector. 
Zero
A Half2 with all of its components set to zero.
public static readonly Half2 ZeroField Value
Methods
Deconstruct(out Half, out Half)
Deconstructs the vector's components into named variables.
public readonly void Deconstruct(out Half x, out Half y)Parameters
Equals(Half2)
Returns a value that indicates whether the current instance is equal to the specified object.
public readonly bool Equals(Half2 other)Parameters
- otherHalf2
- Object to make the comparison with. 
Returns
- bool
- trueif the current instance is equal to the specified object;- falseotherwise.
Equals(ref readonly Half2, ref readonly Half2)
Determines whether the specified object instances are considered equal.
public static bool Equals(ref readonly Half2 value1, ref readonly Half2 value2)Parameters
Returns
- bool
- trueif- value1is the same instance as- value2or if both are- nullreferences or if- value1.Equals(value2)returns- true; otherwise,- false.
Equals(object?)
Returns a value that indicates whether the current instance is equal to a specified object.
public override readonly bool Equals(object? obj)Parameters
- objobject
- Object to make the comparison with. 
Returns
- bool
- trueif the current instance is equal to the specified object;- falseotherwise.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()Returns
- int
- A 32-bit signed integer hash code. 
ToString()
Returns a string that represents this instance.
public override readonly string ToString()Returns
ToString(string?, IFormatProvider?)
Returns a string that represents this instance.
public readonly string ToString(string? format, IFormatProvider? formatProvider)Parameters
- formatstring
- The format. 
- formatProviderIFormatProvider
- The format provider. 
Returns
Operators
operator ==(Half2, Half2)
Tests for equality between two objects.
public static bool operator ==(Half2 left, Half2 right)Parameters
Returns
- bool
- trueif- lefthas the same value as- right; otherwise,- false.
explicit operator Vector2(Half2)
public static explicit operator Vector2(Half2 value)Parameters
- valueHalf2
- The value. 
Returns
- Vector2
- The result of the conversion. 
explicit operator Half2(Vector2)
public static explicit operator Half2(Vector2 value)Parameters
- valueVector2
- The value. 
Returns
- Half2
- The result of the conversion. 
operator !=(Half2, Half2)
Tests for inequality between two objects.
public static bool operator !=(Half2 left, Half2 right)Parameters
Returns
- bool
- trueif- lefthas a different value than- right; otherwise,- false.