Vector3f

References
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 12)] [DebuggerDisplay("({m_x}, {m_y}, {m_z})")] [Serializable] public struct Vector3f : IEquatable<Vector3f>, IComparable<Vector3f>, IComparable, IEpsilonFComparable<Vector3f>, IFormattable
Represents the three components of a vector in three-dimensional space, using float-precision floating point numbers.

Constructors

Vector3f

#Since v5.0
public Vector3f(float x, float y, float z)
Constructs a new vector from 3 single precision numbers.
x (float)X component of vector.
y (float)Y component of vector.
z (float)Z component of vector.

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 v5.0
public float 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 length of the vector. This property does not check for the validity of the inputs.

Unset

#Since v5.0
public static Vector3f 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 Vector3f XAxis { get; }
Gets the value of the vector with components 1,0,0.

Y

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

YAxis

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

Z

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

ZAxis

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

Zero

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

Methods

Add

#Since v5.0
public static Point3f Add(Point3f point, Vector3f 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 (Point3f)A point.
vector (Vector3f)A vector.
A new point that results from the addition of point and vector.

Add

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

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

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

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

other (Vector3f)The other Vector3f 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 Vector3f CrossProduct(Vector3f a, Vector3f b)
Computes the cross product (or vector product, or exterior product) of two vectors.

This operation is not commutative.

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

has Length == a.Length * b.Length and

with a result that is oriented following the right hand rule.

Divide

#Since v6.0
public static Vector3f Divide(Vector3f vector, double t)
Divides a Vector3f 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)

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

Divide

#Since v6.0
public static Vector3f Divide(Vector3f vector, float t)
Divides a Vector3f 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)

vector (Vector3f)A vector.
t (float)A number.
A new vector that is component-wise divided by t.

EpsilonEquals

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

Equals

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

Equals

#Since v5.0
[ConstOperation] public bool Equals(Vector3f vector)
Determines whether the specified vector has the same values as the present vector.
vector (Vector3f)The specified vector.
true if vector has the same components 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(Vector3f point1, Vector3f point2)
Multiplies two Vector3f together, returning the dot (internal) product of the two. This is not the cross product.

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

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

Multiply

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

Multiply

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

Negate

#Since v6.0
public static Vector3f Negate(Vector3f 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 (Vector3f)A vector to negate.
A new vector where all components were multiplied by -1.

PerpendicularTo

#Since v5.0
[ConstOperation] public bool PerpendicularTo(Vector3f other)
Sets this vector to be perpendicular to another vector. Result is not unitized.
other (Vector3f)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 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.

Rotate

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

Subtract

#Since v6.0
public static Vector3f Subtract(Vector3f vector1, Vector3f 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 (Vector3f)A vector.
vector2 (Vector3f)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.

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.

Operators

OperationResultDescription
Point3f+Vector3fPoint3fSums up a point and a vector, and returns a new point.
Vector3f+Vector3fVector3fSums up two vectors.
Vector3f/doubleVector3fDivides a Vector3f by a number, having the effect of shrinking it, t times.
Vector3f/floatVector3fDivides a Vector3f by a number, having the effect of shrinking it, t times.
Vector3f==Vector3fboolDetermines whether two vectors have equal values.
Vector3f>Vector3fboolDetermines 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.

Vector3f>=Vector3fboolDetermines 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.

Vector3f!=Vector3fboolDetermines whether two vectors have different values.
Vector3f<Vector3fboolDetermines 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.

Vector3f<=Vector3fboolDetermines 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.

Vector3f*Vector3fdoubleMultiplies two Vector3f together, returning the dot (internal) product of the two. This is not the cross product.
float*Vector3fVector3fMultiplies a vector by a number, having the effect of scaling it.
Vector3f*floatVector3fMultiplies a vector by a number, having the effect of scaling it.
Vector3f-Vector3fVector3fSubtracts the second vector from the first one.
-Vector3fVector3fComputes the opposite vector.

Convertors

OperationResultDescription
explicitVector3dVector3fConverts a double-precision vector in a single-precision vector. Needs explicit casting to help retain precision.