Show / Hide Table of Contents

Struct double3

Represents a 3D vector using three double-precision numbers.

Implements
System.IEquatable<double3>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Fusee.Math.Core
Assembly: Fusee.Math.Core.dll
Syntax
public struct double3 : IEquatable<double3>
Remarks

The double3 structure is suitable for inter-operation with unmanaged code requiring three consecutive doubles.

Constructors

double3(double2)

Constructs a new double3 from the given double2.

Declaration
public double3(double2 v)
Parameters
Type Name Description
double2 v

The double2 to copy components from.

double3(double3)

Constructs a new double3 from the given double3.

Declaration
public double3(double3 v)
Parameters
Type Name Description
double3 v

The double3 to copy components from.

double3(double4)

Constructs a new double3 from the given double4.

Declaration
public double3(double4 v)
Parameters
Type Name Description
double4 v

The double4 to copy components from.

double3(float3)

Constructs a new double3 by converting from a double3.

Declaration
public double3(float3 d3)
Parameters
Type Name Description
float3 d3

The double3 to copy components from.

double3(Double)

Constructs a new double3.

Declaration
public double3(double val)
Parameters
Type Name Description
System.Double val

This value will be set for the x, y and z component.

double3(Double, Double, Double)

Constructs a new double3.

Declaration
public double3(double x, double y, double z)
Parameters
Type Name Description
System.Double x

The x component of the double3.

System.Double y

The y component of the double3.

System.Double z

The z component of the double3.

Fields

One

Defines an instance with all components set to 1.

Declaration
public static readonly double3 One
Field Value
Type Description
double3

UnitX

Defines a unit-length double3 that points towards the x-axis.

Declaration
public static readonly double3 UnitX
Field Value
Type Description
double3

UnitY

Defines a unit-length double3 that points towards the y-axis.

Declaration
public static readonly double3 UnitY
Field Value
Type Description
double3

UnitZ

Defines a unit-length double3 that points towards the z-axis.

Declaration
public static readonly double3 UnitZ
Field Value
Type Description
double3

x

The x component of the double3.

Declaration
public double x
Field Value
Type Description
System.Double

y

The y component of the double3.

Declaration
public double y
Field Value
Type Description
System.Double

z

The z component of the double3.

Declaration
public double z
Field Value
Type Description
System.Double

Zero

Defines a zero-length double3.

Declaration
public static readonly double3 Zero
Field Value
Type Description
double3

Properties

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

IsInfinity

Returns a bool which determines whether this double3 contains a infinity value

Declaration
public readonly bool IsInfinity { get; }
Property Value
Type Description
System.Boolean

IsNaN

Returns a bool which determines whether this double3 isNaN

Declaration
public readonly bool IsNaN { get; }
Property Value
Type Description
System.Boolean

Item[Int32]

Gets or sets the individual components x, y, or z, depending on their index.

Declaration
public double this[int idx] { get; set; }
Parameters
Type Name Description
System.Int32 idx

The index (between 0 and 2).

Property Value
Type Description
System.Double

The x or y component of the double3.

Length

Gets the length (magnitude) of the vector.

Declaration
public readonly double Length { get; }
Property Value
Type Description
System.Double

The length.

LengthSquared

Gets the square of the vector length (magnitude).

Declaration
public readonly double LengthSquared { get; }
Property Value
Type Description
System.Double

The length squared.

Remarks

This property avoids the costly square root operation required by the Length property. This makes it more suitable for comparisons.

NegativeInfinity

Returns a double3 which contains negative infinity values

Declaration
public static readonly double3 NegativeInfinity { get; }
Property Value
Type Description
double3

ParseConverter

Gets and sets the Converter object. Has the ability to convert a string to a double3.

Declaration
public static Converter<string, double3> ParseConverter { get; set; }
Property Value
Type Description
Converter<System.String, double3>

The parse property.

PositiveInfinity

Returns a double3 which contains positive infinity values

Declaration
public static readonly double3 PositiveInfinity { get; }
Property Value
Type Description
double3

r

The red component (same as x)

Declaration
public double r { get; set; }
Property Value
Type Description
System.Double

xy

Gets or 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 or 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

xz

Gets or sets an OpenTK.double2 with the x and z components of this instance.

Declaration
public double2 xz { get; set; }
Property Value
Type Description
double2

xzy

Gets or sets an OpenTK.double3 with the x, z and y components of this instance.

Declaration
public double3 xzy { get; set; }
Property Value
Type Description
double3

yx

Gets or sets an OpenTK.double2 with the y and x components of this instance.

Declaration
public double2 yx { get; set; }
Property Value
Type Description
double2

yxz

Gets or sets an OpenTK.double3 with the y, x and z components of this instance.

Declaration
public double3 yxz { get; set; }
Property Value
Type Description
double3

yz

Gets or sets an OpenTK.double2 with the y and z components of this instance.

Declaration
public double2 yz { get; set; }
Property Value
Type Description
double2

yzx

Gets or sets an OpenTK.double3 with the y, z and x components of this instance.

Declaration
public double3 yzx { get; set; }
Property Value
Type Description
double3

zx

Gets or sets an OpenTK.double2 with the z and x components of this instance.

Declaration
public double2 zx { get; set; }
Property Value
Type Description
double2

zxy

Gets or sets an OpenTK.double3 with the z, x and y components of this instance.

Declaration
public double3 zxy { get; set; }
Property Value
Type Description
double3

zy

Gets or sets an OpenTK.double2 with the z and y components of this instance.

Declaration
public double2 zy { get; set; }
Property Value
Type Description
double2

zyx

Gets or sets an OpenTK.double3 with the z, y and x components of this instance.

Declaration
public double3 zyx { get; set; }
Property Value
Type Description
double3

Methods

Add(double3, double3)

Adds two vectors.

Declaration
public static double3 Add(double3 a, double3 b)
Parameters
Type Name Description
double3 a

Left operand.

double3 b

Right operand.

Returns
Type Description
double3

Result of operation.

Add(double3, Double)

Adds a scalar to a instance.

Declaration
public static double3 Add(double3 vec, double scale)
Parameters
Type Name Description
double3 vec

The first instance.

System.Double scale

The scalar.

Returns
Type Description
double3

The result of the calculation.

Barycentric(double3, double3, double3, Double, Double)

Interpolate 3 Vectors using Barycentric coordinates

Declaration
public static double3 Barycentric(double3 a, double3 b, double3 c, double u, double v)
Parameters
Type Name Description
double3 a

First input Vector

double3 b

Second input Vector

double3 c

Third input Vector

System.Double u

First Barycentric Coordinate

System.Double v

Second Barycentric Coordinate

Returns
Type Description
double3

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

CalculateAngle(double3, double3)

Calculates the angle (in radians) between two vectors.

Declaration
public static double CalculateAngle(double3 first, double3 second)
Parameters
Type Name Description
double3 first

The first vector.

double3 second

The second vector.

Returns
Type Description
System.Double

Angle (in radians) between the vectors.

Remarks

Note that the returned angle is never bigger than the constant Pi.

Clamp(double3, double3, double3)

Clamp a vector to the given minimum and maximum vectors

Declaration
public static double3 Clamp(double3 vec, double3 min, double3 max)
Parameters
Type Name Description
double3 vec

Input vector

double3 min

Minimum vector

double3 max

Maximum vector

Returns
Type Description
double3

The clamped vector

ComponentMax(double3, double3)

Calculate the component-wise maximum of two vectors

Declaration
public static double3 ComponentMax(double3 a, double3 b)
Parameters
Type Name Description
double3 a

First operand

double3 b

Second operand

Returns
Type Description
double3

The component-wise maximum

ComponentMin(double3, double3)

Calculate the component-wise minimum of two vectors

Declaration
public static double3 ComponentMin(double3 a, double3 b)
Parameters
Type Name Description
double3 a

First operand

double3 b

Second operand

Returns
Type Description
double3

The component-wise minimum

Cross(double3, double3)

Calculate the cross (vector) product of two vectors

Declaration
public static double3 Cross(double3 left, double3 right)
Parameters
Type Name Description
double3 left

First operand

double3 right

Second operand

Returns
Type Description
double3

The cross product of the two inputs

Divide(double3, double3)

Divides a vector by the components of a vector (scale).

Declaration
public static double3 Divide(double3 vector, double3 scale)
Parameters
Type Name Description
double3 vector

Left operand.

double3 scale

Right operand.

Returns
Type Description
double3

Result of the operation.

Divide(double3, Double)

Divides a vector by a scalar.

Declaration
public static double3 Divide(double3 vector, double scale)
Parameters
Type Name Description
double3 vector

Left operand.

System.Double scale

Right operand.

Returns
Type Description
double3

Result of the operation.

Dot(double3, double3)

Calculate the dot (scalar) product of two vectors

Declaration
public static double Dot(double3 left, double3 right)
Parameters
Type Name Description
double3 left

First operand

double3 right

Second operand

Returns
Type Description
System.Double

The dot product of the two inputs

Equals(double3)

Indicates whether the current vector is equal to another vector.

Declaration
public bool Equals(double3 other)
Parameters
Type Name Description
double3 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
System.ValueType.Equals(System.Object)

GetBarycentric(double3, double3, double3, double3, out Double, out Double)

Calculates the barycentric coordinates for the given point in the given triangle, such that ua + vb + (1-u-v)*c = point.

Declaration
public static void GetBarycentric(double3 a, double3 b, double3 c, double3 point, out double u, out double v)
Parameters
Type Name Description
double3 a

The first point of the triangle.

double3 b

The second point of the triangle.

double3 c

The third point of the triangle.

double3 point

The point to calculate the barycentric coordinates for.

System.Double u

The resulting u coordinate.

System.Double v

The resulting v coordinate.

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
System.ValueType.GetHashCode()

Lerp(double3, double3, double3)

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 double3 Lerp(double3 a, double3 b, double3 blend)
Parameters
Type Name Description
double3 a

First input vector

double3 b

Second input vector

double3 blend

The blend factor. a when blend=0, b when blend=1.

Returns
Type Description
double3

Lerp(double3, double3, Double)

Returns a new Vector that is the linear blend of the 2 given Vectors

Declaration
public static double3 Lerp(double3 a, double3 b, double blend)
Parameters
Type Name Description
double3 a

First input vector

double3 b

Second input vector

System.Double blend

The blend factor. a when blend=0, b when blend=1.

Returns
Type Description
double3

a when blend=0, b when blend=1, and a linear combination otherwise

LinearColorFromSRgb()

Converts this double3 - which is interpreted as a color - from linear color space to sRgb space.

Declaration
public double3 LinearColorFromSRgb()
Returns
Type Description
double3

LinearColorFromSRgb(double3)

Converts a color value from sRgb to linear space.

Declaration
public static double3 LinearColorFromSRgb(double3 sRGBCol)
Parameters
Type Name Description
double3 sRGBCol

The sRgb color value as double3.

Returns
Type Description
double3

LinearColorFromSRgb(Int32, Int32, Int32)

Converts a color value from sRgb to linear space.

Declaration
public static double3 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
double3

LinearColorFromSRgb(String)

Converts a color value from sRgb to linear space.

Declaration
public static double3 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
double3

LinearColorFromSRgb(UInt32)

Converts a color value from sRgb to linear space.

Declaration
public static double3 LinearColorFromSRgb(uint col)
Parameters
Type Name Description
System.UInt32 col

The color value as uint.

Returns
Type Description
double3

Max(double3, double3)

Returns the double3 with the maximum magnitude

Declaration
public static double3 Max(double3 left, double3 right)
Parameters
Type Name Description
double3 left

Left operand

double3 right

Right operand

Returns
Type Description
double3

The maximum double3

Min(double3, double3)

Returns the double3 with the minimum magnitude

Declaration
public static double3 Min(double3 left, double3 right)
Parameters
Type Name Description
double3 left

Left operand

double3 right

Right operand

Returns
Type Description
double3

The minimum double3

Multiply(double3, double3)

Multiplies a vector by the components a vector (scale).

Declaration
public static double3 Multiply(double3 vector, double3 scale)
Parameters
Type Name Description
double3 vector

Left operand.

double3 scale

Right operand.

Returns
Type Description
double3

Result of the operation.

Multiply(double3, Double)

Multiplies a vector by a scalar.

Declaration
public static double3 Multiply(double3 vector, double scale)
Parameters
Type Name Description
double3 vector

Left operand.

System.Double scale

Right operand.

Returns
Type Description
double3

Result of the operation.

Normalize()

Scales the double3 to unit length.

Declaration
public double3 Normalize()
Returns
Type Description
double3

Normalize(double3)

Scale a vector to unit length

Declaration
public static double3 Normalize(double3 vec)
Parameters
Type Name Description
double3 vec

The input vector

Returns
Type Description
double3

The normalized vector

NormalizeFast()

Scales the double3 to approximately unit length.

Declaration
public double3 NormalizeFast()
Returns
Type Description
double3

NormalizeFast(double3)

Scale a vector to approximately unit length

Declaration
public static double3 NormalizeFast(double3 vec)
Parameters
Type Name Description
double3 vec

The input vector

Returns
Type Description
double3

The normalized vector

OrthoNormalize(double3, double3)

Orthoes the normalize.

Declaration
public static double3[] OrthoNormalize(double3 normal, double3 tangent)
Parameters
Type Name Description
double3 normal

The normal.

double3 tangent

The tangent.

Returns
Type Description
double3[]

An double3 Array of size 2 with orthonormalized normal and tangent.

Parse(String, IFormatProvider)

Parses a string into a double3.

Declaration
public static double3 Parse(string source, IFormatProvider provider = null)
Parameters
Type Name Description
System.String source
System.IFormatProvider provider
Returns
Type Description
double3

PointInTriangle(double3, double3, double3, double3, out Double, out Double)

Checks if the given point is inside the given triangle (a, b, c). Returns the barycentric coordinates using GetBarycentric(double3, double3, double3, double3, out Double, out Double).

Declaration
public static bool PointInTriangle(double3 a, double3 b, double3 c, double3 point, out double u, out double v)
Parameters
Type Name Description
double3 a

The first point of the triangle.

double3 b

The second point of the triangle.

double3 c

The third point of the triangle.

double3 point

the point to test.

System.Double u

The resulting barycentric u coordinate (weight for vertex a).

System.Double v

The resulting barycentric v coordinate (weight for vertex b).

Returns
Type Description
System.Boolean

True if the point is inside the triangle a, b, c. Otherwise returns false.

Pow(double3, Double)

Returns a double3 where all components are raised to the specified power.

Declaration
public static double3 Pow(double3 val, double exp)
Parameters
Type Name Description
double3 val

The double3 to be raised to a power.

System.Double exp

A double that specifies a power.

Returns
Type Description
double3

Rotate(double3, double3, 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 double3 Rotate(double3 euler, double3 vec, bool inDegrees = false)
Parameters
Type Name Description
double3 euler

The angles used for the rotation.

double3 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
double3

The rotated vector.

Rotate(QuaternionD, double3)

Rotates a vector by the given quaternion.

Declaration
public static double3 Rotate(QuaternionD quat, double3 vec)
Parameters
Type Name Description
QuaternionD quat

The quaternion used for the rotation.

double3 vec

The vector to rotate.

Returns
Type Description
double3

The rotated vector.

SRgbFromLinearColor()

Converts this double3 - which is interpreted as a color - from sRgb space to linear color space.

Declaration
public double3 SRgbFromLinearColor()
Returns
Type Description
double3

SRgbFromLinearColor(double3)

Converts a color value from linear to sRgb space.

Declaration
public static double3 SRgbFromLinearColor(double3 linearColor)
Parameters
Type Name Description
double3 linearColor

The linear color value as double3.

Returns
Type Description
double3

SRgbFromLinearColor(Int32, Int32, Int32)

Converts a color value from linear to sRgb space.

Declaration
public static double3 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
double3

SRgbFromLinearColor(String)

Converts a color value from linear to sRgb space.

Declaration
public static double3 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
double3

SRgbFromLinearColor(UInt32)

Converts a color value from linear to sRgb space.

Declaration
public static double3 SRgbFromLinearColor(uint col)
Parameters
Type Name Description
System.UInt32 col

The color value as uint.

Returns
Type Description
double3

Step(double3, double3)

Performs Step(Double, Double) for each component of the input vectors.

Declaration
public static double3 Step(double3 edge, double3 val)
Parameters
Type Name Description
double3 edge

Specifies the location of the edge of the step function.

double3 val

Specifies the value to be used to generate the step function.

Returns
Type Description
double3

Subtract(double3, double3)

Subtract one Vector from another

Declaration
public static double3 Subtract(double3 a, double3 b)
Parameters
Type Name Description
double3 a

First operand

double3 b

Second operand

Returns
Type Description
double3

Result of subtraction

Subtract(double3, Double)

Adds a scalar from a instance.

Declaration
public static double3 Subtract(double3 vec, double scale)
Parameters
Type Name Description
double3 vec

The first instance.

System.Double scale

The scalar.

Returns
Type Description
double3

The result of the calculation.

ToArray()

Returns an array of doubles with the three components of the vector.

Declaration
public double[] ToArray()
Returns
Type Description
System.Double[]

Returns an array of doubles with the three components of the vector.

ToString()

Returns a System.String that represents the current double3.

Declaration
public override string ToString()
Returns
Type Description
System.String

A System.String that represents this instance.

Overrides
System.ValueType.ToString()

ToString(IFormatProvider)

Returns a System.String that represents the current double3.

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

Adds two instances.

Declaration
public static double3 operator +(double3 left, double3 right)
Parameters
Type Name Description
double3 left

The first instance.

double3 right

The second instance.

Returns
Type Description
double3

The result of the calculation.

Addition(double3, Double)

Adds a scalar to a instance.

Declaration
public static double3 operator +(double3 left, double scalar)
Parameters
Type Name Description
double3 left

The first instance.

System.Double scalar

The scalar.

Returns
Type Description
double3

The result of the calculation.

Division(double3, Double)

Divides an instance by a scalar.

Declaration
public static double3 operator /(double3 vec, double scale)
Parameters
Type Name Description
double3 vec

The instance.

System.Double scale

The scalar.

Returns
Type Description
double3

The result of the calculation.

Equality(double3, double3)

Compares two instances for equality.

Declaration
public static bool operator ==(double3 left, double3 right)
Parameters
Type Name Description
double3 left

The first instance.

double3 right

The second instance.

Returns
Type Description
System.Boolean

True, if left equals right; false otherwise.

Explicit(float3 to double3)

Explicit cast operator to cast a double3 into a double3 value.

Declaration
public static explicit operator double3(float3 d3)
Parameters
Type Name Description
float3 d3

The double3 value to cast.

Returns
Type Description
double3

A double3 value.

Inequality(double3, double3)

Compares two instances for inequality.

Declaration
public static bool operator !=(double3 left, double3 right)
Parameters
Type Name Description
double3 left

The first instance.

double3 right

The second instance.

Returns
Type Description
System.Boolean

True, if left does not equal right; false otherwise.

Multiply(double3, double3)

Multiplies two instances (component-wise).

Declaration
public static double3 operator *(double3 vec1, double3 vec2)
Parameters
Type Name Description
double3 vec1

The first instance.

double3 vec2

The second instance.

Returns
Type Description
double3

The result of the multiplication.

Multiply(double3, Double)

Multiplies an instance by a scalar.

Declaration
public static double3 operator *(double3 vec, double scale)
Parameters
Type Name Description
double3 vec

The instance.

System.Double scale

The scalar.

Returns
Type Description
double3

The result of the calculation.

Multiply(Double, double3)

Multiplies an instance by a scalar.

Declaration
public static double3 operator *(double scale, double3 vec)
Parameters
Type Name Description
System.Double scale

The scalar.

double3 vec

The instance.

Returns
Type Description
double3

The result of the calculation.

Subtraction(double3, double3)

Subtracts two instances.

Declaration
public static double3 operator -(double3 left, double3 right)
Parameters
Type Name Description
double3 left

The first instance.

double3 right

The second instance.

Returns
Type Description
double3

The result of the calculation.

Subtraction(double3, Double)

Adds a scalar from a instance.

Declaration
public static double3 operator -(double3 left, double scalar)
Parameters
Type Name Description
double3 left

The first instance.

System.Double scalar

The scalar.

Returns
Type Description
double3

The result of the calculation.

UnaryNegation(double3)

Negates an instance.

Declaration
public static double3 operator -(double3 vec)
Parameters
Type Name Description
double3 vec

The instance.

Returns
Type Description
double3

The result of the calculation.

Implements

System.IEquatable<T>
Generated by DocFX
GitHub Repo
Back to top