Vector2f

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

Constructors

Vector2f

#Since v6.0
Creates an instance.
public Vector2f(
x,
X component.
y
Y component.
)

Properties

IsUnitVector

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

IsValid

#Since v6.0
Returns an indication regarding the validity of this vector.
public bool IsValid { get; }

IsZero

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

Length

#Since v8.4
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.
public double Length { get; }

SquareLength

#Since v6.0
Returns the square of the length of this vector. This method does not check for the validity of its inputs.
public float SquareLength { get; }

Unset

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

X

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

XAxis

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

Y

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

YAxis

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

Zero

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

Methods

Add

#Since v8.4
Sums up a point and a vector, and returns a new point.

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

public static Point2f Add(
point,
A point.
vector
A vector.
)
A new point that results from the addition of point and vector.

Add

#Since v8.4
Sums up two vectors.

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

public static Vector2f 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 Vector2f with another Vector2f.

Components evaluation priority is first X, then Y.

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

#
Divides a Vector2f by a number, having the effect of shrinking it, t times.

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

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

Divide

#
Divides a Vector2f by a number, having the effect of shrinking it, t times.

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

public static Vector2f 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 Vector2f and has the same values as the present vector.
[ConstOperation] public override bool Equals(
obj
The specified object.
)
true if obj is Vector2f and has the same coordinates as this; otherwise false.
ValueType.Equals

Equals

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

GetHashCode

#
Computes a hash number that represents the current vector.
[ConstOperation] public override int GetHashCode()
A hash code that is not unique for each vector.

Multiply

#Since v6.0
Multiplies two Vector2f together, returning the dot (internal) product of the two.

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

public static double Multiply(
point1,
The first point.
point2
The second point.
)
A value that results from the coordinate-wise multiplication of point1 and point2.

Multiply

#
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 Vector2f Multiply(
t,
A number.
vector
A vector.
)
A new vector that is the original vector coordinate-wise multiplied by t.

Multiply

#
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 Vector2f Multiply(
vector,
A vector.
t
A number.
)
A new vector that is the original vector coordinate-wise multiplied by t.

Negate

#Since v8.4
Computes the reversed vector.

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

public static Vector2f Negate(
vector
A vector to negate.
)
Remarks: This is similar to Reverse(), but is static for CLR compliance, and with default name.
A new vector where all components were multiplied by -1.

PerpendicularTo

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

Reverse

#Since v8.4
Reverses this vector in place (reverses the direction).

If this vector contains RhinoMath.UnsetValue, the reverse will also be invalid and false will be returned.

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

Subtract

#Since v8.4
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 Vector2f 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
)

ToString

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

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 v8.4
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
Point2f+Vector2fPoint2fSums up a point and a vector, and returns a new point.
Vector2f+Vector2fVector2fComputes the sum between two vectors.
Vector2f/doubleVector2fDivides a Vector2f by a number, having the effect of shrinking it, t times.
Vector2f/floatVector2fDivides a Vector2f by a number, having the effect of shrinking it, t times.
Vector2f==Vector2fboolDetermines whether two vectors have equal values.
Vector2f>Vector2fboolDetermines whether the first specified vector comes after (has superior sorting value than) the second vector.

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

Vector2f>=Vector2fboolDetermines 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.

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

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

Vector2f<=Vector2fboolDetermines 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.

Vector2f*Vector2fdoubleMultiplies two Vector2f together, returning the dot (internal) product of the two.
float*Vector2fVector2fMultiplies a vector by a number, having the effect of scaling it.
Vector2f*floatVector2fMultiplies a vector by a number, having the effect of scaling it.
Vector2f-Vector2fVector2fComputes the difference between two vectors.
-Vector2fVector2fComputes the opposite vector.