Struct int3
Represents a 3D vector using integers.
Implements
Inherited Members
Namespace: Fusee.Math.Core
Assembly: Fusee.Math.Core.dll
Syntax
public struct int3 : IEquatable<int3>
Remarks
The int3 structure is suitable for inter-operation with unmanaged code requiring three consecutive ints.
Constructors
int3(double3)
Constructs a new int3 by converting from a double3.
Declaration
public int3(double3 d3)
Parameters
Type | Name | Description |
---|---|---|
double3 | d3 | The double3 to copy components from. |
int3(float3)
Constructs a new int3 by converting from a double3.
Declaration
public int3(float3 d3)
Parameters
Type | Name | Description |
---|---|---|
float3 | d3 | The double3 to copy components from. |
int3(int2)
Constructs a new int3 from the given int2.
Declaration
public int3(int2 v)
Parameters
Type | Name | Description |
---|---|---|
int2 | v | The int2 to copy components from. |
int3(int3)
Constructs a new int3 from the given int3.
Declaration
public int3(int3 v)
Parameters
Type | Name | Description |
---|---|---|
int3 | v | The int3 to copy components from. |
int3(int4)
Constructs a new int3 from the given int3.
Declaration
public int3(int4 v)
Parameters
Type | Name | Description |
---|---|---|
int4 | v | The int3 to copy components from. |
int3(Int32)
Constructs a new int3.
Declaration
public int3(int val)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | val | This value will be set for the x, y and z component. |
int3(Int32, Int32, Int32)
Constructs a new int3.
Declaration
public int3(int x, int y, int z)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The x component of the int3. |
System.Int32 | y | The y component of the int3. |
System.Int32 | z | The z component of the int3. |
Fields
One
Defines an instance with all components set to 1.
Declaration
public static readonly int3 One
Field Value
Type | Description |
---|---|
int3 |
UnitX
Defines a unit-length int3 that points towards the x-axis.
Declaration
public static readonly int3 UnitX
Field Value
Type | Description |
---|---|
int3 |
UnitY
Defines a unit-length int3 that points towards the y-axis.
Declaration
public static readonly int3 UnitY
Field Value
Type | Description |
---|---|
int3 |
UnitZ
Defines a unit-length int3 that points towards the z-axis.
Declaration
public static readonly int3 UnitZ
Field Value
Type | Description |
---|---|
int3 |
x
The x component of the int3.
Declaration
public int x
Field Value
Type | Description |
---|---|
System.Int32 |
y
The y component of the int3.
Declaration
public int y
Field Value
Type | Description |
---|---|
System.Int32 |
z
The z component of the int3.
Declaration
public int z
Field Value
Type | Description |
---|---|
System.Int32 |
Zero
Defines a zero-length int3.
Declaration
public static readonly int3 Zero
Field Value
Type | Description |
---|---|
int3 |
Properties
b
The blue component (same as z)
Declaration
public int b { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
g
The green component (same as y)
Declaration
public int g { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Int32]
Gets or sets the individual components x, y, or z, depending on their index.
Declaration
public int this[int idx] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index (between 0 and 2). |
Property Value
Type | Description |
---|---|
System.Int32 | The x or y component of the int3. |
Length
Gets the length (magnitude) of the vector.
Declaration
public readonly float Length { get; }
Property Value
Type | Description |
---|---|
System.Single | The length. |
LengthSquared
Gets the square of the vector length (magnitude).
Declaration
public readonly int LengthSquared { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The length squared. |
Remarks
This property avoids the costly square root operation required by the Length property. This makes it more suitable for comparisons.
ParseConverter
Gets and sets the Converter object. Has the ability to convert a string to a int3.
Declaration
public static Converter<string, int3> ParseConverter { get; set; }
Property Value
Type | Description |
---|---|
Converter<System.String, int3> | The parse property. |
r
The red component (same as x)
Declaration
public int r { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
xy
Gets or sets an OpenTK.int2 with the x and y components of this instance.
Declaration
public int2 xy { get; set; }
Property Value
Type | Description |
---|---|
int2 |
xyz
Gets or sets an OpenTK.int3 with the x, y and z components of this instance.
Declaration
public int3 xyz { get; set; }
Property Value
Type | Description |
---|---|
int3 |
xz
Gets or sets an OpenTK.int2 with the x and z components of this instance.
Declaration
public int2 xz { get; set; }
Property Value
Type | Description |
---|---|
int2 |
xzy
Gets or sets an OpenTK.int3 with the x, z and y components of this instance.
Declaration
public int3 xzy { get; set; }
Property Value
Type | Description |
---|---|
int3 |
yx
Gets or sets an OpenTK.int2 with the y and x components of this instance.
Declaration
public int2 yx { get; set; }
Property Value
Type | Description |
---|---|
int2 |
yxz
Gets or sets an OpenTK.int3 with the y, x and z components of this instance.
Declaration
public int3 yxz { get; set; }
Property Value
Type | Description |
---|---|
int3 |
yz
Gets or sets an OpenTK.int2 with the y and z components of this instance.
Declaration
public int2 yz { get; set; }
Property Value
Type | Description |
---|---|
int2 |
yzx
Gets or sets an OpenTK.int3 with the y, z and x components of this instance.
Declaration
public int3 yzx { get; set; }
Property Value
Type | Description |
---|---|
int3 |
zx
Gets or sets an OpenTK.int2 with the z and x components of this instance.
Declaration
public int2 zx { get; set; }
Property Value
Type | Description |
---|---|
int2 |
zxy
Gets or sets an OpenTK.int3 with the z, x and y components of this instance.
Declaration
public int3 zxy { get; set; }
Property Value
Type | Description |
---|---|
int3 |
zy
Gets or sets an OpenTK.int2 with the z and y components of this instance.
Declaration
public int2 zy { get; set; }
Property Value
Type | Description |
---|---|
int2 |
zyx
Gets or sets an OpenTK.int3 with the z, y and x components of this instance.
Declaration
public int3 zyx { get; set; }
Property Value
Type | Description |
---|---|
int3 |
Methods
Add(int3, int3)
Adds two vectors.
Declaration
public static int3 Add(int3 a, int3 b)
Parameters
Type | Name | Description |
---|---|---|
int3 | a | Left operand. |
int3 | b | Right operand. |
Returns
Type | Description |
---|---|
int3 | Result of operation. |
Add(int3, Int32)
Adds a scalar to a instance.
Declaration
public static int3 Add(int3 vec, int scale)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec | The first instance. |
System.Int32 | scale | The scalar. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
CalculateAngle(int3, int3)
Calculates the angle (in radians) between two vectors.
Declaration
public static float CalculateAngle(int3 first, int3 second)
Parameters
Type | Name | Description |
---|---|---|
int3 | first | The first vector. |
int3 | second | The second vector. |
Returns
Type | Description |
---|---|
System.Single | Angle (in radians) between the vectors. |
Remarks
Note that the returned angle is never bigger than the constant Pi.
Clamp(int3, int3, int3)
Clamp a vector to the given minimum and maximum vectors
Declaration
public static int3 Clamp(int3 vec, int3 min, int3 max)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec | Input vector |
int3 | min | Minimum vector |
int3 | max | Maximum vector |
Returns
Type | Description |
---|---|
int3 | The clamped vector |
ComponentMax(int3, int3)
Calculate the component-wise maximum of two vectors
Declaration
public static int3 ComponentMax(int3 a, int3 b)
Parameters
Type | Name | Description |
---|---|---|
int3 | a | First operand |
int3 | b | Second operand |
Returns
Type | Description |
---|---|
int3 | The component-wise maximum |
ComponentMin(int3, int3)
Calculate the component-wise minimum of two vectors
Declaration
public static int3 ComponentMin(int3 a, int3 b)
Parameters
Type | Name | Description |
---|---|---|
int3 | a | First operand |
int3 | b | Second operand |
Returns
Type | Description |
---|---|
int3 | The component-wise minimum |
Cross(int3, int3)
Calculate the cross (vector) product of two vectors
Declaration
public static int3 Cross(int3 left, int3 right)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | First operand |
int3 | right | Second operand |
Returns
Type | Description |
---|---|
int3 | The cross product of the two inputs |
Divide(int3, int3)
Divides a vector by the components of a vector (scale).
Declaration
public static int3 Divide(int3 vector, int3 scale)
Parameters
Type | Name | Description |
---|---|---|
int3 | vector | Left operand. |
int3 | scale | Right operand. |
Returns
Type | Description |
---|---|
int3 | Result of the operation. |
Divide(int3, Int32)
Divides a vector by a scalar.
Declaration
public static int3 Divide(int3 vector, int scale)
Parameters
Type | Name | Description |
---|---|---|
int3 | vector | Left operand. |
System.Int32 | scale | Right operand. |
Returns
Type | Description |
---|---|
int3 | Result of the operation. |
Dot(int3, int3)
Calculate the dot (scalar) product of two vectors
Declaration
public static int Dot(int3 left, int3 right)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | First operand |
int3 | right | Second operand |
Returns
Type | Description |
---|---|
System.Int32 | The dot product of the two inputs |
Equals(int3)
Indicates whether the current vector is equal to another vector.
Declaration
public bool Equals(int3 other)
Parameters
Type | Name | Description |
---|---|---|
int3 | other | A vector to compare with this vector. |
Returns
Type | Description |
---|---|
System.Boolean | true if the current vector is equal to the vector parameter; otherwise, false. |
Equals(Object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | True if the instances are equal; false otherwise. |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A System.Int32 containing the unique hash code for this instance. |
Overrides
Lerp(int3, int3, float3)
Returns a new Vector that is the linear blend of the 2 given Vectors. Each component of vector a is blended with its equivalent in vector b.
Declaration
public static float3 Lerp(int3 a, int3 b, float3 blend)
Parameters
Type | Name | Description |
---|---|---|
int3 | a | First input vector |
int3 | b | Second input vector |
float3 | blend | The blend factor. a when blend=0, b when blend=1. |
Returns
Type | Description |
---|---|
float3 |
Lerp(int3, int3, Single)
Returns a new Vector that is the linear blend of the 2 given Vectors. Each component of vector a is blended with its equivalent in vector b.
Declaration
public static float3 Lerp(int3 a, int3 b, float blend)
Parameters
Type | Name | Description |
---|---|---|
int3 | a | First input vector |
int3 | b | Second input vector |
System.Single | blend | The blend factor. a when blend=0, b when blend=1. |
Returns
Type | Description |
---|---|
float3 |
LinearColorFromSRgb()
Converts this int3 - which is interpreted as a color - from linear color space to sRgb space.
Declaration
public int3 LinearColorFromSRgb()
Returns
Type | Description |
---|---|
int3 |
LinearColorFromSRgb(int3)
Converts a color value [0, 255] from sRgb to linear space.
Declaration
public static int3 LinearColorFromSRgb(int3 sRGBCol)
Parameters
Type | Name | Description |
---|---|---|
int3 | sRGBCol | The sRgb color value as int3. |
Returns
Type | Description |
---|---|
int3 |
LinearColorFromSRgb(Int32, Int32, Int32)
Converts a color value from sRgb to linear space.
Declaration
public static int3 LinearColorFromSRgb(int r, int g, int b)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | r | The red color value in range 0 - 255. |
System.Int32 | g | The green color value in range 0 - 255. |
System.Int32 | b | The blue color value in range 0 - 255. |
Returns
Type | Description |
---|---|
int3 |
LinearColorFromSRgb(String)
Converts a color value from sRgb to linear space.
Declaration
public static int3 LinearColorFromSRgb(string hex)
Parameters
Type | Name | Description |
---|---|---|
System.String | hex | The color value as hex code in form of a "FFFFFF" string. |
Returns
Type | Description |
---|---|
int3 |
LinearColorFromSRgb(UInt32)
Converts a color value from sRgb to linear space.
Declaration
public static int3 LinearColorFromSRgb(uint col)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | col | The color value as uint. |
Returns
Type | Description |
---|---|
int3 |
Max(int3, int3)
Returns the int3 with the maximum magnitude
Declaration
public static int3 Max(int3 left, int3 right)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | Left operand |
int3 | right | Right operand |
Returns
Type | Description |
---|---|
int3 | The maximum int3 |
Min(int3, int3)
Returns the int3 with the minimum magnitude
Declaration
public static int3 Min(int3 left, int3 right)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | Left operand |
int3 | right | Right operand |
Returns
Type | Description |
---|---|
int3 | The minimum int3 |
Multiply(int3, int3)
Multiplies a vector by the components a vector (scale).
Declaration
public static int3 Multiply(int3 vector, int3 scale)
Parameters
Type | Name | Description |
---|---|---|
int3 | vector | Left operand. |
int3 | scale | Right operand. |
Returns
Type | Description |
---|---|
int3 | Result of the operation. |
Multiply(int3, Int32)
Multiplies a vector by a scalar.
Declaration
public static int3 Multiply(int3 vector, int scale)
Parameters
Type | Name | Description |
---|---|---|
int3 | vector | Left operand. |
System.Int32 | scale | Right operand. |
Returns
Type | Description |
---|---|
int3 | Result of the operation. |
Normalize()
Scales the int3 to unit length.
Declaration
public float3 Normalize()
Returns
Type | Description |
---|---|
float3 |
Normalize(int3)
Scale a vector to unit length
Declaration
public static float3 Normalize(int3 vec)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec | The input vector |
Returns
Type | Description |
---|---|
float3 | The normalized vector |
NormalizeFast()
Scales the int3 to approximately unit length.
Declaration
public float3 NormalizeFast()
Returns
Type | Description |
---|---|
float3 |
NormalizeFast(int3)
Scale a vector to approximately unit length
Declaration
public static float3 NormalizeFast(int3 vec)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec | The input vector |
Returns
Type | Description |
---|---|
float3 | The normalized vector |
Parse(String, IFormatProvider)
Parses a string into a int3.
Declaration
public static int3 Parse(string source, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | |
System.IFormatProvider | provider |
Returns
Type | Description |
---|---|
int3 |
Pow(int3, Int32)
Returns a int3 where all components are raised to the specified power.
Declaration
public static int3 Pow(int3 val, int exp)
Parameters
Type | Name | Description |
---|---|---|
int3 | val | The int3 to be raised to a power. |
System.Int32 | exp | A int that specifies a power. |
Returns
Type | Description |
---|---|
int3 |
Rotate(float3, int3, Boolean)
Rotates a vector by the given euler-angles in the following order: yaw (y-axis), pitch (x-axis), roll (z-axis).
Declaration
public static float3 Rotate(float3 euler, int3 vec, bool inDegrees = false)
Parameters
Type | Name | Description |
---|---|---|
float3 | euler | The angles used for the rotation. |
int3 | vec | The vector to rotate. |
System.Boolean | inDegrees | Optional: Whether the angles are given in degrees (true) or radians (false). Default is radians. |
Returns
Type | Description |
---|---|
float3 | The rotated vector. |
Rotate(QuaternionF, int3)
Rotates a vector by the given quaternion.
Declaration
public static float3 Rotate(QuaternionF quat, int3 vec)
Parameters
Type | Name | Description |
---|---|---|
QuaternionF | quat | The quaternion used for the rotation. |
int3 | vec | The vector to rotate. |
Returns
Type | Description |
---|---|
float3 | The rotated vector. |
SRgbFromLinearColor()
Converts this int3 - which is interpreted as a color - from sRgb space to linear color space.
Declaration
public int3 SRgbFromLinearColor()
Returns
Type | Description |
---|---|
int3 |
SRgbFromLinearColor(int3)
Converts a color value [0, 255] from linear to sRgb space.
Declaration
public static int3 SRgbFromLinearColor(int3 linearColor)
Parameters
Type | Name | Description |
---|---|---|
int3 | linearColor | The linear color value as int3. |
Returns
Type | Description |
---|---|
int3 |
SRgbFromLinearColor(Int32, Int32, Int32)
Converts a color value from linear to sRgb space.
Declaration
public static int3 SRgbFromLinearColor(int r, int g, int b)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | r | The red color value in range 0 - 255. |
System.Int32 | g | The green color value in range 0 - 255. |
System.Int32 | b | The blue color value in range 0 - 255. |
Returns
Type | Description |
---|---|
int3 |
SRgbFromLinearColor(String)
Converts a color value from linear to sRgb space.
Declaration
public static int3 SRgbFromLinearColor(string hex)
Parameters
Type | Name | Description |
---|---|---|
System.String | hex | The color value as hex code in form of a "FFFFFF" string. |
Returns
Type | Description |
---|---|
int3 |
SRgbFromLinearColor(UInt32)
Converts a color value from linear to sRgb space.
Declaration
public static int3 SRgbFromLinearColor(uint col)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | col | The color value as uint. |
Returns
Type | Description |
---|---|
int3 |
Step(int3, int3)
Performs Step(Single, Single) for each component of the input vectors.
Declaration
public static int3 Step(int3 edge, int3 val)
Parameters
Type | Name | Description |
---|---|---|
int3 | edge | Specifies the location of the edge of the step function. |
int3 | val | Specifies the value to be used to generate the step function. |
Returns
Type | Description |
---|---|
int3 |
Subtract(int3, int3)
Subtract one Vector from another
Declaration
public static int3 Subtract(int3 a, int3 b)
Parameters
Type | Name | Description |
---|---|---|
int3 | a | First operand |
int3 | b | Second operand |
Returns
Type | Description |
---|---|
int3 | Result of subtraction |
Subtract(int3, Int32)
Adds a scalar from a instance.
Declaration
public static int3 Subtract(int3 vec, int scale)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec | The first instance. |
System.Int32 | scale | The scalar. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
ToArray()
Returns an array of ints with the three components of the vector.
Declaration
public int[] ToArray()
Returns
Type | Description |
---|---|
System.Int32[] | Returns an array of ints with the three components of the vector. |
ToString()
Returns a System.String that represents the current int3.
Declaration
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 the current int3.
Declaration
public string ToString(IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | provider | Provides information about a specific culture. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Operators
Addition(int3, int3)
Adds two instances.
Declaration
public static int3 operator +(int3 left, int3 right)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | The first instance. |
int3 | right | The second instance. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
Addition(int3, Int32)
Adds a scalar to a instance.
Declaration
public static int3 operator +(int3 left, int scalar)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | The first instance. |
System.Int32 | scalar | The scalar. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
Division(int3, Int32)
Divides an instance by a scalar.
Declaration
public static int3 operator /(int3 vec, int scale)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec | The instance. |
System.Int32 | scale | The scalar. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
Equality(int3, int3)
Compares two instances for equality.
Declaration
public static bool operator ==(int3 left, int3 right)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | The first instance. |
int3 | right | The second instance. |
Returns
Type | Description |
---|---|
System.Boolean | True, if left equals right; false otherwise. |
Explicit(double3 to int3)
Explicit cast operator to cast a double3 into a int3 value.
Declaration
public static explicit operator int3(double3 d3)
Parameters
Type | Name | Description |
---|---|---|
double3 | d3 | The double3 value to cast. |
Returns
Type | Description |
---|---|
int3 | A int3 value. |
Explicit(float3 to int3)
Explicit cast operator to cast a double3 into a int3 value.
Declaration
public static explicit operator int3(float3 f3)
Parameters
Type | Name | Description |
---|---|---|
float3 | f3 | The double3 value to cast. |
Returns
Type | Description |
---|---|
int3 | A int3 value. |
Inequality(int3, int3)
Compares two instances for inequality.
Declaration
public static bool operator !=(int3 left, int3 right)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | The first instance. |
int3 | right | The second instance. |
Returns
Type | Description |
---|---|
System.Boolean | True, if left does not equal right; false otherwise. |
Multiply(int3, int3)
Multiplies two instances (component-wise).
Declaration
public static int3 operator *(int3 vec1, int3 vec2)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec1 | The first instance. |
int3 | vec2 | The second instance. |
Returns
Type | Description |
---|---|
int3 | The result of the multiplication. |
Multiply(int3, Int32)
Multiplies an instance by a scalar.
Declaration
public static int3 operator *(int3 vec, int scale)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec | The instance. |
System.Int32 | scale | The scalar. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
Multiply(Int32, int3)
Multiplies an instance by a scalar.
Declaration
public static int3 operator *(int scale, int3 vec)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | scale | The scalar. |
int3 | vec | The instance. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
Subtraction(int3, int3)
Subtracts two instances.
Declaration
public static int3 operator -(int3 left, int3 right)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | The first instance. |
int3 | right | The second instance. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
Subtraction(int3, Int32)
Adds a scalar from a instance.
Declaration
public static int3 operator -(int3 left, int scalar)
Parameters
Type | Name | Description |
---|---|---|
int3 | left | The first instance. |
System.Int32 | scalar | The scalar. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |
UnaryNegation(int3)
Negates an instance.
Declaration
public static int3 operator -(int3 vec)
Parameters
Type | Name | Description |
---|---|---|
int3 | vec | The instance. |
Returns
Type | Description |
---|---|
int3 | The result of the calculation. |