Vector2f

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

Constructors

Vector2f

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

Properties

IsUnitVector

#Since v6.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 v6.0
public bool IsValid { get; }
Returns an indication regarding the validity of this vector.

IsZero

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

Length

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

SquareLength

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

Unset

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

X

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

XAxis

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

Y

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

YAxis

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

Zero

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

Methods

Add

#Since v8.4
public static Point2f Add(Point2f point, Vector2f vector)
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)

point (Point2f)A point.
vector (Vector2f)A vector.
A new point that results from the addition of point and vector.

Add

#Since v8.4
public static Vector2f Add(Vector2f vector1, Vector2f vector2)
Sums up two vectors.

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

vector1 (Vector2f)A vector.
vector2 (Vector2f)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(Vector2f other)
Compares this Vector2f with another Vector2f.

Components evaluation priority is first X, then Y.

other (Vector2f)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.

EpsilonEquals

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

Equals

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

Equals

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

GetHashCode

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

Multiply

#Since v6.0
public static double Multiply(Vector2f point1, Vector2f point2)
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)

point1 (Vector2f)The first point.
point2 (Vector2f)The second point.
A value that results from the coordinate-wise multiplication of point1 and point2.

Negate

#Since v8.4
public static Vector2f Negate(Vector2f vector)
Computes the reversed vector.

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

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

PerpendicularTo

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

Reverse

#Since v8.4
public bool Reverse()
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.

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

ToString

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

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 v8.4
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
Point2f+Vector2fPoint2fSums up a point and a vector, and returns a new point.
Vector2f+Vector2fVector2fComputes the sum between two vectors.
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.
Vector2f-Vector2fVector2fComputes the difference between two vectors.
-Vector2fVector2fComputes the opposite vector.