Table of Contents

Struct Int3

Namespace
Stride.Core.Mathematics
Assembly
Stride.Core.Mathematics.dll

Represents a three dimensional mathematical vector.

[DataContract("Int3")]
[DataStyle(DataStyle.Compact)]
public struct Int3 : IEquatable<Int3>, IFormattable
Implements

Constructors

Int3(Vector2, int)

Initializes a new instance of the Int3 struct.

public Int3(Vector2 value, int z)

Parameters

value Vector2

A vector containing the values with which to initialize the X and Y components.

z int

Initial value for the Z component of the vector.

Int3(int)

Initializes a new instance of the Int3 struct.

public Int3(int value)

Parameters

value int

The value that will be assigned to all components.

Int3(int, int, int)

Initializes a new instance of the Int3 struct.

public Int3(int x, int y, int z)

Parameters

x int

Initial value for the X component of the vector.

y int

Initial value for the Y component of the vector.

z int

Initial value for the Z component of the vector.

Int3(int[])

Initializes a new instance of the Int3 struct.

public Int3(int[] values)

Parameters

values int[]

The values to assign to the X, Y, and Z components of the vector. This must be an array with three elements.

Exceptions

ArgumentNullException

Thrown when values is null.

ArgumentOutOfRangeException

Thrown when values contains more or less than three elements.

Fields

One

A Int3 with all of its components set to one.

public static readonly Int3 One

Field Value

Int3

SizeInBytes

The size of the Int3 type, in bytes.

public static readonly int SizeInBytes

Field Value

int

UnitX

The X unit Int3 (1, 0, 0).

public static readonly Int3 UnitX

Field Value

Int3

UnitY

The Y unit Int3 (0, 1, 0).

public static readonly Int3 UnitY

Field Value

Int3

UnitZ

The Z unit Int3 (0, 0, 1).

public static readonly Int3 UnitZ

Field Value

Int3

X

The X component of the vector.

[DataMember(0)]
public int X

Field Value

int

Y

The Y component of the vector.

[DataMember(1)]
public int Y

Field Value

int

Z

The Z component of the vector.

[DataMember(2)]
public int Z

Field Value

int

Zero

A Int3 with all of its components set to zero.

public static readonly Int3 Zero

Field Value

Int3

Properties

this[int]

Gets or sets the component at the specified index.

public int this[int index] { get; set; }

Parameters

index int

The index of the component to access. Use 0 for the X component, 1 for the Y component, and 2 for the Z component.

Property Value

int

The value of the X, Y, or Z component, depending on the index.

Exceptions

ArgumentOutOfRangeException

Thrown when the index is out of the range [0, 2].

Methods

Add(Int3, Int3)

Adds two vectors.

public static Int3 Add(Int3 left, Int3 right)

Parameters

left Int3

The first vector to add.

right Int3

The second vector to add.

Returns

Int3

The sum of the two vectors.

Add(ref Int3, ref Int3, out Int3)

Adds two vectors.

public static void Add(ref Int3 left, ref Int3 right, out Int3 result)

Parameters

left Int3

The first vector to add.

right Int3

The second vector to add.

result Int3

When the method completes, contains the sum of the two vectors.

Clamp(Int3, Int3, Int3)

Restricts a value to be within a specified range.

public static Int3 Clamp(Int3 value, Int3 min, Int3 max)

Parameters

value Int3

The value to clamp.

min Int3

The minimum value.

max Int3

The maximum value.

Returns

Int3

The clamped value.

Clamp(ref Int3, ref Int3, ref Int3, out Int3)

Restricts a value to be within a specified range.

public static void Clamp(ref Int3 value, ref Int3 min, ref Int3 max, out Int3 result)

Parameters

value Int3

The value to clamp.

min Int3

The minimum value.

max Int3

The maximum value.

result Int3

When the method completes, contains the clamped value.

Deconstruct(out int, out int, out int)

Deconstructs the vector's components into named variables.

public void Deconstruct(out int x, out int y, out int z)

Parameters

x int

The X component

y int

The Y component

z int

The Z component

Divide(Int3, int)

Scales a vector by the given value.

public static Int3 Divide(Int3 value, int scale)

Parameters

value Int3

The vector to scale.

scale int

The amount by which to scale the vector.

Returns

Int3

The scaled vector.

Divide(ref Int3, int, out Int3)

Scales a vector by the given value.

public static void Divide(ref Int3 value, int scale, out Int3 result)

Parameters

value Int3

The vector to scale.

scale int

The amount by which to scale the vector.

result Int3

When the method completes, contains the scaled vector.

Dot(Int3, Int3)

Calculates the dot product of two vectors.

public static int Dot(Int3 left, Int3 right)

Parameters

left Int3

First source vector.

right Int3

Second source vector.

Returns

int

The dot product of the two vectors.

Dot(ref Int3, ref Int3, out int)

Calculates the dot product of two vectors.

public static void Dot(ref Int3 left, ref Int3 right, out int result)

Parameters

left Int3

First source vector.

right Int3

Second source vector.

result int

When the method completes, contains the dot product of the two vectors.

Equals(Int3)

Determines whether the specified Int3 is equal to this instance.

public bool Equals(Int3 other)

Parameters

other Int3

The Int3 to compare with this instance.

Returns

bool

true if the specified Int3 is equal to this instance; otherwise, false.

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object value)

Parameters

value object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

GetHashCode()

Returns a hash code for this instance.

public override int GetHashCode()

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Length()

Calculates the length of the vector.

public int Length()

Returns

int

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

int

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.

LengthUntruncated()

Calculates the untruncated length of the vector.

public float LengthUntruncated()

Returns

float

The length of the vector untruncated.

Lerp(Int3, Int3, float)

Performs a linear interpolation between two vectors.

public static Int3 Lerp(Int3 start, Int3 end, float amount)

Parameters

start Int3

Start vector.

end Int3

End vector.

amount float

Value between 0 and 1 indicating the weight of end.

Returns

Int3

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 Int3, ref Int3, float, out Int3)

Performs a linear interpolation between two vectors.

public static void Lerp(ref Int3 start, ref Int3 end, float amount, out Int3 result)

Parameters

start Int3

Start vector.

end Int3

End vector.

amount float

Value between 0 and 1 indicating the weight of end.

result Int3

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(Int3, Int3)

Returns a vector containing the largest components of the specified vectors.

public static Int3 Max(Int3 left, Int3 right)

Parameters

left Int3

The first source vector.

right Int3

The second source vector.

Returns

Int3

A vector containing the largest components of the source vectors.

Max(ref Int3, ref Int3, out Int3)

Returns a vector containing the smallest components of the specified vectors.

public static void Max(ref Int3 left, ref Int3 right, out Int3 result)

Parameters

left Int3

The first source vector.

right Int3

The second source vector.

result Int3

When the method completes, contains an new vector composed of the largest components of the source vectors.

Min(Int3, Int3)

Returns a vector containing the smallest components of the specified vectors.

public static Int3 Min(Int3 left, Int3 right)

Parameters

left Int3

The first source vector.

right Int3

The second source vector.

Returns

Int3

A vector containing the smallest components of the source vectors.

Min(ref Int3, ref Int3, out Int3)

Returns a vector containing the smallest components of the specified vectors.

public static void Min(ref Int3 left, ref Int3 right, out Int3 result)

Parameters

left Int3

The first source vector.

right Int3

The second source vector.

result Int3

When the method completes, contains an new vector composed of the smallest components of the source vectors.

Modulate(Int3, Int3)

Modulates a vector with another by performing component-wise multiplication.

public static Int3 Modulate(Int3 left, Int3 right)

Parameters

left Int3

The first vector to modulate.

right Int3

The second vector to modulate.

Returns

Int3

The modulated vector.

Modulate(ref Int3, ref Int3, out Int3)

Modulates a vector with another by performing component-wise multiplication.

public static void Modulate(ref Int3 left, ref Int3 right, out Int3 result)

Parameters

left Int3

The first vector to modulate.

right Int3

The second vector to modulate.

result Int3

When the method completes, contains the modulated vector.

Multiply(Int3, int)

Scales a vector by the given value.

public static Int3 Multiply(Int3 value, int scale)

Parameters

value Int3

The vector to scale.

scale int

The amount by which to scale the vector.

Returns

Int3

The scaled vector.

Multiply(ref Int3, int, out Int3)

Scales a vector by the given value.

public static void Multiply(ref Int3 value, int scale, out Int3 result)

Parameters

value Int3

The vector to scale.

scale int

The amount by which to scale the vector.

result Int3

When the method completes, contains the scaled vector.

Negate(Int3)

Reverses the direction of a given vector.

public static Int3 Negate(Int3 value)

Parameters

value Int3

The vector to negate.

Returns

Int3

A vector facing in the opposite direction.

Negate(ref Int3, out Int3)

Reverses the direction of a given vector.

public static void Negate(ref Int3 value, out Int3 result)

Parameters

value Int3

The vector to negate.

result Int3

When the method completes, contains a vector facing in the opposite direction.

Pow(int)

Raises the exponent for each components.

public void Pow(int exponent)

Parameters

exponent int

The exponent.

Round(in Vector3, out Int3, MidpointRounding)

Returns a vector containing the rounded values of the specified vector.

public static void Round(in Vector3 value, out Int3 result, MidpointRounding rounding = MidpointRounding.ToEven)

Parameters

value Vector3

The source vector.

result Int3

When the method completes, contains an new vector composed of the rounded values of the specified vector.

rounding MidpointRounding

The rounding strategy to use.

Round(in Vector3, MidpointRounding)

Returns a vector containing the rounded values of the specified vector.

public static Int3 Round(in Vector3 value, MidpointRounding rounding = MidpointRounding.ToEven)

Parameters

value Vector3

The source vector.

rounding MidpointRounding

The rounding strategy to use.

Returns

Int3

A vector containing the rounded values of the source vector.

SmoothStep(Int3, Int3, float)

Performs a cubic interpolation between two vectors.

public static Int3 SmoothStep(Int3 start, Int3 end, float amount)

Parameters

start Int3

Start vector.

end Int3

End vector.

amount float

Value between 0 and 1 indicating the weight of end.

Returns

Int3

The cubic interpolation of the two vectors.

SmoothStep(ref Int3, ref Int3, float, out Int3)

Performs a cubic interpolation between two vectors.

public static void SmoothStep(ref Int3 start, ref Int3 end, float amount, out Int3 result)

Parameters

start Int3

Start vector.

end Int3

End vector.

amount float

Value between 0 and 1 indicating the weight of end.

result Int3

When the method completes, contains the cubic interpolation of the two vectors.

Subtract(Int3, Int3)

Subtracts two vectors.

public static Int3 Subtract(Int3 left, Int3 right)

Parameters

left Int3

The first vector to subtract.

right Int3

The second vector to subtract.

Returns

Int3

The difference of the two vectors.

Subtract(ref Int3, ref Int3, out Int3)

Subtracts two vectors.

public static void Subtract(ref Int3 left, ref Int3 right, out Int3 result)

Parameters

left Int3

The first vector to subtract.

right Int3

The second vector to subtract.

result Int3

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

int[]

A three-element array containing the components of the vector.

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

ToString(IFormatProvider)

Returns a string that represents this instance.

public string ToString(IFormatProvider formatProvider)

Parameters

formatProvider IFormatProvider

The format provider.

Returns

string

A string that represents this instance.

ToString(string)

Returns a string that represents this instance.

public string ToString(string format)

Parameters

format string

The format.

Returns

string

A string that represents this instance.

ToString(string, IFormatProvider)

Returns a string that represents this instance.

public string ToString(string format, IFormatProvider formatProvider)

Parameters

format string

The format.

formatProvider IFormatProvider

The format provider.

Returns

string

A string that represents this instance.

Operators

operator +(Int3, Int3)

Adds two vectors.

public static Int3 operator +(Int3 left, Int3 right)

Parameters

left Int3

The first vector to add.

right Int3

The second vector to add.

Returns

Int3

The sum of the two vectors.

operator /(Int3, float)

Scales a vector by the given value.

public static Int3 operator /(Int3 value, float scale)

Parameters

value Int3

The vector to scale.

scale float

The amount by which to scale the vector.

Returns

Int3

The scaled vector.

operator ==(Int3, Int3)

Tests for equality between two objects.

public static bool operator ==(Int3 left, Int3 right)

Parameters

left Int3

The first value to compare.

right Int3

The second value to compare.

Returns

bool

true if left has the same value as right; otherwise, false.

explicit operator Vector2(Int3)

Performs an explicit conversion from Int3 to Vector2.

public static explicit operator Vector2(Int3 value)

Parameters

value Int3

The value.

Returns

Vector2

The result of the conversion.

explicit operator Vector3(Int3)

Performs an explicit conversion from Int3 to Vector3.

public static explicit operator Vector3(Int3 value)

Parameters

value Int3

The value.

Returns

Vector3

The result of the conversion.

explicit operator Vector4(Int3)

Performs an explicit conversion from Int3 to Vector4.

public static explicit operator Vector4(Int3 value)

Parameters

value Int3

The value.

Returns

Vector4

The result of the conversion.

operator !=(Int3, Int3)

Tests for inequality between two objects.

public static bool operator !=(Int3 left, Int3 right)

Parameters

left Int3

The first value to compare.

right Int3

The second value to compare.

Returns

bool

true if left has a different value than right; otherwise, false.

operator *(Int3, float)

Scales a vector by the given value.

public static Int3 operator *(Int3 value, float scale)

Parameters

value Int3

The vector to scale.

scale float

The amount by which to scale the vector.

Returns

Int3

The scaled vector.

operator *(float, Int3)

Scales a vector by the given value.

public static Int3 operator *(float scale, Int3 value)

Parameters

scale float

The amount by which to scale the vector.

value Int3

The vector to scale.

Returns

Int3

The scaled vector.

operator -(Int3, Int3)

Subtracts two vectors.

public static Int3 operator -(Int3 left, Int3 right)

Parameters

left Int3

The first vector to subtract.

right Int3

The second vector to subtract.

Returns

Int3

The difference of the two vectors.

operator -(Int3)

Reverses the direction of a given vector.

public static Int3 operator -(Int3 value)

Parameters

value Int3

The vector to negate.

Returns

Int3

A vector facing in the opposite direction.

operator +(Int3)

Assert a vector (return it unchanged).

public static Int3 operator +(Int3 value)

Parameters

value Int3

The vector to assert (unchange).

Returns

Int3

The asserted (unchanged) vector.