Vector2d

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

Constructors

Vector2d

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

Properties

IsValid

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

Length

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

SquareLength

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

Unset

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

X

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

Y

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

Zero

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

Methods

Add

#Since v6.0
Sums up two vectors.

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

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

CompareTo

#Since v5.0
Compares this Vector2d with another Vector2d.

Components evaluation priority is first X, then Y.

[ConstOperation] public int CompareTo(
other
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
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)

public static Vector2d Divide(
vector,
A vector.
t
A number.
)
A new vector that is component-wise divided by t.

EpsilonEquals

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

Equals

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

Equals

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

GetHashCode

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

IsTiny

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

IsTiny

#ExampleSince v6.0
Determines whether a vector is very short.
[ConstOperation] public bool IsTiny(
tolerance
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
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)

public static double Multiply(
vector1,
A vector.
vector2
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
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)

public static Vector2d Multiply(
t,
A number.
vector
A vector.
)
A new vector that is the original vector coordinate-wise multiplied by t.

Multiply

#Since v6.0
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)

public static Vector2d Multiply(
vector,
A vector.
t
A number.
)
A new vector that is the original vector coordinate-wise multiplied by t.

Negate

#Since v6.0
Computes the reversed vector.

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

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

Rotate

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

Subtract

#Since v6.0
Subtracts the second vector from the first one.

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

public static Vector2d Subtract(
vector1,
A vector.
vector2
A second vector.
)
A new vector that results from the component-wise difference of vector1 - vector2.
Explicit

IComparable.CompareTo

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

ISerializable.GetObjectData

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

ToString

#
Constructs a string representation of the current vector.
[ConstOperation] public override string ToString()
A string in the form X,Y.

ToString

#Since v7.0
Formats the value of the current instance using the specified format.
[ConstOperation] public string ToString(
format,
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
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
Unitizes the vector in place. A unit vector has length 1 unit.

An invalid or zero length vector cannot be unitized.

public bool Unitize()
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.