Show / Hide Table of Contents

Class Vector3

Defines a vector with three components.

Inheritance
System.Object
Vector3
Namespace: VRageMath
Assembly: VRage.Math.dll
Syntax
public sealed class Vector3 : ValueType, IEquatable<Vector3>

Constructors

Vector3(Double, Double, Double)

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

Vector3(Single)

Creates a new instance of Vector3.

Declaration
public Vector3(float value)
Parameters
Type Name Description
System.Single value

Value to initialize each component to.

Vector3(Single, Single, Single)

Initializes a new instance of Vector3.

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

Initial value for the x-component of the vector.

System.Single y

Initial value for the y-component of the vector.

System.Single z

Initial value for the z-component of the vector.

Vector3(Vector2, Single)

Initializes a new instance of Vector3.

Declaration
public Vector3(Vector2 value, float z)
Parameters
Type Name Description
Vector2 value

A vector containing the values to initialize x and y components with.

System.Single z

Initial value for the z-component of the vector.

Vector3(Vector3I)

Declaration
public Vector3(Vector3I value)
Parameters
Type Name Description
Vector3I value

Vector3(ref Vector3I)

Declaration
public Vector3(ref Vector3I value)
Parameters
Type Name Description
Vector3I value

Vector3(Vector4)

Declaration
public Vector3(Vector4 xyz)
Parameters
Type Name Description
Vector4 xyz

Fields

Backward

Declaration
public static Vector3 Backward
Field Value
Type Description
Vector3

Down

Declaration
public static Vector3 Down
Field Value
Type Description
Vector3

Forward

Declaration
public static Vector3 Forward
Field Value
Type Description
Vector3

Half

Declaration
public static Vector3 Half
Field Value
Type Description
Vector3

Invalid

Declaration
public static Vector3 Invalid
Field Value
Type Description
Vector3

Left

Declaration
public static Vector3 Left
Field Value
Type Description
Vector3

MaxValue

Declaration
public static Vector3 MaxValue
Field Value
Type Description
Vector3

MinusOne

Declaration
public static Vector3 MinusOne
Field Value
Type Description
Vector3

MinValue

Declaration
public static Vector3 MinValue
Field Value
Type Description
Vector3

NegativeInfinity

Declaration
public static Vector3 NegativeInfinity
Field Value
Type Description
Vector3

One

Declaration
public static Vector3 One
Field Value
Type Description
Vector3

PositiveInfinity

Declaration
public static Vector3 PositiveInfinity
Field Value
Type Description
Vector3

Right

Declaration
public static Vector3 Right
Field Value
Type Description
Vector3

UnitX

Declaration
public static Vector3 UnitX
Field Value
Type Description
Vector3

UnitY

Declaration
public static Vector3 UnitY
Field Value
Type Description
Vector3

UnitZ

Declaration
public static Vector3 UnitZ
Field Value
Type Description
Vector3

Up

Declaration
public static Vector3 Up
Field Value
Type Description
Vector3

X

Gets or sets the x-component of the vector.

Declaration
public float X
Field Value
Type Description
System.Single

Y

Gets or sets the y-component of the vector.

Declaration
public float Y
Field Value
Type Description
System.Single

Z

Gets or sets the z-component of the vector.

Declaration
public float Z
Field Value
Type Description
System.Single

Zero

Declaration
public static Vector3 Zero
Field Value
Type Description
Vector3

Properties

Sum

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

Volume

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

Methods

Abs(Vector3)

Declaration
public static Vector3 Abs(Vector3 value)
Parameters
Type Name Description
Vector3 value
Returns
Type Description
Vector3

AbsMax()

Returns the component of the vector, whose absolute value is largest of all the three components.

Declaration
public float AbsMax()
Returns
Type Description
System.Single

AbsMin()

Returns the component of the vector, whose absolute value is smallest of all the three components.

Declaration
public float AbsMin()
Returns
Type Description
System.Single

Add(Vector3)

Declaration
public void Add(Vector3 other)
Parameters
Type Name Description
Vector3 other

Add(Vector3, Vector3)

Adds two vectors.

Declaration
public static Vector3 Add(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
Vector3

Add(ref Vector3, ref Vector3, out Vector3)

Adds two vectors.

Declaration
public static void Add(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Vector3 result

[OutAttribute] Sum of the source vectors.

Angle(Vector3, Vector3)

Gets angle between 2 vectors in radians

Declaration
public static double Angle(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

Vector A

Vector3 b

Vector B

Returns
Type Description
System.Double

Angle in radians

ArePerpendicular(Vector3, Vector3)

Declaration
public static bool ArePerpendicular(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a
Vector3 b
Returns
Type Description
System.Boolean

ArePerpendicular(in Vector3, in Vector3)

Declaration
public static bool ArePerpendicular(in Vector3 a, in Vector3 b)
Parameters
Type Name Description
Vector3 a
Vector3 b
Returns
Type Description
System.Boolean

AssertIsValid()

Declaration
public void AssertIsValid()

Barycentric(Vector3, Vector3, Vector3, Single, Single)

Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle.

Declaration
public static Vector3 Barycentric(Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2)
Parameters
Type Name Description
Vector3 value1

A Vector3 containing the 3D Cartesian coordinates of vertex 1 of the triangle.

Vector3 value2

A Vector3 containing the 3D Cartesian coordinates of vertex 2 of the triangle.

Vector3 value3

A Vector3 containing the 3D Cartesian coordinates of vertex 3 of the triangle.

System.Single amount1

Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in value2).

System.Single amount2

Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in value3).

Returns
Type Description
Vector3

Barycentric(Vector3, Vector3, Vector3, Vector3, out Single, out Single, out Single)

Compute barycentric coordinates (u, v, w) for point p with respect to triangle (a, b, c) From : Real-Time Collision Detection, Christer Ericson, CRC Press 3.4 Barycentric Coordinates

Declaration
public static void Barycentric(Vector3 p, Vector3 a, Vector3 b, Vector3 c, out float u, out float v, out float w)
Parameters
Type Name Description
Vector3 p
Vector3 a
Vector3 b
Vector3 c
System.Single u
System.Single v
System.Single w

Barycentric(ref Vector3, ref Vector3, ref Vector3, Single, Single, out Vector3)

Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 3D triangle.

Declaration
public static void Barycentric(ref Vector3 value1, ref Vector3 value2, ref Vector3 value3, float amount1, float amount2, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

A Vector3 containing the 3D Cartesian coordinates of vertex 1 of the triangle.

Vector3 value2

A Vector3 containing the 3D Cartesian coordinates of vertex 2 of the triangle.

Vector3 value3

A Vector3 containing the 3D Cartesian coordinates of vertex 3 of the triangle.

System.Single amount1

Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in value2).

System.Single amount2

Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in value3).

Vector3 result

[OutAttribute] The 3D Cartesian coordinates of the specified point are placed in this Vector3 on exit.

CalculatePerpendicularVector(Vector3)

Declaration
public static Vector3 CalculatePerpendicularVector(Vector3 v)
Parameters
Type Name Description
Vector3 v
Returns
Type Description
Vector3

CalculatePerpendicularVector(out Vector3)

Declaration
public void CalculatePerpendicularVector(out Vector3 result)
Parameters
Type Name Description
Vector3 result

CatmullRom(Vector3, Vector3, Vector3, Vector3, Single)

Performs a Catmull-Rom interpolation using the specified positions.

Declaration
public static Vector3 CatmullRom(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount)
Parameters
Type Name Description
Vector3 value1

The first position in the interpolation.

Vector3 value2

The second position in the interpolation.

Vector3 value3

The third position in the interpolation.

Vector3 value4

The fourth position in the interpolation.

System.Single amount

Weighting factor.

Returns
Type Description
Vector3

CatmullRom(ref Vector3, ref Vector3, ref Vector3, ref Vector3, Single, out Vector3)

Performs a Catmull-Rom interpolation using the specified positions.

Declaration
public static void CatmullRom(ref Vector3 value1, ref Vector3 value2, ref Vector3 value3, ref Vector3 value4, float amount, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

The first position in the interpolation.

Vector3 value2

The second position in the interpolation.

Vector3 value3

The third position in the interpolation.

Vector3 value4

The fourth position in the interpolation.

System.Single amount

Weighting factor.

Vector3 result

[OutAttribute] A vector that is the result of the Catmull-Rom interpolation.

Ceiling(Vector3)

Declaration
public static Vector3 Ceiling(Vector3 v)
Parameters
Type Name Description
Vector3 v
Returns
Type Description
Vector3

Clamp(Vector3, Vector3, Vector3)

Restricts a value to be within a specified range.

Declaration
public static Vector3 Clamp(Vector3 value1, Vector3 min, Vector3 max)
Parameters
Type Name Description
Vector3 value1

The value to clamp.

Vector3 min

The minimum value.

Vector3 max

The maximum value.

Returns
Type Description
Vector3

Clamp(Vector3, Vector3, Vector3, out Vector3, out Vector3, out Vector3)

Restricts a value to be within a specified range.

Declaration
public static Vector3 Clamp(Vector3 value1, Vector3 min, Vector3 max, out Vector3 clampedBy, out Vector3 minRemaining, out Vector3 maxRemaining)
Parameters
Type Name Description
Vector3 value1

The value to clamp.

Vector3 min

The minimum value.

Vector3 max

The maximum value.

Vector3 clampedBy

Value was clamped by this amount

Vector3 minRemaining

Remaining min tolerance

Vector3 maxRemaining

Remaining max tolerance

Returns
Type Description
Vector3

Clamp(ref Vector3, ref Vector3, ref Vector3, out Vector3)

Restricts a value to be within a specified range.

Declaration
public static void Clamp(ref Vector3 value1, ref Vector3 min, ref Vector3 max, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

The value to clamp.

Vector3 min

The minimum value.

Vector3 max

The maximum value.

Vector3 result

[OutAttribute] The clamped value.

ClampToSphere(Vector3, Single)

Declaration
public static Vector3 ClampToSphere(Vector3 vector, float radius)
Parameters
Type Name Description
Vector3 vector
System.Single radius
Returns
Type Description
Vector3

ClampToSphere(ref Vector3, Single)

Declaration
public static void ClampToSphere(ref Vector3 vector, float radius)
Parameters
Type Name Description
Vector3 vector
System.Single radius

CreateFromAzimuthAndElevation(Single, Single, out Vector3)

Declaration
public static void CreateFromAzimuthAndElevation(float azimuth, float elevation, out Vector3 direction)
Parameters
Type Name Description
System.Single azimuth
System.Single elevation
Vector3 direction

Cross(Vector3)

Declaration
public Vector3 Cross(Vector3 v)
Parameters
Type Name Description
Vector3 v
Returns
Type Description
Vector3

Cross(Vector3, Vector3)

Calculates the cross product of two vectors.

Declaration
public static Vector3 Cross(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

Source vector.

Vector3 vector2

Source vector.

Returns
Type Description
Vector3

Cross(ref Vector3, ref Vector3, out Vector3)

Calculates the cross product of two vectors.

Declaration
public static void Cross(ref Vector3 vector1, ref Vector3 vector2, out Vector3 result)
Parameters
Type Name Description
Vector3 vector1

Source vector.

Vector3 vector2

Source vector.

Vector3 result

[OutAttribute] The cross product of the vectors.

Distance(Vector3, Vector3)

Calculates the distance between two vectors.

Declaration
public static float Distance(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
System.Single

Distance(ref Vector3, ref Vector3, out Single)

Calculates the distance between two vectors.

Declaration
public static void Distance(ref Vector3 value1, ref Vector3 value2, out float result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

System.Single result

[OutAttribute] The distance between the vectors.

DistanceSquared(Vector3, Vector3)

Calculates the distance between two vectors squared.

Declaration
public static float DistanceSquared(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
System.Single

DistanceSquared(ref Vector3, ref Vector3, out Single)

Calculates the distance between two vectors squared.

Declaration
public static void DistanceSquared(ref Vector3 value1, ref Vector3 value2, out float result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

System.Single result

[OutAttribute] The distance between the two vectors squared.

Divide(Single)

Declaration
public void Divide(float divider)
Parameters
Type Name Description
System.Single divider

Divide(Vector3, Single)

Divides a vector by a scalar value.

Declaration
public static Vector3 Divide(Vector3 value1, float value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

System.Single value2

The divisor.

Returns
Type Description
Vector3

Divide(Vector3, Vector3)

Divides the components of a vector by the components of another vector.

Declaration
public static Vector3 Divide(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Divisor vector.

Returns
Type Description
Vector3

Divide(ref Vector3, Single, out Vector3)

Divides a vector by a scalar value.

Declaration
public static void Divide(ref Vector3 value1, float value2, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

System.Single value2

The divisor.

Vector3 result

[OutAttribute] The result of the division.

Divide(ref Vector3, ref Vector3, out Vector3)

Divides the components of a vector by the components of another vector.

Declaration
public static void Divide(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

The divisor.

Vector3 result

[OutAttribute] The result of the division.

DominantAxisProjection(Vector3)

Returns a vector that is equal to the projection of the input vector to the coordinate axis that corresponds to the original vector's largest value.

Declaration
public static Vector3 DominantAxisProjection(Vector3 value1)
Parameters
Type Name Description
Vector3 value1

Source vector.

Returns
Type Description
Vector3

DominantAxisProjection(ref Vector3, out Vector3)

Calculates a vector that is equal to the projection of the input vector to the coordinate axis that corresponds to the original vector's largest value. The result is saved into a user-specified variable.

Declaration
public static void DominantAxisProjection(ref Vector3 value1, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 result

[OutAttribute] The projected vector.

Dot(Vector3)

Declaration
public float Dot(Vector3 v)
Parameters
Type Name Description
Vector3 v
Returns
Type Description
System.Single

Dot(Vector3, Vector3)

Calculates the dot product of two vectors. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse angle between them.

Declaration
public static float Dot(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

Source vector.

Vector3 vector2

Source vector.

Returns
Type Description
System.Single

Dot(ref Vector3)

Declaration
public float Dot(ref Vector3 v)
Parameters
Type Name Description
Vector3 v
Returns
Type Description
System.Single

Dot(ref Vector3, ref Vector3, out Single)

Calculates the dot product of two vectors and writes the result to a user-specified variable. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse angle between them.

Declaration
public static void Dot(ref Vector3 vector1, ref Vector3 vector2, out float result)
Parameters
Type Name Description
Vector3 vector1

Source vector.

Vector3 vector2

Source vector.

System.Single result

[OutAttribute] The dot product of the two vectors.

Equals(Object)

Returns a value that indicates whether the current instance is equal to a specified object.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

Object to make the comparison with.

Returns
Type Description
System.Boolean

Equals(Vector3)

Determines whether the specified Object is equal to the Vector3.

Declaration
public bool Equals(Vector3 other)
Parameters
Type Name Description
Vector3 other

The Vector3 to compare with the current Vector3.

Returns
Type Description
System.Boolean

Equals(Vector3, Single)

Declaration
public bool Equals(Vector3 other, float epsilon)
Parameters
Type Name Description
Vector3 other
System.Single epsilon
Returns
Type Description
System.Boolean

Floor(Vector3)

Declaration
public static Vector3 Floor(Vector3 v)
Parameters
Type Name Description
Vector3 v
Returns
Type Description
Vector3

GetAzimuthAndElevation(Vector3, out Single, out Single)

Declaration
public static void GetAzimuthAndElevation(Vector3 v, out float azimuth, out float elevation)
Parameters
Type Name Description
Vector3 v
System.Single azimuth
System.Single elevation

GetDim(Int32)

Declaration
public float GetDim(int i)
Parameters
Type Name Description
System.Int32 i
Returns
Type Description
System.Single

GetHash()

Gets the hash code of the vector object.

Declaration
public long GetHash()
Returns
Type Description
System.Int64

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

GetNormalized(ref Vector3)

Declaration
public static bool GetNormalized(ref Vector3 value)
Parameters
Type Name Description
Vector3 value
Returns
Type Description
System.Boolean

Hermite(Vector3, Vector3, Vector3, Vector3, Single)

Performs a Hermite spline interpolation.

Declaration
public static Vector3 Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
Parameters
Type Name Description
Vector3 value1

Source position vector.

Vector3 tangent1

Source tangent vector.

Vector3 value2

Source position vector.

Vector3 tangent2

Source tangent vector.

System.Single amount

Weighting factor.

Returns
Type Description
Vector3

Hermite(ref Vector3, ref Vector3, ref Vector3, ref Vector3, Single, out Vector3)

Performs a Hermite spline interpolation.

Declaration
public static void Hermite(ref Vector3 value1, ref Vector3 tangent1, ref Vector3 value2, ref Vector3 tangent2, float amount, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source position vector.

Vector3 tangent1

Source tangent vector.

Vector3 value2

Source position vector.

Vector3 tangent2

Source tangent vector.

System.Single amount

Weighting factor.

Vector3 result

[OutAttribute] The result of the Hermite spline interpolation.

Interpolate3(Vector3, Vector3, Single)

Declaration
public void Interpolate3(Vector3 v0, Vector3 v1, float rt)
Parameters
Type Name Description
Vector3 v0
Vector3 v1
System.Single rt

IsInsideInclusive(ref Vector3, ref Vector3)

Declaration
public bool IsInsideInclusive(ref Vector3 min, ref Vector3 max)
Parameters
Type Name Description
Vector3 min
Vector3 max
Returns
Type Description
System.Boolean

IsUnit(ref Vector3)

Declaration
public static bool IsUnit(ref Vector3 value)
Parameters
Type Name Description
Vector3 value
Returns
Type Description
System.Boolean

IsValid()

Declaration
public bool IsValid()
Returns
Type Description
System.Boolean

IsZero(Vector3)

Declaration
public static bool IsZero(Vector3 value)
Parameters
Type Name Description
Vector3 value
Returns
Type Description
System.Boolean

IsZero(Vector3, Single)

Declaration
public static bool IsZero(Vector3 value, float epsilon)
Parameters
Type Name Description
Vector3 value
System.Single epsilon
Returns
Type Description
System.Boolean

IsZero(ref Vector3)

Declaration
public static bool IsZero(ref Vector3 vec)
Parameters
Type Name Description
Vector3 vec
Returns
Type Description
System.Boolean

IsZeroVector(Vector3)

Declaration
public static Vector3 IsZeroVector(Vector3 value)
Parameters
Type Name Description
Vector3 value
Returns
Type Description
Vector3

IsZeroVector(Vector3, Single)

Declaration
public static Vector3 IsZeroVector(Vector3 value, float epsilon)
Parameters
Type Name Description
Vector3 value
System.Single epsilon
Returns
Type Description
Vector3

Length()

Calculates the length of the vector.

Declaration
public float Length()
Returns
Type Description
System.Single

LengthSquared()

Calculates the length of the vector squared.

Declaration
public float LengthSquared()
Returns
Type Description
System.Single

Lerp(Vector3, Vector3, Single)

Performs a linear interpolation between two vectors.

Declaration
public static Vector3 Lerp(Vector3 value1, Vector3 value2, float amount)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

System.Single amount

Value between 0 and 1 indicating the weight of value2.

Returns
Type Description
Vector3

Lerp(ref Vector3, ref Vector3, Single, out Vector3)

Performs a linear interpolation between two vectors.

Declaration
public static void Lerp(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

System.Single amount

Value between 0 and 1 indicating the weight of value2.

Vector3 result

[OutAttribute] The result of the interpolation.

Max()

Returns the component of the vector that is largest of all the three components.

Declaration
public float Max()
Returns
Type Description
System.Single

Max(Vector3, Vector3)

Returns a vector that contains the highest value from each matching pair of components.

Declaration
public static Vector3 Max(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
Vector3

Max(ref Vector3, ref Vector3, out Vector3)

Returns a vector that contains the highest value from each matching pair of components.

Declaration
public static void Max(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Vector3 result

[OutAttribute] The maximized vector.

MaxAbsComponent()

Keeps only component with maximal absolute, others are set to zero.

Declaration
public Vector3 MaxAbsComponent()
Returns
Type Description
Vector3

Min()

Returns the component of the vector that is smallest of all the three components.

Declaration
public float Min()
Returns
Type Description
System.Single

Min(Vector3, Vector3)

Returns a vector that contains the lowest value from each matching pair of components.

Declaration
public static Vector3 Min(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
Vector3

Min(ref Vector3, ref Vector3, out Vector3)

Returns a vector that contains the lowest value from each matching pair of components.

Declaration
public static void Min(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Vector3 result

[OutAttribute] The minimized vector.

MinMax(ref Vector3, ref Vector3)

Separates minimal and maximal values of any two input vectors

Declaration
public static void MinMax(ref Vector3 min, ref Vector3 max)
Parameters
Type Name Description
Vector3 min

minimal values of the two vectors

Vector3 max

maximal values of the two vectors

Multiply(Single)

Declaration
public void Multiply(float scale)
Parameters
Type Name Description
System.Single scale

Multiply(Vector3, Single)

Multiplies a vector by a scalar value.

Declaration
public static Vector3 Multiply(Vector3 value1, float scaleFactor)
Parameters
Type Name Description
Vector3 value1

Source vector.

System.Single scaleFactor

Scalar value.

Returns
Type Description
Vector3

Multiply(Vector3, Vector3)

Multiplies the components of two vectors by each other.

Declaration
public static Vector3 Multiply(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
Vector3

Multiply(ref Vector3, Single, out Vector3)

Multiplies a vector by a scalar value.

Declaration
public static void Multiply(ref Vector3 value1, float scaleFactor, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

System.Single scaleFactor

Scalar value.

Vector3 result

[OutAttribute] The result of the multiplication.

Multiply(ref Vector3, ref Vector3, out Vector3)

Multiplies the components of two vectors by each other.

Declaration
public static void Multiply(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Vector3 result

[OutAttribute] The result of the multiplication.

Negate(Vector3)

Returns a vector pointing in the opposite direction.

Declaration
public static Vector3 Negate(Vector3 value)
Parameters
Type Name Description
Vector3 value

Source vector.

Returns
Type Description
Vector3

Negate(ref Vector3, out Vector3)

Returns a vector pointing in the opposite direction.

Declaration
public static void Negate(ref Vector3 value, out Vector3 result)
Parameters
Type Name Description
Vector3 value

Source vector.

Vector3 result

[OutAttribute] Vector pointing in the opposite direction.

Normalize()

Turns the current vector into a unit vector. The result is a vector one unit in length pointing in the same direction as the original vector.

Declaration
public float Normalize()
Returns
Type Description
System.Single

Normalize(Vector3)

Creates a unit vector from the specified vector. The result is a vector one unit in length pointing in the same direction as the original vector.

Declaration
public static Vector3 Normalize(Vector3 value)
Parameters
Type Name Description
Vector3 value

The source Vector3.

Returns
Type Description
Vector3

Normalize(ref Vector3, out Vector3)

Creates a unit vector from the specified vector, writing the result to a user-specified variable. The result is a vector one unit in length pointing in the same direction as the original vector.

Declaration
public static void Normalize(ref Vector3 value, out Vector3 result)
Parameters
Type Name Description
Vector3 value

Source vector.

Vector3 result

[OutAttribute] The normalized vector.

Normalize(Vector3D)

Declaration
public static Vector3 Normalize(Vector3D value)
Parameters
Type Name Description
Vector3D value
Returns
Type Description
Vector3

Normalized()

Creates a unit vector from the specified vector. The result is a vector one unit in length pointing in the same direction as the original vector.

Declaration
public Vector3 Normalized()
Returns
Type Description
Vector3

Normalized vector

ProjectOnPlane(ref Vector3, ref Vector3)

Projects given vector on plane specified by it's normal.

Declaration
public static Vector3 ProjectOnPlane(ref Vector3 vec, ref Vector3 planeNormal)
Parameters
Type Name Description
Vector3 vec

Vector which is to be projected

Vector3 planeNormal

Plane normal (may or may not be normalized)

Returns
Type Description
Vector3

Vector projected on plane

ProjectOnVector(ref Vector3, ref Vector3)

Projects vector on another vector resulting in new vector in guided vector's direction with different length.

Declaration
public static Vector3 ProjectOnVector(ref Vector3 vec, ref Vector3 guideVector)
Parameters
Type Name Description
Vector3 vec

Vector which is to be projected

Vector3 guideVector

Guide vector (may or may not be normalized)

Returns
Type Description
Vector3

Vector projected on guide vector

RectangularDistance(Vector3, Vector3)

Calculates rectangular distance (a.k.a. Manhattan distance or Chessboard distace) between two vectors.

Declaration
public static float RectangularDistance(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
System.Single

RectangularDistance(ref Vector3, ref Vector3)

Calculates rectangular distance (a.k.a. Manhattan distance or Chessboard distace) between two vectors.

Declaration
public static float RectangularDistance(ref Vector3 value1, ref Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
System.Single

Reflect(Vector3, Vector3)

Returns the reflection of a vector off a surface that has the specified normal. Reference page contains code sample.

Declaration
public static Vector3 Reflect(Vector3 vector, Vector3 normal)
Parameters
Type Name Description
Vector3 vector

Source vector.

Vector3 normal

Normal of the surface.

Returns
Type Description
Vector3

Reflect(ref Vector3, ref Vector3, out Vector3)

Returns the reflection of a vector off a surface that has the specified normal. Reference page contains code sample.

Declaration
public static void Reflect(ref Vector3 vector, ref Vector3 normal, out Vector3 result)
Parameters
Type Name Description
Vector3 vector

Source vector.

Vector3 normal

Normal of the surface.

Vector3 result

[OutAttribute] The reflected vector.

Reject(Vector3, Vector3)

Returns the rejection of vector from direction, i.e. projection of vector onto the plane defined by origin and direction

Declaration
public static Vector3 Reject(Vector3 vector, Vector3 direction)
Parameters
Type Name Description
Vector3 vector

Vector which is to be rejected

Vector3 direction

Direction from which the input vector will be rejected

Returns
Type Description
Vector3

Rejection of the vector from the given direction

Reject(ref Vector3, ref Vector3, out Vector3)

Returns the rejection of vector from direction, i.e. projection of vector onto the plane defined by origin and direction

Declaration
public static void Reject(ref Vector3 vector, ref Vector3 direction, out Vector3 result)
Parameters
Type Name Description
Vector3 vector

Vector which is to be rejected

Vector3 direction

Direction from which the input vector will be rejected

Vector3 result

Rejection of the vector from the given direction

RotateAndScale(Vector3, Matrix)

Declaration
public static Vector3 RotateAndScale(Vector3 vector, Matrix matrix)
Parameters
Type Name Description
Vector3 vector
Matrix matrix
Returns
Type Description
Vector3

RotateAndScale(ref Vector3, ref Matrix, out Vector3)

Declaration
public static void RotateAndScale(ref Vector3 vector, ref Matrix matrix, out Vector3 result)
Parameters
Type Name Description
Vector3 vector
Matrix matrix
Vector3 result

Round(Vector3)

Declaration
public static Vector3 Round(Vector3 v)
Parameters
Type Name Description
Vector3 v
Returns
Type Description
Vector3

Round(Vector3, Int32)

Declaration
public static Vector3 Round(Vector3 v, int numDecimals)
Parameters
Type Name Description
Vector3 v
System.Int32 numDecimals
Returns
Type Description
Vector3

SetDim(Int32, Single)

Declaration
public void SetDim(int i, float value)
Parameters
Type Name Description
System.Int32 i
System.Single value

Sign(Vector3)

Declaration
public static Vector3 Sign(Vector3 value)
Parameters
Type Name Description
Vector3 value
Returns
Type Description
Vector3

Sign(Vector3, Single)

Declaration
public static Vector3 Sign(Vector3 value, float epsilon)
Parameters
Type Name Description
Vector3 value
System.Single epsilon
Returns
Type Description
Vector3

SignNonZero(Vector3)

Returns per component sign, never returns zero. For zero component returns sign 1. Faster than Sign.

Declaration
public static Vector3 SignNonZero(Vector3 value)
Parameters
Type Name Description
Vector3 value
Returns
Type Description
Vector3

SmoothStep(Vector3, Vector3, Single)

Interpolates between two values using a cubic equation.

Declaration
public static Vector3 SmoothStep(Vector3 value1, Vector3 value2, float amount)
Parameters
Type Name Description
Vector3 value1

Source value.

Vector3 value2

Source value.

System.Single amount

Weighting value.

Returns
Type Description
Vector3

SmoothStep(ref Vector3, ref Vector3, Single, out Vector3)

Interpolates between two values using a cubic equation.

Declaration
public static void SmoothStep(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

System.Single amount

Weighting value.

Vector3 result

[OutAttribute] The interpolated value.

Step(Vector3)

Declaration
public static Vector3 Step(Vector3 value)
Parameters
Type Name Description
Vector3 value
Returns
Type Description
Vector3

Subtract(Vector3, Vector3)

Subtracts a vector from a vector.

Declaration
public static Vector3 Subtract(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
Vector3

Subtract(ref Vector3, ref Vector3, out Vector3)

Subtracts a vector from a vector.

Declaration
public static void Subtract(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Vector3 result

[OutAttribute] The result of the subtraction.

SwapYZCoordinates(Vector3)

Declaration
public static Vector3 SwapYZCoordinates(Vector3 v)
Parameters
Type Name Description
Vector3 v
Returns
Type Description
Vector3

ToString()

Retrieves a string representation of the current object.

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

ToString(String)

Declaration
public string ToString(string format)
Parameters
Type Name Description
System.String format
Returns
Type Description
System.String

Transform(Vector3, Matrix)

Transforms a 3D vector by the given matrix.

Declaration
public static Vector3 Transform(Vector3 position, Matrix matrix)
Parameters
Type Name Description
Vector3 position

The source vector.

Matrix matrix

The transformation matrix.

Returns
Type Description
Vector3

Transform(Vector3, ref Matrix)

Declaration
public static Vector3 Transform(Vector3 position, ref Matrix matrix)
Parameters
Type Name Description
Vector3 position
Matrix matrix
Returns
Type Description
Vector3

Transform(Vector3, MatrixD)

Transforms a 3D vector by the given matrix.

Declaration
public static Vector3D Transform(Vector3 position, MatrixD matrix)
Parameters
Type Name Description
Vector3 position

The source vector.

MatrixD matrix

The transformation matrix.

Returns
Type Description
Vector3D

Transform(Vector3, Quaternion)

Transforms a Vector3 by a specified Quaternion rotation.

Declaration
public static Vector3 Transform(Vector3 value, Quaternion rotation)
Parameters
Type Name Description
Vector3 value

The Vector3 to rotate.

Quaternion rotation

The Quaternion rotation to apply.

Returns
Type Description
Vector3

Transform(ref Vector3, ref Matrix, out Vector3)

Transforms a Vector3 by the given Matrix.

Declaration
public static void Transform(ref Vector3 position, ref Matrix matrix, out Vector3 result)
Parameters
Type Name Description
Vector3 position

The source Vector3.

Matrix matrix

The transformation Matrix.

Vector3 result

[OutAttribute] The transformed vector.

Transform(ref Vector3, ref MatrixI, out Vector3)

Declaration
public static void Transform(ref Vector3 position, ref MatrixI matrix, out Vector3 result)
Parameters
Type Name Description
Vector3 position
MatrixI matrix
Vector3 result

Transform(ref Vector3, ref Quaternion, out Vector3)

Transforms a Vector3 by a specified Quaternion rotation.

Declaration
public static void Transform(ref Vector3 value, ref Quaternion rotation, out Vector3 result)
Parameters
Type Name Description
Vector3 value

The Vector3 to rotate.

Quaternion rotation

The Quaternion rotation to apply.

Vector3 result

[OutAttribute] An existing Vector3 filled in with the results of the rotation.

Transform(Vector3[], Int32, ref Matrix, Vector3[], Int32, Int32)

Applies a specified transform Matrix to a specified range of an array of Vector3s and writes the results into a specified range of a destination array.

Declaration
public static void Transform(Vector3[] sourceArray, int sourceIndex, ref Matrix matrix, Vector3[] destinationArray, int destinationIndex, int length)
Parameters
Type Name Description
Vector3[] sourceArray

The source array.

System.Int32 sourceIndex

The index in the source array at which to start.

Matrix matrix

The transform Matrix to apply.

Vector3[] destinationArray

The existing destination array.

System.Int32 destinationIndex

The index in the destination array at which to start.

System.Int32 length

The number of Vector3s to transform.

Transform(Vector3[], Int32, ref Quaternion, Vector3[], Int32, Int32)

Applies a specified Quaternion rotation to a specified range of an array of Vector3s and writes the results into a specified range of a destination array.

Declaration
public static void Transform(Vector3[] sourceArray, int sourceIndex, ref Quaternion rotation, Vector3[] destinationArray, int destinationIndex, int length)
Parameters
Type Name Description
Vector3[] sourceArray

The source array.

System.Int32 sourceIndex

The index in the source array at which to start.

Quaternion rotation

The Quaternion rotation to apply.

Vector3[] destinationArray

The existing destination array.

System.Int32 destinationIndex

The index in the destination array at which to start.

System.Int32 length

The number of Vector3s to transform.

Transform(Vector3[], ref Matrix, Vector3[])

Transforms a source array of Vector3s by a specified Matrix and writes the results to an existing destination array.

Declaration
public static void Transform(Vector3[] sourceArray, ref Matrix matrix, Vector3[] destinationArray)
Parameters
Type Name Description
Vector3[] sourceArray

The source array.

Matrix matrix

The transform Matrix to apply.

Vector3[] destinationArray

An existing destination array into which the transformed Vector3s are written.

Transform(Vector3[], ref Quaternion, Vector3[])

Transforms a source array of Vector3s by a specified Quaternion rotation and writes the results to an existing destination array.

Declaration
public static void Transform(Vector3[] sourceArray, ref Quaternion rotation, Vector3[] destinationArray)
Parameters
Type Name Description
Vector3[] sourceArray

The source array.

Quaternion rotation

The Quaternion rotation to apply.

Vector3[] destinationArray

An existing destination array into which the transformed Vector3s are written.

TransformNoProjection(ref Vector3, ref Matrix, out Vector3)

Declaration
public static void TransformNoProjection(ref Vector3 vector, ref Matrix matrix, out Vector3 result)
Parameters
Type Name Description
Vector3 vector
Matrix matrix
Vector3 result

TransformNormal(Vector3, Matrix)

Transforms a 3D vector normal by a matrix.

Declaration
public static Vector3 TransformNormal(Vector3 normal, Matrix matrix)
Parameters
Type Name Description
Vector3 normal

The source vector.

Matrix matrix

The transformation matrix.

Returns
Type Description
Vector3

TransformNormal(Vector3, ref Matrix)

Declaration
public static Vector3 TransformNormal(Vector3 normal, ref Matrix matrix)
Parameters
Type Name Description
Vector3 normal
Matrix matrix
Returns
Type Description
Vector3

TransformNormal(Vector3, MatrixD)

Transforms a 3D vector normal by a matrix.

Declaration
public static Vector3 TransformNormal(Vector3 normal, MatrixD matrix)
Parameters
Type Name Description
Vector3 normal

The source vector.

MatrixD matrix

The transformation matrix.

Returns
Type Description
Vector3

TransformNormal(Vector3, MyBlockOrientation)

Declaration
public static Vector3 TransformNormal(Vector3 normal, MyBlockOrientation orientation)
Parameters
Type Name Description
Vector3 normal
MyBlockOrientation orientation
Returns
Type Description
Vector3

TransformNormal(ref Vector3, ref Matrix, out Vector3)

Transforms a vector normal by a matrix.

Declaration
public static void TransformNormal(ref Vector3 normal, ref Matrix matrix, out Vector3 result)
Parameters
Type Name Description
Vector3 normal

The source vector.

Matrix matrix

The transformation Matrix.

Vector3 result

[OutAttribute] The Vector3 resulting from the transformation.

TransformNormal(ref Vector3, ref MatrixD, out Vector3)

Declaration
public static void TransformNormal(ref Vector3 normal, ref MatrixD matrix, out Vector3 result)
Parameters
Type Name Description
Vector3 normal
MatrixD matrix
Vector3 result

TransformNormal(ref Vector3, ref MatrixI, out Vector3)

Declaration
public static void TransformNormal(ref Vector3 normal, ref MatrixI matrix, out Vector3 result)
Parameters
Type Name Description
Vector3 normal
MatrixI matrix
Vector3 result

TransformNormal(ref Vector3, MyBlockOrientation, out Vector3)

Declaration
public static void TransformNormal(ref Vector3 normal, MyBlockOrientation orientation, out Vector3 result)
Parameters
Type Name Description
Vector3 normal
MyBlockOrientation orientation
Vector3 result

TransformNormal(Vector3[], Int32, ref Matrix, Vector3[], Int32, Int32)

Transforms a specified range in an array of 3D vector normals by a specified Matrix and writes the results to a specified range in a destination array.

Declaration
public static void TransformNormal(Vector3[] sourceArray, int sourceIndex, ref Matrix matrix, Vector3[] destinationArray, int destinationIndex, int length)
Parameters
Type Name Description
Vector3[] sourceArray

The source array of Vector3 normals.

System.Int32 sourceIndex

The starting index in the source array.

Matrix matrix

The transform Matrix to apply.

Vector3[] destinationArray

The destination Vector3 array.

System.Int32 destinationIndex

The starting index in the destination array.

System.Int32 length

The number of vectors to transform.

TransformNormal(Vector3[], ref Matrix, Vector3[])

Transforms an array of 3D vector normals by a specified Matrix.

Declaration
public static void TransformNormal(Vector3[] sourceArray, ref Matrix matrix, Vector3[] destinationArray)
Parameters
Type Name Description
Vector3[] sourceArray

The array of Vector3 normals to transform.

Matrix matrix

The transform matrix to apply.

Vector3[] destinationArray

An existing Vector3 array into which the results of the transforms are written.

TransformNormal(Vector3D, Matrix)

Transforms a 3D vector normal by a matrix.

Declaration
public static Vector3 TransformNormal(Vector3D normal, Matrix matrix)
Parameters
Type Name Description
Vector3D normal

The source vector.

Matrix matrix

The transformation matrix.

Returns
Type Description
Vector3

TransformProjection(ref Vector3, ref Matrix, out Vector3)

Transforms a Vector3 by the given projection matrix (both ortho and perspective are supported)

Declaration
public static void TransformProjection(ref Vector3 position, ref Matrix matrix, out Vector3 result)
Parameters
Type Name Description
Vector3 position

The source Vector3.

Matrix matrix

The projection Matrix.

Vector3 result

[OutAttribute] The transformed vector.

TriangleArea(Vector3, Vector3, Vector3)

Declaration
public static float TriangleArea(Vector3 v1, Vector3 v2, Vector3 v3)
Parameters
Type Name Description
Vector3 v1
Vector3 v2
Vector3 v3
Returns
Type Description
System.Single

TriangleArea(ref Vector3, ref Vector3, ref Vector3)

Declaration
public static float TriangleArea(ref Vector3 v1, ref Vector3 v2, ref Vector3 v3)
Parameters
Type Name Description
Vector3 v1
Vector3 v2
Vector3 v3
Returns
Type Description
System.Single

VolumeInt(Single)

Declaration
public long VolumeInt(float multiplier)
Parameters
Type Name Description
System.Single multiplier
Returns
Type Description
System.Int64

Operators

Addition(Vector3, Single)

Declaration
public static Vector3 operator +(Vector3 value1, float value2)
Parameters
Type Name Description
Vector3 value1
System.Single value2
Returns
Type Description
Vector3

Addition(Vector3, Vector3)

Adds two vectors.

Declaration
public static Vector3 operator +(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
Vector3

Division(Single, Vector3)

Declaration
public static Vector3 operator /(float value, Vector3 divider)
Parameters
Type Name Description
System.Single value
Vector3 divider
Returns
Type Description
Vector3

Division(Vector3, Single)

Divides a vector by a scalar value.

Declaration
public static Vector3 operator /(Vector3 value, float divider)
Parameters
Type Name Description
Vector3 value

Source vector.

System.Single divider

The divisor.

Returns
Type Description
Vector3

Division(Vector3, Vector3)

Divides the components of a vector by the components of another vector.

Declaration
public static Vector3 operator /(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Divisor vector.

Returns
Type Description
Vector3

Equality(Vector3, Vector3)

Tests vectors for equality.

Declaration
public static bool operator ==(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
System.Boolean

Inequality(Vector3, Vector3)

Tests vectors for inequality.

Declaration
public static bool operator !=(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Vector to compare.

Vector3 value2

Vector to compare.

Returns
Type Description
System.Boolean

Multiply(Single, Vector3)

Multiplies a vector by a scalar value.

Declaration
public static Vector3 operator *(float scaleFactor, Vector3 value)
Parameters
Type Name Description
System.Single scaleFactor

Scalar value.

Vector3 value

Source vector.

Returns
Type Description
Vector3

Multiply(Vector3, Single)

Multiplies a vector by a scalar value.

Declaration
public static Vector3 operator *(Vector3 value, float scaleFactor)
Parameters
Type Name Description
Vector3 value

Source vector.

System.Single scaleFactor

Scalar value.

Returns
Type Description
Vector3

Multiply(Vector3, Vector3)

Multiplies the components of two vectors by each other.

Declaration
public static Vector3 operator *(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
Vector3

Subtraction(Vector3, Single)

Declaration
public static Vector3 operator -(Vector3 value1, float value2)
Parameters
Type Name Description
Vector3 value1
System.Single value2
Returns
Type Description
Vector3

Subtraction(Vector3, Vector3)

Subtracts a vector from a vector.

Declaration
public static Vector3 operator -(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1

Source vector.

Vector3 value2

Source vector.

Returns
Type Description
Vector3

UnaryNegation(Vector3)

Returns a vector pointing in the opposite direction.

Declaration
public static Vector3 operator -(Vector3 value)
Parameters
Type Name Description
Vector3 value

Source vector.

Returns
Type Description
Vector3

Extension Methods

ColorExtensions.HSVtoColor(Vector3)
ColorExtensions.PackHSVToUint(Vector3)
ColorExtensions.ToLinearRGB(Vector3)
ColorExtensions.ToSRGB(Vector3)
ColorExtensions.ToGray(Vector3)
Vector3Extensions.Project(Vector3, Vector3)
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾