Int2 Struct
Namespace: Stride.Core.MathematicsAssembly: Stride.Core.Mathematics.dll
Represents a three dimensional mathematical vector.
[DataContract("Int2")]
[DataStyle(DataStyle.Compact)]
public struct Int2 : IEquatable<Int2>, IFormattable
Name | Description | |
---|---|---|
Constructors | ||
Int2(Vector2) | Initializes a new instance of the Int2 struct. |
|
Int2(Int32) | Initializes a new instance of the Int2 struct. |
|
Int2(Int32, Int32) | Initializes a new instance of the Int2 struct. |
|
Int2(Int32[]) | Initializes a new instance of the Int2 struct. |
|
Fields | ||
One | A Int2 with all of its components set to one. |
|
SizeInBytes | The size of the Int2 type, in bytes. |
|
UnitX | The X unit Int2 (1, 0, 0). |
|
UnitY | The Y unit Int2 (0, 1, 0). |
|
X | The X component of the vector. |
|
Y | The Y component of the vector. |
|
Zero | A Int2 with all of its components set to zero. |
|
Properties | ||
Item[Int32] | Gets or sets the component at the specified index. |
|
Methods | ||
Add(Int2, Int2) | Adds two vectors. |
|
Add(ref Int2, ref Int2, out Int2) | Adds two vectors. |
|
Clamp(Int2, Int2, Int2) | Restricts a value to be within a specified range. |
|
Clamp(ref Int2, ref Int2, ref Int2, out Int2) | Restricts a value to be within a specified range. |
|
Divide(Int2, Int32) | Scales a vector by the given value. |
|
Divide(ref Int2, Int32, out Int2) | Scales a vector by the given value. |
|
Dot(Int2, Int2) | Calculates the dot product of two vectors. |
|
Dot(ref Int2, ref Int2, out Int32) | Calculates the dot product of two vectors. |
|
Equals(Int2) | Determines whether the specified Int2 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. |
|
Lerp(Int2, Int2, Single) | Performs a linear interpolation between two vectors. |
|
Lerp(ref Int2, ref Int2, Single, out Int2) | Performs a linear interpolation between two vectors. |
|
Max(Int2, Int2) | Returns a vector containing the largest components of the specified vectors. |
|
Max(ref Int2, ref Int2, out Int2) | Returns a vector containing the smallest components of the specified vectors. |
|
Min(Int2, Int2) | Returns a vector containing the smallest components of the specified vectors. |
|
Min(ref Int2, ref Int2, out Int2) | Returns a vector containing the smallest components of the specified vectors. |
|
Modulate(Int2, Int2) | Modulates a vector with another by performing component-wise multiplication. |
|
Modulate(ref Int2, ref Int2, out Int2) | Modulates a vector with another by performing component-wise multiplication. |
|
Multiply(Int2, Int32) | Scales a vector by the given value. |
|
Multiply(ref Int2, Int32, out Int2) | Scales a vector by the given value. |
|
Negate(Int2) | Reverses the direction of a given vector. |
|
Negate(ref Int2, out Int2) | Reverses the direction of a given vector. |
|
Pow(Int32) | Raises the exponent for each components. |
|
SmoothStep(Int2, Int2, Single) | Performs a cubic interpolation between two vectors. |
|
SmoothStep(ref Int2, ref Int2, Single, out Int2) | Performs a cubic interpolation between two vectors. |
|
Subtract(Int2, Int2) | Subtracts two vectors. |
|
Subtract(ref Int2, ref Int2, out Int2) | 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(Int2, Int2) | Adds two vectors. |
|
Division(Int2, Single) | Scales a vector by the given value. |
|
Equality(Int2, Int2) | Tests for equality between two objects. |
|
Explicit(Int2 to Vector2) | ||
Explicit(Int2 to Vector4) | ||
Inequality(Int2, Int2) | Tests for inequality between two objects. |
|
Multiply(Int2, Single) | Scales a vector by the given value. |
|
Multiply(Single, Int2) | Scales a vector by the given value. |
|
Subtraction(Int2, Int2) | Subtracts two vectors. |
|
UnaryNegation(Int2) | Reverses the direction of a given vector. |
|
UnaryPlus(Int2) | Assert a vector (return it unchanged). |
Constructors
Int2(Vector2)
Initializes a new instance of the Int2 struct.
public Int2(Vector2 value)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | A vector containing the values with which to initialize the X and Y components. |
Int2(Int32)
Initializes a new instance of the Int2 struct.
public Int2(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value that will be assigned to all components. |
Int2(Int32, Int32)
Initializes a new instance of the Int2 struct.
public Int2(int x, int y)
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. |
Int2(Int32[])
Initializes a new instance of the Int2 struct.
public Int2(int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | The values to assign to the X, Y, and Z components of the vector. This must be an array with three elements. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
Fields
One
A Int2 with all of its components set to one.
public static readonly Int2 One
Field Value
Type | Description |
---|---|
Int2 |
SizeInBytes
The size of the Int2 type, in bytes.
public static readonly int SizeInBytes
Field Value
Type | Description |
---|---|
System.Int32 |
UnitX
The X unit Int2 (1, 0, 0).
public static readonly Int2 UnitX
Field Value
Type | Description |
---|---|
Int2 |
UnitY
The Y unit Int2 (0, 1, 0).
public static readonly Int2 UnitY
Field Value
Type | Description |
---|---|
Int2 |
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 |
Zero
A Int2 with all of its components set to zero.
public static readonly Int2 Zero
Field Value
Type | Description |
---|---|
Int2 |
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 and 1 for the Y component. |
Property Value
Type | Description |
---|---|
System.Int32 | The value of the X or Y component, depending on the index. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when the |
Methods
Add(Int2, Int2)
Adds two vectors.
public static Int2 Add(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first vector to add. |
Int2 | right | The second vector to add. |
Returns
Type | Description |
---|---|
Int2 | The sum of the two vectors. |
Add(ref Int2, ref Int2, out Int2)
Adds two vectors.
public static void Add(ref Int2 left, ref Int2 right, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first vector to add. |
Int2 | right | The second vector to add. |
Int2 | result | When the method completes, contains the sum of the two vectors. |
Clamp(Int2, Int2, Int2)
Restricts a value to be within a specified range.
public static Int2 Clamp(Int2 value, Int2 min, Int2 max)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The value to clamp. |
Int2 | min | The minimum value. |
Int2 | max | The maximum value. |
Returns
Type | Description |
---|---|
Int2 | The clamped value. |
Clamp(ref Int2, ref Int2, ref Int2, out Int2)
Restricts a value to be within a specified range.
public static void Clamp(ref Int2 value, ref Int2 min, ref Int2 max, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The value to clamp. |
Int2 | min | The minimum value. |
Int2 | max | The maximum value. |
Int2 | result | When the method completes, contains the clamped value. |
Divide(Int2, Int32)
Scales a vector by the given value.
public static Int2 Divide(Int2 value, int scale)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to scale. |
System.Int32 | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Int2 | The scaled vector. |
Divide(ref Int2, Int32, out Int2)
Scales a vector by the given value.
public static void Divide(ref Int2 value, int scale, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to scale. |
System.Int32 | scale | The amount by which to scale the vector. |
Int2 | result | When the method completes, contains the scaled vector. |
Dot(Int2, Int2)
Calculates the dot product of two vectors.
public static int Dot(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | First source vector. |
Int2 | right | Second source vector. |
Returns
Type | Description |
---|---|
System.Int32 | The dot product of the two vectors. |
Dot(ref Int2, ref Int2, out Int32)
Calculates the dot product of two vectors.
public static void Dot(ref Int2 left, ref Int2 right, out int result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | First source vector. |
Int2 | right | Second source vector. |
System.Int32 | result | When the method completes, contains the dot product of the two vectors. |
Equals(Int2)
Determines whether the specified Int2 is equal to this instance.
public bool Equals(Int2 other)
Parameters
Type | Name | Description |
---|---|---|
Int2 | other | The Int2 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.
Lerp(Int2, Int2, Single)
Performs a linear interpolation between two vectors.
public static Int2 Lerp(Int2 start, Int2 end, float amount)
Parameters
Type | Name | Description |
---|---|---|
Int2 | start | Start vector. |
Int2 | end | End vector. |
System.Single | amount | Value between 0 and 1 indicating the weight of |
Returns
Type | Description |
---|---|
Int2 | The linear interpolation of the two vectors. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount
a value of 0 will cause start
to be returned; a value of 1 will cause end
to be returned.
Lerp(ref Int2, ref Int2, Single, out Int2)
Performs a linear interpolation between two vectors.
public static void Lerp(ref Int2 start, ref Int2 end, float amount, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | start | Start vector. |
Int2 | end | End vector. |
System.Single | amount | Value between 0 and 1 indicating the weight of |
Int2 | result | When the method completes, contains the linear interpolation of the two vectors. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount
a value of 0 will cause start
to be returned; a value of 1 will cause end
to be returned.
Max(Int2, Int2)
Returns a vector containing the largest components of the specified vectors.
public static Int2 Max(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first source vector. |
Int2 | right | The second source vector. |
Returns
Type | Description |
---|---|
Int2 | A vector containing the largest components of the source vectors. |
Max(ref Int2, ref Int2, out Int2)
Returns a vector containing the smallest components of the specified vectors.
public static void Max(ref Int2 left, ref Int2 right, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first source vector. |
Int2 | right | The second source vector. |
Int2 | result | When the method completes, contains an new vector composed of the largest components of the source vectors. |
Min(Int2, Int2)
Returns a vector containing the smallest components of the specified vectors.
public static Int2 Min(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first source vector. |
Int2 | right | The second source vector. |
Returns
Type | Description |
---|---|
Int2 | A vector containing the smallest components of the source vectors. |
Min(ref Int2, ref Int2, out Int2)
Returns a vector containing the smallest components of the specified vectors.
public static void Min(ref Int2 left, ref Int2 right, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first source vector. |
Int2 | right | The second source vector. |
Int2 | result | When the method completes, contains an new vector composed of the smallest components of the source vectors. |
Modulate(Int2, Int2)
Modulates a vector with another by performing component-wise multiplication.
public static Int2 Modulate(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first vector to modulate. |
Int2 | right | The second vector to modulate. |
Returns
Type | Description |
---|---|
Int2 | The modulated vector. |
Modulate(ref Int2, ref Int2, out Int2)
Modulates a vector with another by performing component-wise multiplication.
public static void Modulate(ref Int2 left, ref Int2 right, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first vector to modulate. |
Int2 | right | The second vector to modulate. |
Int2 | result | When the method completes, contains the modulated vector. |
Multiply(Int2, Int32)
Scales a vector by the given value.
public static Int2 Multiply(Int2 value, int scale)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to scale. |
System.Int32 | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Int2 | The scaled vector. |
Multiply(ref Int2, Int32, out Int2)
Scales a vector by the given value.
public static void Multiply(ref Int2 value, int scale, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to scale. |
System.Int32 | scale | The amount by which to scale the vector. |
Int2 | result | When the method completes, contains the scaled vector. |
Negate(Int2)
Reverses the direction of a given vector.
public static Int2 Negate(Int2 value)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to negate. |
Returns
Type | Description |
---|---|
Int2 | A vector facing in the opposite direction. |
Negate(ref Int2, out Int2)
Reverses the direction of a given vector.
public static void Negate(ref Int2 value, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to negate. |
Int2 | result | When the method completes, contains a vector facing in the opposite direction. |
Pow(Int32)
Raises the exponent for each components.
public void Pow(int exponent)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | exponent | The exponent. |
SmoothStep(Int2, Int2, Single)
Performs a cubic interpolation between two vectors.
public static Int2 SmoothStep(Int2 start, Int2 end, float amount)
Parameters
Type | Name | Description |
---|---|---|
Int2 | start | Start vector. |
Int2 | end | End vector. |
System.Single | amount | Value between 0 and 1 indicating the weight of |
Returns
Type | Description |
---|---|
Int2 | The cubic interpolation of the two vectors. |
SmoothStep(ref Int2, ref Int2, Single, out Int2)
Performs a cubic interpolation between two vectors.
public static void SmoothStep(ref Int2 start, ref Int2 end, float amount, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | start | Start vector. |
Int2 | end | End vector. |
System.Single | amount | Value between 0 and 1 indicating the weight of |
Int2 | result | When the method completes, contains the cubic interpolation of the two vectors. |
Subtract(Int2, Int2)
Subtracts two vectors.
public static Int2 Subtract(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first vector to subtract. |
Int2 | right | The second vector to subtract. |
Returns
Type | Description |
---|---|
Int2 | The difference of the two vectors. |
Subtract(ref Int2, ref Int2, out Int2)
Subtracts two vectors.
public static void Subtract(ref Int2 left, ref Int2 right, out Int2 result)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first vector to subtract. |
Int2 | right | The second vector to subtract. |
Int2 | 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 two-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(Int2, Int2)
Adds two vectors.
public static Int2 operator +(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first vector to add. |
Int2 | right | The second vector to add. |
Returns
Type | Description |
---|---|
Int2 | The sum of the two vectors. |
Division(Int2, Single)
Scales a vector by the given value.
public static Int2 operator /(Int2 value, float scale)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to scale. |
System.Single | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Int2 | The scaled vector. |
Equality(Int2, Int2)
Tests for equality between two objects.
public static bool operator ==(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first value to compare. |
Int2 | right | The second value to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Explicit(Int2 to Vector2)
public static explicit operator Vector2(Int2 value)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The value. |
Returns
Type | Description |
---|---|
Vector2 | The result of the conversion. |
Explicit(Int2 to Vector4)
public static explicit operator Vector4(Int2 value)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The value. |
Returns
Type | Description |
---|---|
Vector4 | The result of the conversion. |
Inequality(Int2, Int2)
Tests for inequality between two objects.
public static bool operator !=(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first value to compare. |
Int2 | right | The second value to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Multiply(Int2, Single)
Scales a vector by the given value.
public static Int2 operator *(Int2 value, float scale)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to scale. |
System.Single | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Int2 | The scaled vector. |
Multiply(Single, Int2)
Scales a vector by the given value.
public static Int2 operator *(float scale, Int2 value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | scale | The amount by which to scale the vector. |
Int2 | value | The vector to scale. |
Returns
Type | Description |
---|---|
Int2 | The scaled vector. |
Subtraction(Int2, Int2)
Subtracts two vectors.
public static Int2 operator -(Int2 left, Int2 right)
Parameters
Type | Name | Description |
---|---|---|
Int2 | left | The first vector to subtract. |
Int2 | right | The second vector to subtract. |
Returns
Type | Description |
---|---|
Int2 | The difference of the two vectors. |
UnaryNegation(Int2)
Reverses the direction of a given vector.
public static Int2 operator -(Int2 value)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to negate. |
Returns
Type | Description |
---|---|
Int2 | A vector facing in the opposite direction. |
UnaryPlus(Int2)
Assert a vector (return it unchanged).
public static Int2 operator +(Int2 value)
Parameters
Type | Name | Description |
---|---|---|
Int2 | value | The vector to assert (unchange). |
Returns
Type | Description |
---|---|
Int2 | The asserted (unchanged) vector. |