Int4 Struct
Namespace: Stride.Core.MathematicsAssembly: Stride.Core.Mathematics.dll
Represents a four dimensional mathematical vector.
[DataContract("Int4")]
[DataStyle(DataStyle.Compact)]
public struct Int4 : IEquatable<Int4>, IFormattable
| Name | Description | |
|---|---|---|
| Constructors | ||
| Int4(Int32) | Initializes a new instance of the Int4 struct. |
|
| Int4(Int32, Int32, Int32, Int32) | Initializes a new instance of the Int4 struct. |
|
| Int4(Int32[]) | Initializes a new instance of the Int4 struct. |
|
| Fields | ||
| One | A Int4 with all of its components set to one. |
|
| SizeInBytes | The size of the Int4 type, in bytes. |
|
| UnitW | The W unit Int4 (0, 0, 0, 1). |
|
| UnitX | The X unit Int4 (1, 0, 0, 0). |
|
| UnitY | The Y unit Int4 (0, 1, 0, 0). |
|
| UnitZ | The Z unit Int4 (0, 0, 1, 0). |
|
| W | The W component of the vector. |
|
| X | The X component of the vector. |
|
| Y | The Y component of the vector. |
|
| Z | The Z component of the vector. |
|
| Zero | A Int4 with all of its components set to zero. |
|
| Properties | ||
| Item[Int32] | Gets or sets the component at the specified index. |
|
| Methods | ||
| Add(Int4, Int4) | Adds two vectors. |
|
| Add(ref Int4, ref Int4, out Int4) | Adds two vectors. |
|
| Clamp(Int4, Int4, Int4) | Restricts a value to be within a specified range. |
|
| Clamp(ref Int4, ref Int4, ref Int4, out Int4) | Restricts a value to be within a specified range. |
|
| Divide(Int4, Int32) | Scales a vector by the given value. |
|
| Divide(ref Int4, Int32, out Int4) | Scales a vector by the given value. |
|
| Equals(Int4) | Determines whether the specified Int4 is equal to this instance. |
|
| Equals(Object) | Determines whether the specified System.Object is equal to this instance. |
|
| GetHashCode() | Returns a hash code for this instance. |
|
| Length() | Calculates the length of the vector. |
|
| LengthSquared() | Calculates the squared length of the vector. |
|
| Max(Int4, Int4) | Returns a vector containing the largest components of the specified vectors. |
|
| Max(ref Int4, ref Int4, out Int4) | Returns a vector containing the smallest components of the specified vectors. |
|
| Min(Int4, Int4) | Returns a vector containing the smallest components of the specified vectors. |
|
| Min(ref Int4, ref Int4, out Int4) | Returns a vector containing the smallest components of the specified vectors. |
|
| Modulate(Int4, Int4) | Modulates a vector with another by performing component-wise multiplication. |
|
| Modulate(ref Int4, ref Int4, out Int4) | Modulates a vector with another by performing component-wise multiplication. |
|
| Multiply(Int4, Int32) | Scales a vector by the given value. |
|
| Multiply(ref Int4, Int32, out Int4) | Scales a vector by the given value. |
|
| Negate(Int4) | Reverses the direction of a given vector. |
|
| Negate(ref Int4, out Int4) | Reverses the direction of a given vector. |
|
| Subtract(Int4, Int4) | Subtracts two vectors. |
|
| Subtract(ref Int4, ref Int4, out Int4) | Subtracts two vectors. |
|
| ToArray() | Creates an array containing the elements of the vector. |
|
| ToString() | Returns a System.String that represents this instance. |
|
| ToString(IFormatProvider) | Returns a System.String that represents this instance. |
|
| ToString(String) | Returns a System.String that represents this instance. |
|
| ToString(String, IFormatProvider) | Returns a System.String that represents this instance. |
|
| Operators | ||
| Addition(Int4, Int4) | Adds two vectors. |
|
| Division(Int4, Int32) | Scales a vector by the given value. |
|
| Equality(Int4, Int4) | Tests for equality between two objects. |
|
| Explicit(Int4 to Vector2) | ||
| Explicit(Int4 to Vector3) | ||
| Explicit(Int4 to Vector4) | ||
| Implicit(Int4 to Int32[]) | Performs an implicit conversion from Int4 to System.Int32 array. |
|
| Implicit(Int32[] to Int4) | Performs an implicit conversion from System.Int32 array to Int4. |
|
| Inequality(Int4, Int4) | Tests for inequality between two objects. |
|
| Multiply(Int4, Int32) | Scales a vector by the given value. |
|
| Multiply(Int32, Int4) | Scales a vector by the given value. |
|
| Subtraction(Int4, Int4) | Subtracts two vectors. |
|
| UnaryNegation(Int4) | Reverses the direction of a given vector. |
|
| UnaryPlus(Int4) | Assert a vector (return it unchanged). |
|
Constructors
Int4(Int32)
Initializes a new instance of the Int4 struct.
public Int4(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | value | The value that will be assigned to all components. |
Int4(Int32, Int32, Int32, Int32)
Initializes a new instance of the Int4 struct.
public Int4(int x, int y, int z, int w)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | x | Initial value for the X component of the vector. |
| System.Int32 | y | Initial value for the Y component of the vector. |
| System.Int32 | z | Initial value for the Z component of the vector. |
| System.Int32 | w | Initial value for the W component of the vector. |
Int4(Int32[])
Initializes a new instance of the Int4 struct.
public Int4(int[] values)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32[] | values | The values to assign to the X, Y, Z, and W components of the vector. This must be an array with four elements. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentOutOfRangeException | Thrown when |
Fields
One
A Int4 with all of its components set to one.
public static readonly Int4 One
Field Value
| Type | Description |
|---|---|
| Int4 |
SizeInBytes
The size of the Int4 type, in bytes.
public static readonly int SizeInBytes
Field Value
| Type | Description |
|---|---|
| System.Int32 |
UnitW
The W unit Int4 (0, 0, 0, 1).
public static readonly Int4 UnitW
Field Value
| Type | Description |
|---|---|
| Int4 |
UnitX
The X unit Int4 (1, 0, 0, 0).
public static readonly Int4 UnitX
Field Value
| Type | Description |
|---|---|
| Int4 |
UnitY
The Y unit Int4 (0, 1, 0, 0).
public static readonly Int4 UnitY
Field Value
| Type | Description |
|---|---|
| Int4 |
UnitZ
The Z unit Int4 (0, 0, 1, 0).
public static readonly Int4 UnitZ
Field Value
| Type | Description |
|---|---|
| Int4 |
W
The W component of the vector.
[DataMember(3)]
public int W
Field Value
| Type | Description |
|---|---|
| System.Int32 |
X
The X component of the vector.
[DataMember(0)]
public int X
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Y
The Y component of the vector.
[DataMember(1)]
public int Y
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Z
The Z component of the vector.
[DataMember(2)]
public int Z
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Zero
A Int4 with all of its components set to zero.
public static readonly Int4 Zero
Field Value
| Type | Description |
|---|---|
| Int4 |
Properties
Item[Int32]
Gets or sets the component at the specified index.
public int this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the component to access. Use 0 for the X component, 1 for the Y component, 2 for the Z component, and 3 for the W component. |
Property Value
| Type | Description |
|---|---|
| System.Int32 | The value of the X, Y, Z, or W component, depending on the index. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown when the |
Methods
Add(Int4, Int4)
Adds two vectors.
public static Int4 Add(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first vector to add. |
| Int4 | right | The second vector to add. |
Returns
| Type | Description |
|---|---|
| Int4 | The sum of the two vectors. |
Add(ref Int4, ref Int4, out Int4)
Adds two vectors.
public static void Add(ref Int4 left, ref Int4 right, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first vector to add. |
| Int4 | right | The second vector to add. |
| Int4 | result | When the method completes, contains the sum of the two vectors. |
Clamp(Int4, Int4, Int4)
Restricts a value to be within a specified range.
public static Int4 Clamp(Int4 value, Int4 min, Int4 max)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The value to clamp. |
| Int4 | min | The minimum value. |
| Int4 | max | The maximum value. |
Returns
| Type | Description |
|---|---|
| Int4 | The clamped value. |
Clamp(ref Int4, ref Int4, ref Int4, out Int4)
Restricts a value to be within a specified range.
public static void Clamp(ref Int4 value, ref Int4 min, ref Int4 max, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The value to clamp. |
| Int4 | min | The minimum value. |
| Int4 | max | The maximum value. |
| Int4 | result | When the method completes, contains the clamped value. |
Divide(Int4, Int32)
Scales a vector by the given value.
public static Int4 Divide(Int4 value, int scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to scale. |
| System.Int32 | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Int4 | The scaled vector. |
Divide(ref Int4, Int32, out Int4)
Scales a vector by the given value.
public static void Divide(ref Int4 value, int scale, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to scale. |
| System.Int32 | scale | The amount by which to scale the vector. |
| Int4 | result | When the method completes, contains the scaled vector. |
Equals(Int4)
Determines whether the specified Int4 is equal to this instance.
public bool Equals(Int4 other)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | other | The Int4 to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
public override bool Equals(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The System.Object to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Overrides
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
Length()
Calculates the length of the vector.
public int Length()
Returns
| Type | Description |
|---|---|
| System.Int32 | The length of the vector. |
Remarks
LengthSquared() may be preferred when only the relative length is needed and speed is of the essence.
LengthSquared()
Calculates the squared length of the vector.
public int LengthSquared()
Returns
| Type | Description |
|---|---|
| System.Int32 | The squared length of the vector. |
Remarks
This method may be preferred to Length() when only a relative length is needed and speed is of the essence.
Max(Int4, Int4)
Returns a vector containing the largest components of the specified vectors.
public static Int4 Max(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first source vector. |
| Int4 | right | The second source vector. |
Returns
| Type | Description |
|---|---|
| Int4 | A vector containing the largest components of the source vectors. |
Max(ref Int4, ref Int4, out Int4)
Returns a vector containing the smallest components of the specified vectors.
public static void Max(ref Int4 left, ref Int4 right, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first source vector. |
| Int4 | right | The second source vector. |
| Int4 | result | When the method completes, contains an new vector composed of the largest components of the source vectors. |
Min(Int4, Int4)
Returns a vector containing the smallest components of the specified vectors.
public static Int4 Min(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first source vector. |
| Int4 | right | The second source vector. |
Returns
| Type | Description |
|---|---|
| Int4 | A vector containing the smallest components of the source vectors. |
Min(ref Int4, ref Int4, out Int4)
Returns a vector containing the smallest components of the specified vectors.
public static void Min(ref Int4 left, ref Int4 right, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first source vector. |
| Int4 | right | The second source vector. |
| Int4 | result | When the method completes, contains an new vector composed of the smallest components of the source vectors. |
Modulate(Int4, Int4)
Modulates a vector with another by performing component-wise multiplication.
public static Int4 Modulate(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first vector to modulate. |
| Int4 | right | The second vector to modulate. |
Returns
| Type | Description |
|---|---|
| Int4 | The modulated vector. |
Modulate(ref Int4, ref Int4, out Int4)
Modulates a vector with another by performing component-wise multiplication.
public static void Modulate(ref Int4 left, ref Int4 right, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first vector to modulate. |
| Int4 | right | The second vector to modulate. |
| Int4 | result | When the method completes, contains the modulated vector. |
Multiply(Int4, Int32)
Scales a vector by the given value.
public static Int4 Multiply(Int4 value, int scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to scale. |
| System.Int32 | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Int4 | The scaled vector. |
Multiply(ref Int4, Int32, out Int4)
Scales a vector by the given value.
public static void Multiply(ref Int4 value, int scale, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to scale. |
| System.Int32 | scale | The amount by which to scale the vector. |
| Int4 | result | When the method completes, contains the scaled vector. |
Negate(Int4)
Reverses the direction of a given vector.
public static Int4 Negate(Int4 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to negate. |
Returns
| Type | Description |
|---|---|
| Int4 | A vector facing in the opposite direction. |
Negate(ref Int4, out Int4)
Reverses the direction of a given vector.
public static void Negate(ref Int4 value, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to negate. |
| Int4 | result | When the method completes, contains a vector facing in the opposite direction. |
Subtract(Int4, Int4)
Subtracts two vectors.
public static Int4 Subtract(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first vector to subtract. |
| Int4 | right | The second vector to subtract. |
Returns
| Type | Description |
|---|---|
| Int4 | The difference of the two vectors. |
Subtract(ref Int4, ref Int4, out Int4)
Subtracts two vectors.
public static void Subtract(ref Int4 left, ref Int4 right, out Int4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first vector to subtract. |
| Int4 | right | The second vector to subtract. |
| Int4 | result | When the method completes, contains the difference of the two vectors. |
ToArray()
Creates an array containing the elements of the vector.
public int[] ToArray()
Returns
| Type | Description |
|---|---|
| System.Int32[] | A four-element array containing the components of the vector. |
ToString()
Returns a System.String that represents this instance.
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
Overrides
ToString(IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(IFormatProvider formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IFormatProvider | formatProvider | The format provider. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
ToString(String)
Returns a System.String that represents this instance.
public string ToString(string format)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | format | The format. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
ToString(String, IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | format | The format. |
| System.IFormatProvider | formatProvider | The format provider. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
Operators
Addition(Int4, Int4)
Adds two vectors.
public static Int4 operator +(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first vector to add. |
| Int4 | right | The second vector to add. |
Returns
| Type | Description |
|---|---|
| Int4 | The sum of the two vectors. |
Division(Int4, Int32)
Scales a vector by the given value.
public static Int4 operator /(Int4 value, int scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to scale. |
| System.Int32 | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Int4 | The scaled vector. |
Equality(Int4, Int4)
Tests for equality between two objects.
public static bool operator ==(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first value to compare. |
| Int4 | right | The second value to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Explicit(Int4 to Vector2)
public static explicit operator Vector2(Int4 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The value. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the conversion. |
Explicit(Int4 to Vector3)
public static explicit operator Vector3(Int4 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The value. |
Returns
| Type | Description |
|---|---|
| Vector3 | The result of the conversion. |
Explicit(Int4 to Vector4)
public static explicit operator Vector4(Int4 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The value. |
Returns
| Type | Description |
|---|---|
| Vector4 | The result of the conversion. |
Implicit(Int4 to Int32[])
Performs an implicit conversion from Int4 to System.Int32 array.
public static implicit operator int[](Int4 input)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | input | The input. |
Returns
| Type | Description |
|---|---|
| System.Int32[] | The result of the conversion. |
Implicit(Int32[] to Int4)
Performs an implicit conversion from System.Int32 array to Int4.
public static implicit operator Int4(int[] input)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32[] | input | The input. |
Returns
| Type | Description |
|---|---|
| Int4 | The result of the conversion. |
Inequality(Int4, Int4)
Tests for inequality between two objects.
public static bool operator !=(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first value to compare. |
| Int4 | right | The second value to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Multiply(Int4, Int32)
Scales a vector by the given value.
public static Int4 operator *(Int4 value, int scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to scale. |
| System.Int32 | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Int4 | The scaled vector. |
Multiply(Int32, Int4)
Scales a vector by the given value.
public static Int4 operator *(int scale, Int4 value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | scale | The amount by which to scale the vector. |
| Int4 | value | The vector to scale. |
Returns
| Type | Description |
|---|---|
| Int4 | The scaled vector. |
Subtraction(Int4, Int4)
Subtracts two vectors.
public static Int4 operator -(Int4 left, Int4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | left | The first vector to subtract. |
| Int4 | right | The second vector to subtract. |
Returns
| Type | Description |
|---|---|
| Int4 | The difference of the two vectors. |
UnaryNegation(Int4)
Reverses the direction of a given vector.
public static Int4 operator -(Int4 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to negate. |
Returns
| Type | Description |
|---|---|
| Int4 | A vector facing in the opposite direction. |
UnaryPlus(Int4)
Assert a vector (return it unchanged).
public static Int4 operator +(Int4 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int4 | value | The vector to assert (unchange). |
Returns
| Type | Description |
|---|---|
| Int4 | The asserted (unchanged) vector. |