Vector2d

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

Constructors

Vector2d

#Since v5.0
public Vector2d(double x, double y)
Initializes a new instance of the vector based on two, X and Y, components.
x (double)The X (first) component.
y (double)The Y (second) component.

Properties

IsValid

#Since v5.7
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.

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.

SquareLength

#Since v6.0
public double SquareLength { get; }
Returns the square of the length of the vector.

Unset

#Since v5.0
public static Vector2d Unset { get; }
Gets the value of the vector with components set as RhinoMath.UnsetValue,RhinoMath.UnsetValue.

X

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

Y

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

Zero

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

Methods

Add

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

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

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

CompareTo

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

Components evaluation priority is first X, then Y.

other (Vector2d)The other Vector2d 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: otherwise.

Divide

#Since v6.0
public static Vector2d Divide(Vector2d vector, double t)
Divides a Vector2d 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 (Vector2d)A vector.
t (double)A number.
A new vector that is component-wise divided by t.

EpsilonEquals

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

Equals

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

Equals

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

GetHashCode

#
[ConstOperation] public override int GetHashCode()
Provides a hashing value for the present vector.
A non-unique number based on vector components.

IsTiny

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

IsTiny

#ExampleSince v6.0
[ConstOperation] 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 v6.0
public static double Multiply(Vector2d vector1, Vector2d vector2)
Multiplies two vectors together, returning the dot product (or inner product).

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

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

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

Multiply

#Since v6.0
public static Vector2d Multiply(double t, Vector2d 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 (Vector2d)A vector.
A new vector that is the original vector coordinate-wise multiplied by t.

Multiply

#Since v6.0
public static Vector2d Multiply(Vector2d 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 (Vector2d)A vector.
t (double)A number.
A new vector that is the original vector coordinate-wise multiplied by t.

Negate

#Since v6.0
public static Vector2d Negate(Vector2d vector)
Computes the reversed vector.

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

vector (Vector2d)A vector to negate.
A new vector where all components were multiplied by -1.

Rotate

#Since v6.0
public bool Rotate(double angleRadians)
Rotates this vector.
angleRadians (double)Angle of rotation (in radians).
true on success, false on failure.

Subtract

#Since v6.0
public static Vector2d Subtract(Vector2d vector1, Vector2d 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 (Vector2d)A vector.
vector2 (Vector2d)A second vector.
A new vector that results from the component-wise difference of vector1 - vector2.
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()
Constructs a string representation of the current vector.
A string in the form X,Y.

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.

Unitize

#Since v5.7
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.

Operators

OperationResultDescription
Vector2d+Vector2dVector2dSums up two vectors.
Vector2d/doubleVector2dDivides a Vector2d by a number, having the effect of shrinking it.
Vector2d==Vector2dboolDetermines whether two vectors have equal values.
Vector2d>Vector2dboolDetermines whether the first specified vector comes after (has superior sorting value than) the second vector.

Components have decreasing evaluation priority: first X, then Y.

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

Components have decreasing evaluation priority: first X, then Y.

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

Components have decreasing evaluation priority: first X, then Y.

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

Components have decreasing evaluation priority: first X, then Y.

Vector2d*Vector2ddoubleMultiplies two vectors together, returning the dot product (or inner product).
double*Vector2dVector2dMultiplies a vector by a number, having the effect of scaling it.
Vector2d*doubleVector2dMultiplies a vector by a number, having the effect of scaling it.
Vector2d-Vector2dVector2dSubtracts the second vector from the first one.
-Vector2dVector2dComputes the opposite vector.