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