Vector3d

References
Represents the three components of a vector in three-dimensional space, using double-precision floating point numbers.

Constructors

Vector3d

#Since v5.0
public Vector3d(double x, double y, double z)
Initializes a new instance of a vector, using its three components.
x (double)The X (first) component.
y (double)The Y (second) component.
z (double)The Z (third) component.

Vector3d

#Since v5.0
public Vector3d(Point3d point)
Initializes a new instance of a vector, copying the three components from the three coordinates of a point.
point (Point3d)The point to copy from.

Vector3d

#Since v5.0
public Vector3d(Vector3d vector)
Initializes a new instance of a vector, copying the three components from a vector.
vector (Vector3d)A double-precision vector.

Vector3d

#Since v5.0
public Vector3d(Vector3f vector)
Initializes a new instance of a vector, copying the three components from a single-precision vector.
vector (Vector3f)A single-precision vector.

Properties

IsUnitVector

#Since v5.0
public bool IsUnitVector { get; }
Gets a value indicating whether or not this is a unit vector. A unit vector has length 1.

IsValid

#Since v5.0
public bool IsValid { get; }
Gets a value indicating whether this vector is valid. A valid vector must be formed of valid component values for x, y and z.

IsZero

#Since v5.0
public bool IsZero { get; }
Gets a value indicating whether the X, Y, and Z values are all equal to 0.0.

Length

#Since v5.0
public double Length { get; }
Computes the length (or magnitude, or size) of this vector. This is an application of Pythagoras' theorem. If this vector is invalid, its length is considered 0.

MaximumCoordinate

#Since v5.0
public double MaximumCoordinate { get; }
Gets the largest (both positive and negative) component value in this vector, as an absolute value.

MinimumCoordinate

#Since v5.0
public double MinimumCoordinate { get; }
Gets the smallest (both positive and negative) component value in this vector.

SquareLength

#Since v5.0
public double SquareLength { get; }
Computes the squared length (or magnitude, or size) of this vector. This is an application of Pythagoras' theorem. While the Length property checks for input validity, this property does not. You should check validity in advance, if this vector can be invalid.

Unset

#Since v5.0
public static Vector3d Unset { get; }
Gets the value of the vector with each component set to RhinoMath.UnsetValue.

X

#Since v5.0
public double X { get; set; }
Gets or sets the X (first) component of the vector.

XAxis

#Since v5.0
public static Vector3d XAxis { get; }
Gets the value of the vector with components 1,0,0.

Y

#Since v5.0
public double Y { get; set; }
Gets or sets the Y (second) component of the vector.

YAxis

#Since v5.0
public static Vector3d YAxis { get; }
Gets the value of the vector with components 0,1,0.

Z

#Since v5.0
public double Z { get; set; }
Gets or sets the Z (third) component of the vector.

ZAxis

#Since v5.0
public static Vector3d ZAxis { get; }
Gets the value of the vector with components 0,0,1.

Zero

#Since v5.0
public static Vector3d Zero { get; }
Gets the value of the vector with components 0,0,0.

Indexers

this[]

#
public double this[int index] { get; set; }
Gets or sets a vector component at the given index.
index (int)Index of vector component. Valid values are:

0 = X-component

1 = Y-component

2 = Z-component

.

Methods

Add

#Since v5.0
public static Vector3d Add(Vector3d vector1, Vector3d vector2)
Sums up two vectors.

(Provided for languages that do not support operator overloading. You can use the + operator otherwise)

vector1 (Vector3d)A vector.
vector2 (Vector3d)A second vector.
A new vector that results from the component-wise addition of the two vectors.

AreOrthogonal

#Since v6.7
public static bool AreOrthogonal(Vector3d x, Vector3d y, Vector3d z)
Test whether three vectors describe an orthogonal axis system. All vectors must be mutually perpendicular this to be the case.
x (Vector3d)X axis vector.
y (Vector3d)Y axis vector.
z (Vector3d)Z axis vector.
True if all vectors are non-zero and mutually perpendicular.

AreOrthonormal

#Since v6.7
public static bool AreOrthonormal(Vector3d x, Vector3d y, Vector3d z)
Test whether three vectors describe an orthogonal, unit axis system. All vectors must be mutually perpendicular and have unit length for this to be the case.
x (Vector3d)X axis vector.
y (Vector3d)Y axis vector.
z (Vector3d)Z axis vector.
True if all vectors are non-zero and mutually perpendicular.

AreRighthanded

#Since v6.7
public static bool AreRighthanded(Vector3d x, Vector3d y, Vector3d z)
Test whether three vectors describe a right-handed, orthogonal, unit axis system. The vectors must be orthonormal and follow the right-hand ordering; index-finger=x, middle-finger=y, thumb=z.
x (Vector3d)X axis vector.
y (Vector3d)Y axis vector.
z (Vector3d)Z axis vector.
True if all vectors are non-zero and mutually perpendicular.

CompareTo

#Since v5.0
[ConstOperation] public int CompareTo(Vector3d other)
Compares this Vector3d with another Vector3d.

Component evaluation priority is first X, then Y, then Z.

other (Vector3d)The other Vector3d to use in comparison.

0: if this is identical to other

-1: if this.X < other.X

-1: if this.X == other.X and this.Y < other.Y

-1: if this.X == other.X and this.Y == other.Y and this.Z < other.Z

+1: otherwise.

CrossProduct

#Since v5.0
public static Vector3d CrossProduct(Vector3d a, Vector3d b)
Computes the cross product (or vector product, or exterior product) of two vectors.

This operation is not commutative.

a (Vector3d)First vector.
b (Vector3d)Second vector.
A new vector that is perpendicular to both a and b,

has Length == a.Length * b.Length * sin(theta) where theta is the angle between a and b.

The resulting vector is oriented according to the right hand rule.

Decompose

#Since v9.0
public static bool Decompose(Vector3d v, Vector3d a, Vector3d b, out double x, out double y)
Find scalars x and y so that the component of v in the plane of a and b is x*a + y*b
v (Vector3d)
a (Vector3d)non-zero and not parallel to b
b (Vector3d)non-zero and not parallel to a
x (out double)
y (out double)
true if the decomposition is successful.

Divide

#Since v5.0
public static Vector3d Divide(Vector3d vector, double t)
Divides a Vector3d by a number, having the effect of shrinking it.

(Provided for languages that do not support operator overloading. You can use the / operator otherwise)

vector (Vector3d)A vector.
t (double)A number.
A new vector that is component-wise divided by t.

EpsilonEquals

#Since v5.4
[ConstOperation] public bool EpsilonEquals(Vector3d other, double epsilon)
Check that all values in other are within epsilon of the values in this
other (Vector3d)
epsilon (double)
EpsilonEquals

Equals

#
[ConstOperation] public override bool Equals(object obj)
Determines whether the specified System.Object is a Vector3d and has the same values as the present vector.
obj (object)The specified object.
true if obj is a Vector3d and has the same coordinates as this; otherwise false.
ValueType.Equals

Equals

#Since v5.0
[ConstOperation] public bool Equals(Vector3d vector)
Determines whether the specified vector has the same value as the present vector.
vector (Vector3d)The specified vector.
true if vector has the same coordinates as this; otherwise false.

GetHashCode

#
[ConstOperation] public override int GetHashCode()
Computes the hash code for the current vector.
A non-unique number that represents the components of this vector.

IsParallelTo

#Since v5.0
[ConstOperation] public int IsParallelTo(Vector3d other, double angleTolerance)
Determines whether this vector is parallel to another vector, within a provided tolerance.
other (Vector3d)Vector to use for comparison.
angleTolerance (double)Angle tolerance (in radians).
Parallel indicator:

+1 = both vectors are parallel.

0 = vectors are not parallel or at least one of the vectors is zero.

-1 = vectors are anti-parallel.

IsParallelTo

#ExampleSince v5.0
[ConstOperation] public int IsParallelTo(Vector3d other)
Determines whether this vector is parallel to another vector, within one degree (within Pi / 180).
other (Vector3d)Vector to use for comparison.
Parallel indicator:

+1 = both vectors are parallel

0 = vectors are not parallel, or at least one of the vectors is zero

-1 = vectors are anti-parallel.

IsPerpendicularTo

#Since v5.0
[ConstOperation] public bool IsPerpendicularTo(Vector3d other, double angleTolerance)
Determines whether this vector is perpendicular to another vector, within a provided angle tolerance.
other (Vector3d)Vector to use for comparison.
angleTolerance (double)Angle tolerance (in radians).
true if vectors form Pi-radians (90-degree) angles with each other; otherwise false.

IsPerpendicularTo

#Since v5.0
[ConstOperation] public bool IsPerpendicularTo(Vector3d other)
Test to see whether this vector is perpendicular to within one degree of another one.
other (Vector3d)Vector to compare to.
true if both vectors are perpendicular, false if otherwise.

IsTiny

#Since v5.0
public bool IsTiny()
Uses RhinoMath.ZeroTolerance for IsTiny calculation.
true if vector is very small, otherwise false.

IsTiny

#ExampleSince v5.0
public bool IsTiny(double tolerance)
Determines whether a vector is very short.
tolerance (double)A nonzero value used as the coordinate zero tolerance. .
(Math.Abs(X) <= tiny_tol) AND (Math.Abs(Y) <= tiny_tol) AND (Math.Abs(Z) <= tiny_tol).

Multiply

#Since v5.0
public static double Multiply(Vector3d vector1, Vector3d vector2)
Multiplies two vectors together, returning the dot product (or inner product). This differs from the cross product.

(Provided for languages that do not support operator overloading. You can use the * operator otherwise)

vector1 (Vector3d)A vector.
vector2 (Vector3d)A second vector.
A value that results from the evaluation of v1.X*v2.X + v1.Y*v2.Y + v1.Z*v2.Z.

This value equals v1.Length * v2.Length * cos(alpha), where alpha is the angle between vectors.

Multiply

#Since v5.0
public static Vector3d Multiply(double t, Vector3d vector)
Multiplies a vector by a number, having the effect of scaling it.

(Provided for languages that do not support operator overloading. You can use the * operator otherwise)

t (double)A number.
vector (Vector3d)A vector.
A new vector that is the original vector coordinate-wise multiplied by t.

Multiply

#Since v5.0
public static Vector3d Multiply(Vector3d vector, double t)
Multiplies a vector by a number, having the effect of scaling it.

(Provided for languages that do not support operator overloading. You can use the * operator otherwise)

vector (Vector3d)A vector.
t (double)A number.
A new vector that is the original vector coordinate-wise multiplied by t.

Negate

#Since v5.0
public static Vector3d Negate(Vector3d vector)
Computes the reversed vector.

(Provided for languages that do not support operator overloading. You can use the - unary operator otherwise)

Remarks: Similar to Reverse(), but static for CLR compliance.
vector (Vector3d)A vector to negate.
A new vector where all components were multiplied by -1.

PerpendicularTo

#Since v8.0
public bool PerpendicularTo(Point3d point0, Point3d point1, Point3d point2)
Set this vector to be perpendicular to a plane defined by 3 points.
point0 (Point3d)The first point.
point1 (Point3d)The second point.
point2 (Point3d)The third point.

PerpendicularTo

#Since v5.0
public bool PerpendicularTo(Vector3d other)
Sets this vector to be perpendicular to another vector. Result is not unitized.
other (Vector3d)Vector to use as guide.
true on success, false if input vector is zero or invalid.

Reverse

#Since v5.0
public bool Reverse()
Reverses this vector in place (reverses the direction).

If this vector is Invalid, no changes will occur and false will be returned.

Remarks: Similar to Negate, that is only provided for CLR language compliance.
true on success or false if the vector is invalid.

Rotate

#Since v5.0
public bool Rotate(double angleRadians, Vector3d rotationAxis)
Rotates this vector around a given axis.
angleRadians (double)Angle of rotation (in radians).
rotationAxis (Vector3d)Axis of rotation.
true on success, false on failure.

Subtract

#Since v5.0
public static Vector3d Subtract(Vector3d vector1, Vector3d vector2)
Subtracts the second vector from the first one.

(Provided for languages that do not support operator overloading. You can use the - operator otherwise)

vector1 (Vector3d)A vector.
vector2 (Vector3d)A second vector.
A new vector that results from the component-wise difference of vector1 - vector2.
Explicit

ICloneable.Clone

#
Explicit

IComparable.CompareTo

#
[ConstOperation] int IComparable.CompareTo(object obj)
obj (object)
Explicit

ISerializable.GetObjectData

#
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
info (SerializationInfo)
context (StreamingContext)

ToString

#
[ConstOperation] public override string ToString()
Returns the string representation of the current vector, in the form X,Y,Z.
A string with the current location of the point.

ToString

#Since v7.0
[ConstOperation] public string ToString(string format, IFormatProvider formatProvider)
Formats the value of the current instance using the specified format.
format (string)The format to use. -or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.
formatProvider (IFormatProvider)The provider to use to format the value. -or- A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
The value of the current instance in the specified format.

Transform

#Since v5.0
public void Transform(Transform transformation)
Transforms the vector in place.

The transformation matrix acts on the left of the vector; i.e.,

result = transformation*vector

transformation (Transform)Transformation matrix to apply.

Unitize

#Since v5.0
public bool Unitize()
Unitizes the vector in place. A unit vector has length 1 unit.

An invalid or zero length vector cannot be unitized.

true on success or false on failure.

VectorAngle

#Since v5.0
public static double VectorAngle(Vector3d a, Vector3d b, Plane plane)
Computes the angle on a plane between two vectors.
a (Vector3d)First vector.
b (Vector3d)Second vector.
plane (Plane)Two-dimensional plane on which to perform the angle measurement.
On success, the angle (in radians) between a and b as projected onto the plane; RhinoMath.UnsetValue on failure.

VectorAngle

#Since v5.0
public static double VectorAngle(Vector3d a, Vector3d b)
Compute the angle between two vectors.

This operation is commutative.

a (Vector3d)First vector for angle.
b (Vector3d)Second vector for angle.
If the input is valid, the angle (in radians) between a and b; RhinoMath.UnsetValue otherwise.

VectorAngle

#Since v6.0
public static double VectorAngle(Vector3d v1, Vector3d v2, Vector3d vNormal)
Computes the angle of v1, v2 with a normal vector.
v1 (Vector3d)First vector.
v2 (Vector3d)Second vector.
vNormal (Vector3d)Normal vector.
On success, the angle (in radians) between a and b with respect of normal vector; RhinoMath.UnsetValue on failure.

Operators

OperationResultDescription
Vector3d+Vector3dVector3dSums up two vectors.
Vector3d/doubleVector3dDivides a Vector3d by a number, having the effect of shrinking it.
Vector3d==Vector3dboolDetermines whether two vectors have the same value.
Vector3d>Vector3dboolDetermines whether the first specified vector comes after (has superior sorting value than) the second vector.

Components evaluation priority is first X, then Y, then Z.

Vector3d>=Vector3dboolDetermines whether the first specified vector comes after (has superior sorting value than) the second vector, or it is equal to it.

Components evaluation priority is first X, then Y, then Z.

Vector3d!=Vector3dboolDetermines whether two vectors have different values.
Vector3d<Vector3dboolDetermines whether the first specified vector comes before (has inferior sorting value than) the second vector.

Components evaluation priority is first X, then Y, then Z.

Vector3d<=Vector3dboolDetermines whether the first specified vector comes before (has inferior sorting value than) the second vector, or it is equal to it.

Components evaluation priority is first X, then Y, then Z.

Vector3d*Vector3ddoubleMultiplies two vectors together, returning the dot product (or inner product). This differs from the cross product.
double*Vector3dVector3dMultiplies a vector by a number, having the effect of scaling it.
Vector3d*doubleVector3dMultiplies a vector by a number, having the effect of scaling it.
Vector3d-Vector3dVector3dSubtracts the second vector from the first one.
-Vector3dVector3dComputes the opposite vector.

Convertors

OperationResultDescription
implicitVector3fVector3dConverts a single-precision (float) vector in a double-precision vector, without needing casting.