Show / Hide Table of Contents

Struct float3

Represents a 3D vector using three single-precision floating-point numbers.

Implements
System.IEquatable<float3>
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 float3 : IEquatable<float3>
Remarks

The float3 structure is suitable for inter-operation with unmanaged code requiring three consecutive floats.

Constructors

float3(double3)

Constructs a new float3 by converting from a double3.

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

The double3 to copy components from.

float3(float2)

Constructs a new float3 from the given float2.

Declaration
public float3(float2 v)
Parameters
Type Name Description
float2 v

The float2 to copy components from.

float3(float3)

Constructs a new float3 from the given float3.

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

The float3 to copy components from.

float3(float4)

Constructs a new float3 from the given float4.

Declaration
public float3(float4 v)
Parameters
Type Name Description
float4 v

The float4 to copy components from.

float3(Single)

Constructs a new float3.

Declaration
public float3(float val)
Parameters
Type Name Description
System.Single val

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

float3(Single, Single, Single)

Constructs a new float3.

Declaration
public float3(float x, float y, float z)
Parameters
Type Name Description
System.Single x

The x component of the float3.

System.Single y

The y component of the float3.

System.Single z

The z component of the float3.

Fields

One

Defines an instance with all components set to 1.

Declaration
public static readonly float3 One
Field Value
Type Description
float3

UnitX

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

Declaration
public static readonly float3 UnitX
Field Value
Type Description
float3

UnitY

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

Declaration
public static readonly float3 UnitY
Field Value
Type Description
float3

UnitZ

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

Declaration
public static readonly float3 UnitZ
Field Value
Type Description
float3

x

The x component of the float3.

Declaration
public float x
Field Value
Type Description
System.Single

y

The y component of the float3.

Declaration
public float y
Field Value
Type Description
System.Single

z

The z component of the float3.

Declaration
public float z
Field Value
Type Description
System.Single

Zero

Defines a zero-length float3.

Declaration
public static readonly float3 Zero
Field Value
Type Description
float3

Properties

b

The blue component (same as z)

Declaration
public float b { get; set; }
Property Value
Type Description
System.Single

g

The green component (same as y)

Declaration
public float g { get; set; }
Property Value
Type Description
System.Single

IsInfinity

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

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

IsNaN

Returns a bool which determines whether this float3 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 float this[int idx] { get; set; }
Parameters
Type Name Description
System.Int32 idx

The index (between 0 and 2).

Property Value
Type Description
System.Single

The x or y component of the float3.

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 float LengthSquared { get; }
Property Value
Type Description
System.Single

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 float3 which contains negative infinity values

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

ParseConverter

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

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

The parse property.

PositiveInfinity

Returns a float3 which contains positive infinity values

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

r

The red component (same as x)

Declaration
public float r { get; set; }
Property Value
Type Description
System.Single

xy

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

Declaration
public float2 xy { get; set; }
Property Value
Type Description
float2

xyz

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

Declaration
public float3 xyz { get; set; }
Property Value
Type Description
float3

xz

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

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

xzy

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

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

yx

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

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

yxz

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

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

yz

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

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

yzx

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

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

zx

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

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

zxy

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

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

zy

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

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

zyx

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

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

Methods

Add(float3, float3)

Adds two vectors.

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

Left operand.

float3 b

Right operand.

Returns
Type Description
float3

Result of operation.

Add(float3, Single)

Adds a scalar to a instance.

Declaration
public static float3 Add(float3 vec, float scale)
Parameters
Type Name Description
float3 vec

The first instance.

System.Single scale

The scalar.

Returns
Type Description
float3

The result of the calculation.

Barycentric(float3, float3, float3, Single, Single)

Interpolate 3 Vectors using Barycentric coordinates

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

First input Vector

float3 b

Second input Vector

float3 c

Third input Vector

System.Single u

First Barycentric Coordinate

System.Single v

Second Barycentric Coordinate

Returns
Type Description
float3

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

Calculates the angle (in radians) between two vectors.

Declaration
public static float CalculateAngle(float3 first, float3 second)
Parameters
Type Name Description
float3 first

The first vector.

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

Clamp a vector to the given minimum and maximum vectors

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

Input vector

float3 min

Minimum vector

float3 max

Maximum vector

Returns
Type Description
float3

The clamped vector

ComponentMax(float3, float3)

Calculate the component-wise maximum of two vectors

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

First operand

float3 b

Second operand

Returns
Type Description
float3

The component-wise maximum

ComponentMin(float3, float3)

Calculate the component-wise minimum of two vectors

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

First operand

float3 b

Second operand

Returns
Type Description
float3

The component-wise minimum

Cross(float3, float3)

Caclulate the cross (vector) product of two vectors

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

First operand

float3 right

Second operand

Returns
Type Description
float3

The cross product of the two inputs

Divide(float3, float3)

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

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

Left operand.

float3 scale

Right operand.

Returns
Type Description
float3

Result of the operation.

Divide(float3, Single)

Divides a vector by a scalar.

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

Left operand.

System.Single scale

Right operand.

Returns
Type Description
float3

Result of the operation.

Dot(float3, float3)

Calculate the dot (scalar) product of two vectors

Declaration
public static float Dot(float3 left, float3 right)
Parameters
Type Name Description
float3 left

First operand

float3 right

Second operand

Returns
Type Description
System.Single

The dot product of the two inputs

Equals(float3)

Indicates whether the current vector is equal to another vector.

Declaration
public bool Equals(float3 other)
Parameters
Type Name Description
float3 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(float3, float3, float3, float3, out Single, out Single)

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(float3 a, float3 b, float3 c, float3 point, out float u, out float v)
Parameters
Type Name Description
float3 a

The first point of the triangle.

float3 b

The second point of the triangle.

float3 c

The third point of the triangle.

float3 point

The point to calculate the barycentric coordinates for.

System.Single u

The resulting u coordinate.

System.Single v

The resulting v coordinate.

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

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

First input vector

float3 b

Second input vector

float3 blend

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

Returns
Type Description
float3

Lerp(float3, float3, Single)

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

Declaration
public static float3 Lerp(float3 a, float3 b, float blend)
Parameters
Type Name Description
float3 a

First input vector

float3 b

Second input vector

System.Single blend

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

Returns
Type Description
float3

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

LinearColorFromSRgb()

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

Declaration
public float3 LinearColorFromSRgb()
Returns
Type Description
float3

LinearColorFromSRgb(float3)

Converts a color value from sRgb to linear space.

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

The sRgb color value as float3.

Returns
Type Description
float3

LinearColorFromSRgb(Int32, Int32, Int32)

Converts a color value from sRgb to linear space.

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

LinearColorFromSRgb(String)

Converts a color value from sRgb to linear space.

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

LinearColorFromSRgb(UInt32)

Converts a color value from sRgb to linear space.

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

The color value as uint.

Returns
Type Description
float3

Max(float3, float3)

Returns the float3 with the maximum magnitude

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

Left operand

float3 right

Right operand

Returns
Type Description
float3

The maximum float3

Min(float3, float3)

Returns the float3 with the minimum magnitude

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

Left operand

float3 right

Right operand

Returns
Type Description
float3

The minimum float3

Multiply(float3, float3)

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

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

Left operand.

float3 scale

Right operand.

Returns
Type Description
float3

Result of the operation.

Multiply(float3, Single)

Multiplies a vector by a scalar.

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

Left operand.

System.Single scale

Right operand.

Returns
Type Description
float3

Result of the operation.

Normalize()

Scales the float3 to unit length.

Declaration
public float3 Normalize()
Returns
Type Description
float3

Normalize(float3)

Scale a vector to unit length

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

The input vector

Returns
Type Description
float3

The normalized vector

NormalizeFast()

Scales the float3 to approximately unit length.

Declaration
public float3 NormalizeFast()
Returns
Type Description
float3

NormalizeFast(float3)

Scale a vector to approximately unit length

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

The input vector

Returns
Type Description
float3

The normalized vector

OrthoNormalize(float3, float3)

Normalizes the given vectors and makes sure they are orthogonal to each other.

Declaration
public static float3[] OrthoNormalize(float3 vecOne, float3 vecTwo)
Parameters
Type Name Description
float3 vecOne

The first vector.

float3 vecTwo

The second vector.

Returns
Type Description
float3[]

An float3 Array of size 2 with orthonormalized vectors.

Parse(String, IFormatProvider)

Parses a string into a float3.

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

PointInTriangle(float3, float3, float3, float3, out Single, out Single)

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

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

The first point of the triangle.

float3 b

The second point of the triangle.

float3 c

The third point of the triangle.

float3 point

the point to test.

System.Single u

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

System.Single 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(float3, Single)

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

Declaration
public static float3 Pow(float3 val, float exp)
Parameters
Type Name Description
float3 val

The float3 to be raised to a power.

System.Single exp

A float that specifies a power.

Returns
Type Description
float3

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

The angles used for the rotation.

float3 vec

The vector to rotate.

System.Boolean inDegrees

Optional: Whether the angles are given in degrees (true) or radians (false). Defautl is radians.

Returns
Type Description
float3

The rotated vector.

Rotate(QuaternionF, float3)

Rotates a vector by the given quaternion.

Declaration
public static float3 Rotate(QuaternionF quat, float3 vec)
Parameters
Type Name Description
QuaternionF quat

The quaternion used for the rotation.

float3 vec

The vector to rotate.

Returns
Type Description
float3

The rotated vector.

SRgbFromLinearColor()

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

Declaration
public float3 SRgbFromLinearColor()
Returns
Type Description
float3

SRgbFromLinearColor(float3)

Converts a color value from linear to sRgb space.

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

The linear color value as float3.

Returns
Type Description
float3

SRgbFromLinearColor(Int32, Int32, Int32)

Converts a color value from linear to sRgb space.

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

SRgbFromLinearColor(String)

Converts a color value from linear to sRgb space.

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

SRgbFromLinearColor(UInt32)

Converts a color value from linear to sRgb space.

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

The color value as uint.

Returns
Type Description
float3

Step(float3, float3)

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

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

Specifies the location of the edge of the step function.

float3 val

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

Returns
Type Description
float3

Subtract(float3, float3)

Subtract one Vector from another

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

First operand

float3 b

Second operand

Returns
Type Description
float3

Result of subtraction

Subtract(float3, Single)

Adds a scalar from a instance.

Declaration
public static float3 Subtract(float3 vec, float scale)
Parameters
Type Name Description
float3 vec

The first instance.

System.Single scale

The scalar.

Returns
Type Description
float3

The result of the calculation.

ToArray()

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

Declaration
public float[] ToArray()
Returns
Type Description
System.Single[]

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

ToString()

Returns a System.String that represents the current float3.

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 float3.

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

Adds two instances.

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

The first instance.

float3 right

The second instance.

Returns
Type Description
float3

The result of the calculation.

Addition(float3, Single)

Adds a scalar to a instance.

Declaration
public static float3 operator +(float3 left, float scalar)
Parameters
Type Name Description
float3 left

The first instance.

System.Single scalar

The scalar.

Returns
Type Description
float3

The result of the calculation.

Division(float3, Single)

Divides an instance by a scalar.

Declaration
public static float3 operator /(float3 vec, float scale)
Parameters
Type Name Description
float3 vec

The instance.

System.Single scale

The scalar.

Returns
Type Description
float3

The result of the calculation.

Equality(float3, float3)

Compares two instances for equality.

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

The first instance.

float3 right

The second instance.

Returns
Type Description
System.Boolean

True, if left equals right; false otherwise.

Explicit(double3 to float3)

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

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

The double3 value to cast.

Returns
Type Description
float3

A float3 value.

Inequality(float3, float3)

Compares two instances for inequality.

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

The first instance.

float3 right

The second instance.

Returns
Type Description
System.Boolean

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

Multiply(float3, float3)

Multiplies two instances (component-wise).

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

The first instance.

float3 vec2

The second instance.

Returns
Type Description
float3

The result of the multiplication.

Multiply(float3, Single)

Multiplies an instance by a scalar.

Declaration
public static float3 operator *(float3 vec, float scale)
Parameters
Type Name Description
float3 vec

The instance.

System.Single scale

The scalar.

Returns
Type Description
float3

The result of the calculation.

Multiply(Single, float3)

Multiplies an instance by a scalar.

Declaration
public static float3 operator *(float scale, float3 vec)
Parameters
Type Name Description
System.Single scale

The scalar.

float3 vec

The instance.

Returns
Type Description
float3

The result of the calculation.

Subtraction(float3, float3)

Subtracts two instances.

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

The first instance.

float3 right

The second instance.

Returns
Type Description
float3

The result of the calculation.

Subtraction(float3, Single)

Adds a scalar from a instance.

Declaration
public static float3 operator -(float3 left, float scalar)
Parameters
Type Name Description
float3 left

The first instance.

System.Single scalar

The scalar.

Returns
Type Description
float3

The result of the calculation.

UnaryNegation(float3)

Negates an instance.

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

The instance.

Returns
Type Description
float3

The result of the calculation.

Implements

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