Vector4
Represents a 4D vector using four double-precision floating-point numbers.
Implements: IEquatable<Vector4>
Constructors
public Vector4(double x, double y, double z, double w)
vector4 = Vector4(x, y, z, w)
Constructs a new Vector4d.
- x
- The x component of the Vector4d.
- y
- The y component of the Vector4d.
- z
- The z component of the Vector4d.
- w
- The w component of the Vector4d.
public Vector4(Vector2 v)
vector4 = Vector4(v)
Constructs a new Vector4d from the given Vector2d.
- v
- The Vector2d to copy components from.
public Vector4(Vector3 v)
vector4 = Vector4(v)
Constructs a new Vector4d from the given Vector3d.
- v
- The Vector3d to copy components from.
public Vector4(Vector3 v, double w)
vector4 = Vector4(v, w)
Constructs a new Vector4d from the specified Vector3d and w component.
- v
- The Vector3d to copy components from.
- w
- The w component of the new Vector4.
public Vector4(Vector4 v)
vector4 = Vector4(v)
Constructs a new Vector4d from the given Vector4d.
- v
- The Vector4d to copy components from.
Properties
public double Length { get; }
value = vector4.Length
Gets the length (magnitude) of the vector.
public double LengthFast { get; }
value = vector4.LengthFast
Gets an approximation of the vector length (magnitude).
public double LengthSquared { get; }
value = vector4.LengthSquared
Gets the square of the vector length (magnitude).
public Vector2 Xy { get; set; }
value = vector4.Xy
vector4.Xy = value
Gets or sets an OpenTK.Vector2d with the X and Y components of this instance.
public Vector3 Xyz { get; set; }
value = vector4.Xyz
vector4.Xyz = value
Gets or sets an OpenTK.Vector3d with the X, Y and Z components of this instance.
Methods
public static void Add(Vector4 a, Vector4 b, Vector4 result)
Vector4.Add(a, b, result)
Adds two vectors.
- a
- Left operand.
- b
- Right operand.
- result
- Result of operation.
public static Vector4 Add(Vector4 a, Vector4 b)
result = Vector4.Add(a, b)
Adds two vectors.
- a
- Left operand.
- b
- Right operand.
Returns: Result of operation.
public static void BaryCentric(Vector4 a, Vector4 b, Vector4 c, double u, double v, Vector4 result)
Vector4.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
public static Vector4 BaryCentric(Vector4 a, Vector4 b, Vector4 c, double u, double v)
result = Vector4.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
public static void Clamp(Vector4 vec, Vector4 min, Vector4 max, Vector4 result)
Vector4.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
public static Vector4 Clamp(Vector4 vec, Vector4 min, Vector4 max)
result = Vector4.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
public static Vector4 Divide(Vector4 vector, double scale)
result = Vector4.Divide(vector, scale)
Divides a vector by a scalar.
- vector
- Left operand.
- scale
- Right operand.
Returns: Result of the operation.
public static void Divide(Vector4 vector, double scale, Vector4 result)
Vector4.Divide(vector, scale, result)
Divides a vector by a scalar.
- vector
- Left operand.
- scale
- Right operand.
- result
- Result of the operation.
public static Vector4 Divide(Vector4 vector, Vector4 scale)
result = Vector4.Divide(vector, scale)
Divides a vector by the components of a vector (scale).
- vector
- Left operand.
- scale
- Right operand.
Returns: Result of the operation.
public static void Divide(Vector4 vector, Vector4 scale, Vector4 result)
Vector4.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.
public static void Dot(Vector4 left, Vector4 right, double result)
Vector4.Dot(left, right, result)
Calculate the dot product of two vectors
- left
- First operand
- right
- Second operand
- result
- The dot product of the two inputs
public static double Dot(Vector4 left, Vector4 right)
result = Vector4.Dot(left, right)
Calculate the dot product of two vectors
- left
- First operand
- right
- Second operand
Returns: The dot product of the two inputs
public bool Equals(Vector4 other)
result = vector4.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.
public override bool Equals(object obj)
result = vector4.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.
public override int GetHashCode()
result = vector4.GetHashCode()
Returns the hashcode for this instance.
Returns: A System.Int32 containing the unique hashcode for this instance.
public static Vector4 Lerp(Vector4 a, Vector4 b, double blend)
result = Vector4.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
public static void Lerp(Vector4 a, Vector4 b, double blend, Vector4 result)
Vector4.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
public static void Max(Vector4 a, Vector4 b, Vector4 result)
Vector4.Max(a, b, result)
Calculate the component-wise maximum of two vectors
- a
- First operand
- b
- Second operand
- result
- The component-wise maximum
public static Vector4 Max(Vector4 a, Vector4 b)
result = Vector4.Max(a, b)
Calculate the component-wise maximum of two vectors
- a
- First operand
- b
- Second operand
Returns: The component-wise maximum
public static Vector4 Min(Vector4 a, Vector4 b)
result = Vector4.Min(a, b)
Calculate the component-wise minimum of two vectors
- a
- First operand
- b
- Second operand
Returns: The component-wise minimum
public static void Min(Vector4 a, Vector4 b, Vector4 result)
Vector4.Min(a, b, result)
Calculate the component-wise minimum of two vectors
- a
- First operand
- b
- Second operand
- result
- The component-wise minimum
public static Vector4 Multiply(Vector4 vector, double scale)
result = Vector4.Multiply(vector, scale)
Multiplies a vector by a scalar.
- vector
- Left operand.
- scale
- Right operand.
Returns: Result of the operation.
public static void Multiply(Vector4 vector, double scale, Vector4 result)
Vector4.Multiply(vector, scale, result)
Multiplies a vector by a scalar.
- vector
- Left operand.
- scale
- Right operand.
- result
- Result of the operation.
public static Vector4 Multiply(Vector4 vector, Vector4 scale)
result = Vector4.Multiply(vector, scale)
Multiplies a vector by the components a vector (scale).
- vector
- Left operand.
- scale
- Right operand.
Returns: Result of the operation.
public static void Multiply(Vector4 vector, Vector4 scale, Vector4 result)
Vector4.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.
public static Vector4 Normalize(Vector4 vec)
result = Vector4.Normalize(vec)
Scale a vector to unit length
- vec
- The input vector
Returns: The normalized vector
public static void Normalize(Vector4 vec, Vector4 result)
Vector4.Normalize(vec, result)
Scale a vector to unit length
- vec
- The input vector
- result
- The normalized vector
public void NormalizeFast()
vector4.NormalizeFast()
Scales the Vector4d to approximately unit length.
public static void NormalizeFast(Vector4 vec, Vector4 result)
Vector4.NormalizeFast(vec, result)
Scale a vector to approximately unit length
- vec
- The input vector
- result
- The normalized vector
public static Vector4 NormalizeFast(Vector4 vec)
result = Vector4.NormalizeFast(vec)
Scale a vector to approximately unit length
- vec
- The input vector
Returns: The normalized vector
public static Vector4 op_Addition(Vector4 left, Vector4 right)
result = Vector4.op_Addition(left, right)
Adds two instances.
- left
- The first instance.
- right
- The second instance.
Returns: The result of the calculation.
public static Vector4 op_Division(Vector4 vec, double scale)
result = Vector4.op_Division(vec, scale)
Divides an instance by a scalar.
- vec
- The instance.
- scale
- The scalar.
Returns: The result of the calculation.
public static bool op_Equality(Vector4 left, Vector4 right)
result = Vector4.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_Explicit(Double*) : IntPtr
Returns a pointer to the first element of the specified instance.
- v
- The instance.
Returns: A pointer to the first element of v.
op_Explicit(IntPtr) : IntPtr
Returns a pointer to the first element of the specified instance.
- v
- The instance.
Returns: A pointer to the first element of v.
public static bool op_Inequality(Vector4 left, Vector4 right)
result = Vector4.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.
public static Vector4 op_Multiply(double scale, Vector4 vec)
result = Vector4.op_Multiply(scale, vec)
Multiplies an instance by a scalar.
- scale
- The scalar.
- vec
- The instance.
Returns: The result of the calculation.
public static Vector4 op_Multiply(Vector4 vec, double scale)
result = Vector4.op_Multiply(vec, scale)
Multiplies an instance by a scalar.
- vec
- The instance.
- scale
- The scalar.
Returns: The result of the calculation.
public static Vector4 op_Subtraction(Vector4 left, Vector4 right)
result = Vector4.op_Subtraction(left, right)
Subtracts two instances.
- left
- The first instance.
- right
- The second instance.
Returns: The result of the calculation.
public static Vector4 op_UnaryNegation(Vector4 vec)
result = Vector4.op_UnaryNegation(vec)
Negates an instance.
- vec
- The instance.
Returns: The result of the calculation.
public static Vector4 Subtract(Vector4 a, Vector4 b)
result = Vector4.Subtract(a, b)
Subtract one Vector from another
- a
- First operand
- b
- Second operand
Returns: Result of subtraction
public static void Subtract(Vector4 a, Vector4 b, Vector4 result)
Vector4.Subtract(a, b, result)
Subtract one Vector from another
- a
- First operand
- b
- Second operand
- result
- Result of subtraction
public string ToString(string format)
result = vector4.ToString(format)
Returns a System.String that represents the current Vector4d, formatting each element with format.
- format
public override string ToString()
result = vector4.ToString()
Returns a System.String that represents the current Vector4d.
public static Vector4 Transform(Vector4 vec, Matrix4X4 mat)
result = Vector4.Transform(vec, mat)
Transform a Vector by the given Matrix
- vec
- The vector to transform
- mat
- The desired transformation
Returns: The transformed vector
public static void Transform(Vector4 vec, Matrix4X4 mat, Vector4 result)
Vector4.Transform(vec, mat, result)
Transform a Vector by the given Matrix
- vec
- The vector to transform
- mat
- The desired transformation
- result
- The transformed vector
public static Vector4 Transform(Vector4 vec, Quaternion quat)
result = Vector4.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.
public static void Transform(Vector4 vec, Quaternion quat, Vector4 result)
Vector4.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.
Fields
public static readonly Vector4 One
value = Vector4.One
Defines an instance with all components set to 1.
public static readonly int SizeInBytes
value = Vector4.SizeInBytes
Defines the size of the Vector4d struct in bytes.
public static Vector4 UnitW
value = Vector4.UnitW
Defines a unit-length Vector4d that points towards the W-axis.
public static Vector4 UnitX
value = Vector4.UnitX
Defines a unit-length Vector4d that points towards the X-axis.
public static Vector4 UnitY
value = Vector4.UnitY
Defines a unit-length Vector4d that points towards the Y-axis.
public static Vector4 UnitZ
value = Vector4.UnitZ
Defines a unit-length Vector4d that points towards the Z-axis.