Struct int4
Represents a 4D vector using four integers.
Implements
Inherited Members
Namespace: Fusee.Math.Core
Assembly: Fusee.Math.Core.dll
Syntax
public struct int4 : IEquatable<int4>Remarks
The int4 structure is suitable for interoperation with unmanaged code requiring four consecutive ints.
Constructors
int4(double4)
Constructs a new int4 by converting from a double4.
Declaration
public int4(double4 d4)Parameters
| Type | Name | Description | 
|---|---|---|
| double4 | d4 | The double4 to copy components from. | 
int4(int2)
Constructs a new int4 from the given int2.
Declaration
public int4(int2 v)Parameters
| Type | Name | Description | 
|---|---|---|
| int2 | v | The int2 to copy components from. | 
int4(int3)
Constructs a new int4 from the given int3.
Declaration
public int4(int3 v)Parameters
| Type | Name | Description | 
|---|---|---|
| int3 | v | The int3 to copy components from. | 
int4(int3, Int32)
Constructs a new int4 from the specified int3 and ww component.
Declaration
public int4(int3 v, int ww)Parameters
| Type | Name | Description | 
|---|---|---|
| int3 | v | The int3 to copy components from. | 
| System.Int32 | ww | The ww component of the new int4. | 
int4(int4)
Constructs a new int4 from the given int4.
Declaration
public int4(int4 v)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | v | The int4 to copy components from. | 
int4(Int32)
Constructs a new int4.
Declaration
public int4(int val)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | val | This value will be set for the x, y, z and w component. | 
int4(Int32, Int32, Int32, Int32)
Constructs a new int4.
Declaration
public int4(int x, int y, int z, int w)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | x | The x component of the int4. | 
| System.Int32 | y | The y component of the int4. | 
| System.Int32 | z | The z component of the int4. | 
| System.Int32 | w | The w component of the int4. | 
Fields
One
Defines an instance with all components set to 1.
Declaration
public static readonly int4 OneField Value
| Type | Description | 
|---|---|
| int4 | 
UnitW
Defines a unit-length int4 that points towards the w-axis.
Declaration
public static readonly int4 UnitWField Value
| Type | Description | 
|---|---|
| int4 | 
UnitX
Defines a unit-length int4 that points towards the x-axis.
Declaration
public static readonly int4 UnitXField Value
| Type | Description | 
|---|---|
| int4 | 
UnitY
Defines a unit-length int4 that points towards the y-axis.
Declaration
public static readonly int4 UnitYField Value
| Type | Description | 
|---|---|
| int4 | 
UnitZ
Defines a unit-length int4 that points towards the z-axis.
Declaration
public static readonly int4 UnitZField Value
| Type | Description | 
|---|---|
| int4 | 
w
The w component of the int4.
Declaration
public int wField Value
| Type | Description | 
|---|---|
| System.Int32 | 
x
The x component of the int4.
Declaration
public int xField Value
| Type | Description | 
|---|---|
| System.Int32 | 
y
The y component of the int4.
Declaration
public int yField Value
| Type | Description | 
|---|---|
| System.Int32 | 
z
The z component of the int4.
Declaration
public int zField Value
| Type | Description | 
|---|---|
| System.Int32 | 
Zero
Defines a zero-length int4.
Declaration
public static readonly int4 ZeroField Value
| Type | Description | 
|---|---|
| int4 | 
Properties
a
The alpha component (same as w)
Declaration
public int a { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
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, z, or w, depending on their index.
Declaration
public int this[int idx] { get; set; }Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | idx | The index (between 0 and 3). | 
Property Value
| Type | Description | 
|---|---|
| System.Int32 | The x or y component of the int4. | 
Length
Gets the length (magnitude) of the vector.
Declaration
public readonly float Length { get; }Property Value
| Type | Description | 
|---|---|
| System.Single | 
Length1
Gets the length in 1-norm.
Declaration
public readonly int Length1 { get; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
LengthSquared
Gets the square of the vector length (magnitude).
Declaration
public readonly int LengthSquared { get; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
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 int4.
Declaration
public static Converter<string, int4> ParseConverter { get; set; }Property Value
| Type | Description | 
|---|---|
| Converter<System.String, int4> | The parse property. | 
r
The red component (same as x)
Declaration
public int r { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
rg
The rg component (same as xy)
Declaration
public int2 rg { get; set; }Property Value
| Type | Description | 
|---|---|
| int2 | 
rgb
The rgb component (same as xyz)
Declaration
public int3 rgb { get; set; }Property Value
| Type | Description | 
|---|---|
| int3 | 
xy
Gets and 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 and 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 | 
Methods
Add(int4, int4)
Adds two vectors.
Declaration
public static int4 Add(int4 a, int4 b)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | a | Left operand. | 
| int4 | b | Right operand. | 
Returns
| Type | Description | 
|---|---|
| int4 | Result of operation. | 
Clamp(int4, int4, int4)
Clamp a vector to the given minimum and maximum vectors
Declaration
public static int4 Clamp(int4 vec, int4 min, int4 max)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vec | Input vector | 
| int4 | min | Minimum vector | 
| int4 | max | Maximum vector | 
Returns
| Type | Description | 
|---|---|
| int4 | The clamped vector | 
Divide(int4, int4)
Divides a vector by the components of a vector (scale).
Declaration
public static int4 Divide(int4 vector, int4 scale)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vector | Left operand. | 
| int4 | scale | Right operand. | 
Returns
| Type | Description | 
|---|---|
| int4 | Result of the operation. | 
Divide(int4, Int32)
Divides a vector by a scalar.
Declaration
public static int4 Divide(int4 vector, int scale)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vector | Left operand. | 
| System.Int32 | scale | Right operand. | 
Returns
| Type | Description | 
|---|---|
| int4 | Result of the operation. | 
Dot(int4, int4)
Calculate the dot product of two vectors
Declaration
public static int Dot(int4 left, int4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | left | First operand | 
| int4 | right | Second operand | 
Returns
| Type | Description | 
|---|---|
| System.Int32 | The dot product of the two inputs | 
Equals(int4)
Indicates whether the current vector is equal to another vector.
Declaration
public bool Equals(int4 other)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | 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(int4, int4, float4)
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 float4 Lerp(int4 a, int4 b, float4 blend)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | a | First input vector | 
| int4 | b | Second input vector | 
| float4 | blend | The blend factor. a when blend=0, b when blend=1. | 
Returns
| Type | Description | 
|---|---|
| float4 | 
Lerp(int4, int4, Single)
Returns a new Vector that is the linear blend of the 2 given Vectors
Declaration
public static float4 Lerp(int4 a, int4 b, float blend)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | a | First input vector | 
| int4 | b | Second input vector | 
| System.Single | blend | The blend factor. a when blend=0, b when blend=1. | 
Returns
| Type | Description | 
|---|---|
| float4 | a when blend=0, b when blend=1, and a linear combination otherwise | 
LinearColorFromSRgb()
Converts this int4 - which is interpreted as a color - from sRgb space to linear color space.
Declaration
public int4 LinearColorFromSRgb()Returns
| Type | Description | 
|---|---|
| int4 | 
LinearColorFromSRgb(int4)
Converts a color value from sRgb to linear space.
Declaration
public static int4 LinearColorFromSRgb(int4 sRGBCol)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | sRGBCol | The sRgb color value as int4. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
LinearColorFromSRgb(Int32, Int32, Int32, Int32)
Converts a color value from sRgb to linear space.
Declaration
public static int4 LinearColorFromSRgb(int r, int g, int b, int a)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. | 
| System.Int32 | a | The alpha value in range 0 - 255. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
LinearColorFromSRgb(String)
Converts a color value from sRgb to linear space.
Declaration
public static int4 LinearColorFromSRgb(string hex)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | hex | The color value as hex code in form of a "FFFFFFFF" string. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
LinearColorFromSRgb(UInt32)
Converts a color value from sRgb to linear space.
Declaration
public static int4 LinearColorFromSRgb(uint col)Parameters
| Type | Name | Description | 
|---|---|---|
| System.UInt32 | col | The color value as uint. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
Max(int4, int4)
Calculate the component-wise maximum of two vectors
Declaration
public static int4 Max(int4 a, int4 b)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | a | First operand | 
| int4 | b | Second operand | 
Returns
| Type | Description | 
|---|---|
| int4 | The component-wise maximum | 
Min(int4, int4)
Calculate the component-wise minimum of two vectors
Declaration
public static int4 Min(int4 a, int4 b)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | a | First operand | 
| int4 | b | Second operand | 
Returns
| Type | Description | 
|---|---|
| int4 | The component-wise minimum | 
Multiply(int4, int4)
Multiplies a vector by the components a vector (scale).
Declaration
public static int4 Multiply(int4 vector, int4 scale)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vector | Left operand. | 
| int4 | scale | Right operand. | 
Returns
| Type | Description | 
|---|---|
| int4 | Result of the operation. | 
Multiply(int4, Int32)
Multiplies a vector by a scalar.
Declaration
public static int4 Multiply(int4 vector, int scale)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vector | Left operand. | 
| System.Int32 | scale | Right operand. | 
Returns
| Type | Description | 
|---|---|
| int4 | Result of the operation. | 
Normalize()
Scales the int4 to unit length.
Declaration
public float4 Normalize()Returns
| Type | Description | 
|---|---|
| float4 | 
Normalize(int4)
Scale a vector to unit length
Declaration
public static float4 Normalize(int4 vec)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vec | The input vector | 
Returns
| Type | Description | 
|---|---|
| float4 | The normalized vector | 
Normalize1()
Scales the int4 to unit length in 1-norm.
Declaration
public float4 Normalize1()Returns
| Type | Description | 
|---|---|
| float4 | 
Normalize1(int4)
Scales the vector to unit length in 1-norm.
Declaration
public static float4 Normalize1(int4 vec)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vec | The input vector. | 
Returns
| Type | Description | 
|---|---|
| float4 | The scaled vector. | 
NormalizeFast()
Scales the int4 to approximately unit length.
Declaration
public float4 NormalizeFast()Returns
| Type | Description | 
|---|---|
| float4 | 
NormalizeFast(int4)
Scale a vector to approximately unit length
Declaration
public static float4 NormalizeFast(int4 vec)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vec | The input vector | 
Returns
| Type | Description | 
|---|---|
| float4 | The normalized vector | 
Parse(String, IFormatProvider)
Parses a string into a int4.
Declaration
public static int4 Parse(string source, IFormatProvider provider = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | source | |
| System.IFormatProvider | provider | 
Returns
| Type | Description | 
|---|---|
| int4 | 
Pow(int4, Int32)
Returns a int4 where all components are raised to the specified power.
Declaration
public static int4 Pow(int4 val, int exp)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | val | The int4 to be raised to a power. | 
| System.Int32 | exp | A int that specifies a power. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
SRgbFromLinearColor()
Converts this int4 - which is interpreted as a color - from linear color space to sRgb space.
Declaration
public int4 SRgbFromLinearColor()Returns
| Type | Description | 
|---|---|
| int4 | 
SRgbFromLinearColor(int4)
Converts a color value from linear to sRgb space.
Declaration
public static int4 SRgbFromLinearColor(int4 sRGBCol)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | sRGBCol | The linear color value as int4. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
SRgbFromLinearColor(Int32, Int32, Int32, Int32)
Converts a color value from linear to sRgb space.
Declaration
public static int4 SRgbFromLinearColor(int r, int g, int b, int a)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. | 
| System.Int32 | a | The alpha value in range 0 - 255. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
SRgbFromLinearColor(String)
Converts a color value from linear to sRgb space.
Declaration
public static int4 SRgbFromLinearColor(string hex)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | hex | The color value as hex code in form of a "FFFFFFFF" string. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
SRgbFromLinearColor(UInt32)
Converts a color value from linear to sRgb space.
Declaration
public static int4 SRgbFromLinearColor(uint col)Parameters
| Type | Name | Description | 
|---|---|---|
| System.UInt32 | col | The color value as uint. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
Step(int4, int4)
Performs Step(Single, Single) for each component of the input vectors.
Declaration
public static int4 Step(int4 edge, int4 val)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | edge | Specifies the location of the edge of the step function. | 
| int4 | val | Specifies the value to be used to generate the step function. | 
Returns
| Type | Description | 
|---|---|
| int4 | 
Subtract(int4, int4)
Subtract one Vector from another
Declaration
public static int4 Subtract(int4 a, int4 b)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | a | First operand | 
| int4 | b | Second operand | 
Returns
| Type | Description | 
|---|---|
| int4 | Result of subtraction | 
ToArray()
XML-Comment
Declaration
public int[] ToArray()Returns
| Type | Description | 
|---|---|
| System.Int32[] | An int array of size 4 that cobtains the x,y,z,w components. | 
ToString()
Returns a System.String that represents the current int4.
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 int4.
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(int4, int4)
Adds two instances.
Declaration
public static int4 operator +(int4 left, int4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | left | The first instance. | 
| int4 | right | The second instance. | 
Returns
| Type | Description | 
|---|---|
| int4 | The result of the calculation. | 
Division(int4, Int32)
Divides an instance by a scalar.
Declaration
public static int4 operator /(int4 vec, int scale)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vec | The instance. | 
| System.Int32 | scale | The scalar. | 
Returns
| Type | Description | 
|---|---|
| int4 | The result of the calculation. | 
Equality(int4, int4)
Compares two instances for equality.
Declaration
public static bool operator ==(int4 left, int4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | left | The first instance. | 
| int4 | right | The second instance. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | True, if left equals right; false otherwise. | 
Explicit(double4 to int4)
Explicit cast operator to cast a double4 into a int4 value.
Declaration
public static explicit operator int4(double4 d4)Parameters
| Type | Name | Description | 
|---|---|---|
| double4 | d4 | The double4 value to cast. | 
Returns
| Type | Description | 
|---|---|
| int4 | A int4 value. | 
Inequality(int4, int4)
Compares two instances for inequality.
Declaration
public static bool operator !=(int4 left, int4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | left | The first instance. | 
| int4 | right | The second instance. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | True, if left does not equal right; false otherwise. | 
Multiply(int4, int4)
Multiplies two instances (component-wise).
Declaration
public static int4 operator *(int4 left, int4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | left | The first instance. | 
| int4 | right | The second instance. | 
Returns
| Type | Description | 
|---|---|
| int4 | The result of the calculation. | 
Multiply(int4, Int32)
Multiplies an instance by a scalar.
Declaration
public static int4 operator *(int4 vec, int scale)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vec | The instance. | 
| System.Int32 | scale | The scalar. | 
Returns
| Type | Description | 
|---|---|
| int4 | The result of the calculation. | 
Multiply(Int32, int4)
Multiplies an instance by a scalar.
Declaration
public static int4 operator *(int scale, int4 vec)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | scale | The scalar. | 
| int4 | vec | The instance. | 
Returns
| Type | Description | 
|---|---|
| int4 | The result of the calculation. | 
Subtraction(int4, int4)
Subtracts two instances.
Declaration
public static int4 operator -(int4 left, int4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | left | The first instance. | 
| int4 | right | The second instance. | 
Returns
| Type | Description | 
|---|---|
| int4 | The result of the calculation. | 
UnaryNegation(int4)
Negates an instance.
Declaration
public static int4 operator -(int4 vec)Parameters
| Type | Name | Description | 
|---|---|---|
| int4 | vec | The instance. | 
Returns
| Type | Description | 
|---|---|
| int4 | The result of the calculation. |