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
Constructs a new vector from 3 single precision numbers.
public Vector3f(
x,
X component of vector.
y,
Y component of vector.
z
Z component of vector.
)

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 v5.0
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 float Length { get; }

SquareLength

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

Unset

#Since v5.0
Gets the value of the vector with each component set to RhinoMath.UnsetValue.
public static Vector3f 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,0.
public static Vector3f XAxis { get; }

Y

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

YAxis

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

Z

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

ZAxis

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

Zero

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

Methods

Add

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

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 Vector3f 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 Vector3f with another Vector3f.

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

[ConstOperation] public int CompareTo(
other
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
Computes the cross product (or vector product, or exterior product) of two vectors.

This operation is not commutative.

public static Vector3f CrossProduct(
a,
First vector.
b
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
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)

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

Divide

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

public static Vector3f 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 Vector3f and has the same values as the present vector.
[ConstOperation] public override bool Equals(
obj
The specified object.
)
true if obj is Vector3f and has the same components 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 vector has the same components 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 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)

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

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

Multiply

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

Rotate

#Since v5.0
Rotates this vector around a given axis.
public bool Rotate(
angleRadians,
Angle of rotation (in radians).
rotationAxis
Axis of rotation.
)
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 Vector3f 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.

Transform

#Since v5.0
Transforms the vector in place.

The transformation matrix acts on the left of the vector; i.e.,

result = transformation*vector

public void Transform(
Transform
transformation
Transformation matrix to apply.
)

Unitize

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