Vector3

StockSharp.Xaml.Charting.Rendering.HighQualityRasterizer.Agg.VectorMath

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

Implements: IEquatable<Vector3>

Constructors

Vector3
public Vector3(double x, double y, double z)
vector3 = Vector3(x, y, z)

Constructs a new Vector3.

x
The x component of the Vector3.
y
The y component of the Vector3.
z
The z component of the Vector3.
Vector3
public Vector3(Vector2 v, double z)
vector3 = Vector3(v, z)

Constructs a new instance from the given Vector2d.

v
The Vector2d to copy components from.
z
Vector3
public Vector3(Vector3 v)
vector3 = Vector3(v)

Constructs a new instance from the given Vector3d.

v
The Vector3d to copy components from.
Vector3
public Vector3(Vector4 v)
vector3 = Vector3(v)

Constructs a new instance from the given Vector4d.

v
The Vector4d to copy components from.

Properties

Length
public double Length { get; }
value = vector3.Length

Gets the length (magnitude) of the vector.

LengthFast
public double LengthFast { get; }
value = vector3.LengthFast

Gets an approximation of the vector length (magnitude).

LengthSquared
public double LengthSquared { get; }
value = vector3.LengthSquared

Gets the square of the vector length (magnitude).

Xy
public Vector2 Xy { get; set; }
value = vector3.Xy
vector3.Xy = value

Gets or sets an OpenTK.Vector2d with the X and Y components of this instance.

Methods

Add
public static void Add(Vector3 a, Vector3 b, Vector3 result)
Vector3.Add(a, b, result)

Adds two vectors.

a
Left operand.
b
Right operand.
result
Result of operation.
Add
public static Vector3 Add(Vector3 a, Vector3 b)
result = Vector3.Add(a, b)

Adds two vectors.

a
Left operand.
b
Right operand.

Returns: Result of operation.

BaryCentric
public static void BaryCentric(Vector3 a, Vector3 b, Vector3 c, double u, double v, Vector3 result)
Vector3.BaryCentric(a, b, c, u, v, result)

Interpolate 3 Vectors using Barycentric coordinates

a
First input Vector.
b
Second input Vector.
c
Third input Vector.
u
First Barycentric Coordinate.
v
Second Barycentric Coordinate.
result
Output Vector. a when u=v=0, b when u=1,v=0, c when u=0,v=1, and a linear combination of a,b,c otherwise
BaryCentric
public static Vector3 BaryCentric(Vector3 a, Vector3 b, Vector3 c, double u, double v)
result = Vector3.BaryCentric(a, b, c, u, v)

Interpolate 3 Vectors using Barycentric coordinates

a
First input Vector
b
Second input Vector
c
Third input Vector
u
First Barycentric Coordinate
v
Second Barycentric Coordinate

Returns: a when u=v=0, b when u=1,v=0, c when u=0,v=1, and a linear combination of a,b,c otherwise

CalculateAngle
public static void CalculateAngle(Vector3 first, Vector3 second, double result)
Vector3.CalculateAngle(first, second, result)

Calculates the angle (in radians) between two vectors.

first
The first vector.
second
The second vector.
result
Angle (in radians) between the vectors.
CalculateAngle
public static double CalculateAngle(Vector3 first, Vector3 second)
result = Vector3.CalculateAngle(first, second)

Calculates the angle (in radians) between two vectors.

first
The first vector.
second
The second vector.

Returns: Angle (in radians) between the vectors.

Clamp
public static void Clamp(Vector3 vec, Vector3 min, Vector3 max, Vector3 result)
Vector3.Clamp(vec, min, max, result)

Clamp a vector to the given minimum and maximum vectors

vec
Input vector
min
Minimum vector
max
Maximum vector
result
The clamped vector
Clamp
public static Vector3 Clamp(Vector3 vec, Vector3 min, Vector3 max)
result = Vector3.Clamp(vec, min, max)

Clamp a vector to the given minimum and maximum vectors

vec
Input vector
min
Minimum vector
max
Maximum vector

Returns: The clamped vector

ComponentMax
public static Vector3 ComponentMax(Vector3 a, Vector3 b)
result = Vector3.ComponentMax(a, b)

Calculate the component-wise maximum of two vectors

a
First operand
b
Second operand

Returns: The component-wise maximum

ComponentMax
public static void ComponentMax(Vector3 a, Vector3 b, Vector3 result)
Vector3.ComponentMax(a, b, result)

Calculate the component-wise maximum of two vectors

a
First operand
b
Second operand
result
The component-wise maximum
ComponentMin
public static Vector3 ComponentMin(Vector3 a, Vector3 b)
result = Vector3.ComponentMin(a, b)

Calculate the component-wise minimum of two vectors

a
First operand
b
Second operand

Returns: The component-wise minimum

ComponentMin
public static void ComponentMin(Vector3 a, Vector3 b, Vector3 result)
Vector3.ComponentMin(a, b, result)

Calculate the component-wise minimum of two vectors

a
First operand
b
Second operand
result
The component-wise minimum
Cross
public static void Cross(Vector3 left, Vector3 right, Vector3 result)
Vector3.Cross(left, right, result)

Caclulate the cross (vector) product of two vectors

left
First operand
right
Second operand
result
The cross product of the two inputs

Returns: The cross product of the two inputs

Cross
public static Vector3 Cross(Vector3 left, Vector3 right)
result = Vector3.Cross(left, right)

Caclulate the cross (vector) product of two vectors

left
First operand
right
Second operand

Returns: The cross product of the two inputs

Divide
public static Vector3 Divide(Vector3 vector, Vector3 scale)
result = Vector3.Divide(vector, scale)

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

vector
Left operand.
scale
Right operand.

Returns: Result of the operation.

Divide
public static void Divide(Vector3 vector, double scale, Vector3 result)
Vector3.Divide(vector, scale, result)

Divides a vector by a scalar.

vector
Left operand.
scale
Right operand.
result
Result of the operation.
Divide
public static Vector3 Divide(Vector3 vector, double scale)
result = Vector3.Divide(vector, scale)

Divides a vector by a scalar.

vector
Left operand.
scale
Right operand.

Returns: Result of the operation.

Divide
public static void Divide(Vector3 vector, Vector3 scale, Vector3 result)
Vector3.Divide(vector, scale, result)

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

vector
Left operand.
scale
Right operand.
result
Result of the operation.
Dot
public static void Dot(Vector3 left, Vector3 right, double result)
Vector3.Dot(left, right, result)

Calculate the dot (scalar) product of two vectors

left
First operand
right
Second operand
result
The dot product of the two inputs
Dot
public static double Dot(Vector3 left, Vector3 right)
result = Vector3.Dot(left, right)

Calculate the dot (scalar) product of two vectors

left
First operand
right
Second operand

Returns: The dot product of the two inputs

Equals
public bool Equals(Vector3 OtherVector, double ErrorValue)
result = vector3.Equals(OtherVector, ErrorValue)

Indicates whether this instance and a specified object are equal within an error range.

OtherVector
ErrorValue

Returns: True if the instances are equal; false otherwise.

Equals
public bool Equals(Vector3 other)
result = vector3.Equals(other)

Indicates whether the current vector is equal to another vector.

other
A vector to compare with this vector.

Returns: true if the current vector is equal to the vector parameter; otherwise, false.

Equals
public override bool Equals(object obj)
result = vector3.Equals(obj)

Indicates whether this instance and a specified object are equal.

obj
The object to compare to.

Returns: True if the instances are equal; false otherwise.

GetHashCode
public override int GetHashCode()
result = vector3.GetHashCode()

Returns the hashcode for this instance.

Returns: A System.Int32 containing the unique hashcode for this instance.

GetNormal
public Vector3 GetNormal()
result = vector3.GetNormal()

Returns a normalized Vector of this.

Lerp
public static Vector3 Lerp(Vector3 a, Vector3 b, double blend)
result = Vector3.Lerp(a, b, blend)

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

a
First input vector
b
Second input vector
blend
The blend factor. a when blend=0, b when blend=1.

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

Lerp
public static void Lerp(Vector3 a, Vector3 b, double blend, Vector3 result)
Vector3.Lerp(a, b, blend, result)

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

a
First input vector
b
Second input vector
blend
The blend factor. a when blend=0, b when blend=1.
result
a when blend=0, b when blend=1, and a linear combination otherwise
Max
public static Vector3 Max(Vector3 left, Vector3 right)
result = Vector3.Max(left, right)

Returns the Vector3d with the minimum magnitude

left
Left operand
right
Right operand

Returns: The minimum Vector3

Min
public static Vector3 Min(Vector3 left, Vector3 right)
result = Vector3.Min(left, right)

Returns the Vector3d with the minimum magnitude

left
Left operand
right
Right operand

Returns: The minimum Vector3

Multiply
public static Vector3 Multiply(Vector3 vector, double scale)
result = Vector3.Multiply(vector, scale)

Multiplies a vector by a scalar.

vector
Left operand.
scale
Right operand.

Returns: Result of the operation.

Multiply
public static void Multiply(Vector3 vector, double scale, Vector3 result)
Vector3.Multiply(vector, scale, result)

Multiplies a vector by a scalar.

vector
Left operand.
scale
Right operand.
result
Result of the operation.
Multiply
public static Vector3 Multiply(Vector3 vector, Vector3 scale)
result = Vector3.Multiply(vector, scale)

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

vector
Left operand.
scale
Right operand.

Returns: Result of the operation.

Multiply
public static void Multiply(Vector3 vector, Vector3 scale, Vector3 result)
Vector3.Multiply(vector, scale, result)

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

vector
Left operand.
scale
Right operand.
result
Result of the operation.
Normalize
public void Normalize()
vector3.Normalize()

Scales the Vector3d to unit length.

Normalize
public static void Normalize(Vector3 vec, Vector3 result)
Vector3.Normalize(vec, result)

Scale a vector to unit length

vec
The input vector
result
The normalized vector
Normalize
public static Vector3 Normalize(Vector3 vec)
result = Vector3.Normalize(vec)

Scale a vector to unit length

vec
The input vector

Returns: The normalized vector

NormalizeFast
public static void NormalizeFast(Vector3 vec, Vector3 result)
Vector3.NormalizeFast(vec, result)

Scale a vector to approximately unit length

vec
The input vector
result
The normalized vector
NormalizeFast
public static Vector3 NormalizeFast(Vector3 vec)
result = Vector3.NormalizeFast(vec)

Scale a vector to approximately unit length

vec
The input vector

Returns: The normalized vector

NormalizeFast
public void NormalizeFast()
vector3.NormalizeFast()

Scales the Vector3d to approximately unit length.

op_Addition
public static Vector3 op_Addition(Vector3 left, Vector3 right)
result = Vector3.op_Addition(left, right)

Adds two instances.

left
The first instance.
right
The second instance.

Returns: The result of the calculation.

op_Division
public static Vector3 op_Division(double numerator, Vector3 vec)
result = Vector3.op_Division(numerator, vec)

Creates a new vector which is the numerator devided by each component of the vector.

numerator
vec

Returns: The result of the calculation.

op_Division
public static Vector3 op_Division(Vector3 vec, double scale)
result = Vector3.op_Division(vec, scale)

Divides an instance by a scalar.

vec
The instance.
scale
The scalar.

Returns: The result of the calculation.

op_Equality
public static bool op_Equality(Vector3 left, Vector3 right)
result = Vector3.op_Equality(left, right)

Compares two instances for equality.

left
The first instance.
right
The second instance.

Returns: True, if left equals right; false otherwise.

op_Inequality
public static bool op_Inequality(Vector3 left, Vector3 right)
result = Vector3.op_Inequality(left, right)

Compares two instances for inequality.

left
The first instance.
right
The second instance.

Returns: True, if left does not equa lright; false otherwise.

op_Multiply
public static Vector3 op_Multiply(double scale, Vector3 vec)
result = Vector3.op_Multiply(scale, vec)

Multiplies an instance by a scalar.

scale
The scalar.
vec
The instance.

Returns: The result of the calculation.

op_Multiply
public static Vector3 op_Multiply(Vector3 vec, double scale)
result = Vector3.op_Multiply(vec, scale)

Multiplies an instance by a scalar.

vec
The instance.
scale
The scalar.

Returns: The result of the calculation.

op_Multiply
public static Vector3 op_Multiply(Vector3 vecA, Vector3 vecB)
result = Vector3.op_Multiply(vecA, vecB)

Component wise multiply two vectors together, x*x, y*y, z*z.

vecA
vecB
op_Subtraction
public static Vector3 op_Subtraction(Vector3 left, Vector3 right)
result = Vector3.op_Subtraction(left, right)

Subtracts two instances.

left
The first instance.
right
The second instance.

Returns: The result of the calculation.

op_UnaryNegation
public static Vector3 op_UnaryNegation(Vector3 vec)
result = Vector3.op_UnaryNegation(vec)

Negates an instance.

vec
The instance.

Returns: The result of the calculation.

Subtract
public static Vector3 Subtract(Vector3 a, Vector3 b)
result = Vector3.Subtract(a, b)

Subtract one Vector from another

a
First operand
b
Second operand

Returns: Result of subtraction

Subtract
public static void Subtract(Vector3 a, Vector3 b, Vector3 result)
Vector3.Subtract(a, b, result)

Subtract one Vector from another

a
First operand
b
Second operand
result
Result of subtraction
ToString
public override string ToString()
result = vector3.ToString()

Returns a System.String that represents the current Vector3.

Transform
public static void Transform(Vector3[] vecArray, Quaternion rotationQuaternion)
Vector3.Transform(vecArray, rotationQuaternion)

Transform all the vectors in the array by the quaternion rotation.

vecArray
rotationQuaternion
Transform
public static void Transform(Vector3 vec, Quaternion quat, Vector3 result)
Vector3.Transform(vec, quat, result)

Transforms a vector by a quaternion rotation.

vec
The vector to transform.
quat
The quaternion to rotate the vector by.
result
The result of the operation.
Transform
public static void Transform(Vector3 vec, Matrix4X4 mat, Vector3 result)
Vector3.Transform(vec, mat, result)

Transform a Vector by the given Matrix

vec
The vector to transform
mat
The desired transformation
result
The transformed vector
Transform
public static Vector3 Transform(Vector3 vec, Quaternion quat)
result = Vector3.Transform(vec, quat)

Transforms a vector by a quaternion rotation.

vec
The vector to transform.
quat
The quaternion to rotate the vector by.

Returns: The result of the operation.

Transform
public static void Transform(Vector3[] vecArray, Matrix4X4 mat)
Vector3.Transform(vecArray, mat)

Transform all the vectors in the array by the given Matrix.

Transform
public static Vector3 Transform(Vector3 vec, Matrix4X4 mat)
result = Vector3.Transform(vec, mat)

Transform a Vector by the given Matrix

vec
The vector to transform
mat
The desired transformation

Returns: The transformed vector

TransformNormal
public static void TransformNormal(Vector3 norm, Matrix4X4 mat, Vector3 result)
Vector3.TransformNormal(norm, mat, result)

Transform a Normal by the given Matrix

norm
The normal to transform
mat
The desired transformation
result
The transformed normal
TransformNormal
public static Vector3 TransformNormal(Vector3 norm, Matrix4X4 mat)
result = Vector3.TransformNormal(norm, mat)

Transform a Normal by the given Matrix

norm
The normal to transform
mat
The desired transformation

Returns: The transformed normal

TransformNormalInverse
public static void TransformNormalInverse(Vector3 norm, Matrix4X4 invMat, Vector3 result)
Vector3.TransformNormalInverse(norm, invMat, result)

Transform a Normal by the (transpose of the) given Matrix

norm
The normal to transform
invMat
The inverse of the desired transformation
result
The transformed normal
TransformNormalInverse
public static Vector3 TransformNormalInverse(Vector3 norm, Matrix4X4 invMat)
result = Vector3.TransformNormalInverse(norm, invMat)

Transform a Normal by the (transpose of the) given Matrix

norm
The normal to transform
invMat
The inverse of the desired transformation

Returns: The transformed normal

TransformPerspective
public static Vector3 TransformPerspective(Vector3 vec, Matrix4X4 mat)
result = Vector3.TransformPerspective(vec, mat)

Transform a Vector3d by the given Matrix, and project the resulting Vector4 back to a Vector3

vec
The vector to transform
mat
The desired transformation

Returns: The transformed vector

TransformPerspective
public static void TransformPerspective(Vector3 vec, Matrix4X4 mat, Vector3 result)
Vector3.TransformPerspective(vec, mat, result)

Transform a Vector3d by the given Matrix, and project the resulting Vector4d back to a Vector3d

vec
The vector to transform
mat
The desired transformation
result
The transformed vector
TransformPosition
public static void TransformPosition(Vector3 pos, Matrix4X4 mat, Vector3 result)
Vector3.TransformPosition(pos, mat, result)

Transform a Position by the given Matrix

pos
The position to transform
mat
The desired transformation
result
The transformed position
TransformPosition
public static Vector3 TransformPosition(Vector3 pos, Matrix4X4 mat)
result = Vector3.TransformPosition(pos, mat)

Transform a Position by the given Matrix

pos
The position to transform
mat
The desired transformation

Returns: The transformed position

TransformVector
public static void TransformVector(Vector3 vec, Matrix4X4 mat, Vector3 result)
Vector3.TransformVector(vec, mat, result)

Transform a direction vector by the given Matrix Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.

vec
The vector to transform
mat
The desired transformation
result
The transformed vector
TransformVector
public static Vector3 TransformVector(Vector3 vec, Matrix4X4 mat)
result = Vector3.TransformVector(vec, mat)

Transform a direction vector by the given Matrix Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.

vec
The vector to transform
mat
The desired transformation

Returns: The transformed vector

Fields

NegativeInfinity
public static readonly Vector3 NegativeInfinity
value = Vector3.NegativeInfinity

Defines an instance with all components set to negative infinity.

One
public static readonly Vector3 One
value = Vector3.One

Defines an instance with all components set to 1.

PositiveInfinity
public static readonly Vector3 PositiveInfinity
value = Vector3.PositiveInfinity

Defines an instance with all components set to positive infinity.

SizeInBytes
public static readonly int SizeInBytes
value = Vector3.SizeInBytes

Defines the size of the Vector3d struct in bytes.

UnitX
public static readonly Vector3 UnitX
value = Vector3.UnitX

Defines a unit-length Vector3d that points towards the X-axis.

UnitY
public static readonly Vector3 UnitY
value = Vector3.UnitY

Defines a unit-length Vector3d that points towards the Y-axis.

UnitZ
public static readonly Vector3 UnitZ
value = Vector3.UnitZ

/// Defines a unit-length Vector3d that points towards the Z-axis.

x
public double x
value = vector3.x

The X component of the Vector3.

y
public double y
value = vector3.y

The Y component of the Vector3.

z
public double z
value = vector3.z

The Z component of the Vector3.

Zero
public static readonly Vector3 Zero
value = Vector3.Zero

Defines a zero-length Vector3.