Generated by DocFX

Struct Vector3

Defines a Vector in Euclidean space with coordinates X, Y, and Z. Referenced from https://github.com/mcneel/rhinocommon/blob/master/dotnet/opennurbs/opennurbs_point.cs

Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Syntax
public struct Vector3 : IEquatable<Vector3>, IComparable<Vector3>, IComparable

Constructors

| Improve this Doc View Source

Vector3(Point3)

Initializes a new instance of a vector, copying the three components from the three coordinates of a point.

Declaration
public Vector3(Point3 point)
Parameters
Type Name Description
Point3 point

The point to copy from.

| Improve this Doc View Source

Vector3(Vector3)

Initializes a new instance of a vector, copying the three components from a vector.

Declaration
public Vector3(Vector3 vector)
Parameters
Type Name Description
Vector3 vector

A double-precision vector.

| Improve this Doc View Source

Vector3(Double, Double, Double)

Initializes a new instance of a vector, using its three components.

Declaration
public Vector3(double x, double y, double z)
Parameters
Type Name Description
System.Double x

The X (first) component.

System.Double y

The Y (second) component.

System.Double z

The Z (third) component.

Properties

| Improve this Doc View Source

IsUnitVector

Gets a value indicating whether or not this is a unit vector. A unit vector has length 1.

Declaration
public readonly bool IsUnitVector { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsValid

Gets a value indicating whether this vector is valid. A valid vector must be formed of valid component values for x, y and z.

Declaration
public readonly bool IsValid { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsZero

Gets a value indicating whether the X, Y, and Z values are all equal to 0.0.

Declaration
public readonly bool IsZero { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Item[Int32]

Declaration
public double this[int i] { get; set; }
Parameters
Type Name Description
System.Int32 i
Property Value
Type Description
System.Double
| Improve this Doc View Source

Length

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.

Declaration
public readonly double Length { get; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

Size

Dimension of vector.

Declaration
public readonly int Size { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

SquareLength

Computes the squared length (or magnitude, or size) of this vector. This is an application of Pythagoras' theorem. While the Length property checks for input validity, this property does not. You should check validity in advance, if this vector can be invalid.

Declaration
public readonly double SquareLength { get; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

Unset

Gets the value of the vector with each component set to GeoSharkMath.UNSET_VALUE.

Declaration
public static readonly Vector3 Unset { get; }
Property Value
Type Description
Vector3
| Improve this Doc View Source

X

Gets or sets the X (first) component of the vector.

Declaration
public double X { readonly get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

XAxis

Gets the value of the vector with components 1,0,0.

Declaration
public static readonly Vector3 XAxis { get; }
Property Value
Type Description
Vector3
| Improve this Doc View Source

Y

Gets or sets the Y (second) component of the vector.

Declaration
public double Y { readonly get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

YAxis

Gets the value of the vector with components 0,1,0.

Declaration
public static readonly Vector3 YAxis { get; }
Property Value
Type Description
Vector3
| Improve this Doc View Source

Z

Gets or sets the Z (third) component of the vector.

Declaration
public double Z { readonly get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

ZAxis

Gets the value of the vector with components 0,0,1.

Declaration
public static readonly Vector3 ZAxis { get; }
Property Value
Type Description
Vector3
| Improve this Doc View Source

Zero

Gets the value of the vector with components 0,0,0.

Declaration
public static readonly Vector3 Zero { get; }
Property Value
Type Description
Vector3

Methods

| Improve this Doc View Source

Amplify(Double)

Gets a new amplified vector by unitizing and uniformly scaling this vector by the amplitude value.

Declaration
public Vector3 Amplify(double amplitude)
Parameters
Type Name Description
System.Double amplitude

The scalar value to amplify the vector.

Returns
Type Description
Vector3

The amplified vector.

| Improve this Doc View Source

CompareTo(Vector3)

Compares this Vector3 with another Vector3.

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

Declaration
public int CompareTo(Vector3 other)
Parameters
Type Name Description
Vector3 other

The other Vector3 to use in comparison.

Returns
Type Description
System.Int32

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.

| Improve this Doc View Source

CrossProduct(Vector3, Vector3)

Computes the cross product (or vector product, or exterior product) of two vectors.

This operation is not commutative.

Declaration
public static Vector3 CrossProduct(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

First vector.

Vector3 b

Second vector.

Returns
Type Description
Vector3

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.

| Improve this Doc View Source

DotProduct(Vector3, Vector3)

Computes the dot product between two vectors.

Declaration
public static double DotProduct(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The first vector.

Vector3 vector2

The second vector with which compute the dot product.

Returns
Type Description
System.Double

The dot product.

| Improve this Doc View Source

EpsilonEquals(Vector3, Double)

Declaration
public bool EpsilonEquals(Vector3 vector, double epsilon)
Parameters
Type Name Description
Vector3 vector
System.Double epsilon
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Equals(Vector3)

Determines whether the specified vector has the same value as the present vector.

Declaration
public bool Equals(Vector3 vector)
Parameters
Type Name Description
Vector3 vector

The specified vector.

Returns
Type Description
System.Boolean

true if vector has the same coordinates as this; otherwise false.

| Improve this Doc View Source

Equals(Object)

Determines whether the specified System.Object is a Vector3d and has the same values as the present vector.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The specified object.

Returns
Type Description
System.Boolean

true if obj is a Vector3d and has the same coordinates as this; otherwise false.

Overrides
System.ValueType.Equals(System.Object)
| Improve this Doc View Source

GetHashCode()

Computes the hash code for the current vector.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

A non-unique number that represents the components of this vector.

Overrides
System.ValueType.GetHashCode()
| Improve this Doc View Source

IsParallelTo(Vector3, Double)

Determines whether this vector is parallel to another vector, within a provided tolerance.

Declaration
public int IsParallelTo(Vector3 other, double angleTolerance = 0.0174532925199433)
Parameters
Type Name Description
Vector3 other

Vector to use for comparison.

System.Double angleTolerance

Angle tolerance (in radians).

Returns
Type Description
System.Int32

Parallel indicator:

+1 = both vectors are parallel.

0 = vectors are not parallel or at least one of the vectors is zero.

-1 = vectors are anti-parallel.

| Improve this Doc View Source

IsPerpendicularTo(Vector3, Double)

Determines whether this vector is perpendicular to another vector, within a provided angle tolerance.

Declaration
public bool IsPerpendicularTo(Vector3 other, double angleTolerance = 0.0174532925199433)
Parameters
Type Name Description
Vector3 other

Vector to use for comparison.

System.Double angleTolerance

Angle tolerance (in radians).

Returns
Type Description
System.Boolean

true if vectors form Pi-radians (90-degree) angles with each other; otherwise false.

| Improve this Doc View Source

PerpendicularTo(Point3, Point3, Point3)

Computes the perpendicular of a vector given three points.
Result is not unitized.

Declaration
public Vector3 PerpendicularTo(Point3 pt1, Point3 pt2, Point3 pt3)
Parameters
Type Name Description
Point3 pt1

First point.

Point3 pt2

Second point.

Point3 pt3

Third point.

Returns
Type Description
Vector3

The perpendicular vector.

| Improve this Doc View Source

PerpendicularTo(Vector3)

Computes the perpendicular to another vector.
https://stackoverflow.com/questions/11132681/what-is-a-formula-to-get-a-vector-perpendicular-to-another-vector
Result is not unitized.

Declaration
public static Vector3 PerpendicularTo(Vector3 vector)
Parameters
Type Name Description
Vector3 vector

The other vector.

Returns
Type Description
Vector3

The perpendicular vector.

| Improve this Doc View Source

Reverse()

Reverses (inverts) this vector in place.

If this vector is Invalid, no changes will occur and false will be returned.

Declaration
public Vector3 Reverse()
Returns
Type Description
Vector3

Returns a reversed vector on success or Vector3d.Unset if the vector is invalid.

| Improve this Doc View Source

Rotate(Vector3, Double)

Rotates this vector around a given axis.
The rotation is computed using Rodrigues Rotation formula.
https://handwiki.org/wiki/Rodrigues%27_rotation_formula

Declaration
public Vector3 Rotate(Vector3 axis, double radiansAngle)
Parameters
Type Name Description
Vector3 axis

Axis of rotation.

System.Double radiansAngle

Angle of rotation (in radians).

Returns
Type Description
Vector3

Rotated vector.

| Improve this Doc View Source

ToString()

Returns the string representation of the current vector, in the form X,Y,Z.

Declaration
public override string ToString()
Returns
Type Description
System.String

A string with the current location of the point.

Overrides
System.ValueType.ToString()
| Improve this Doc View Source

TripleProduct(Vector3, Vector3)

The triple product of this vector and the two specified vectors.

Declaration
public double TripleProduct(Vector3 middle, Vector3 right)
Parameters
Type Name Description
Vector3 middle

The second vector.

Vector3 right

The third vector.

Returns
Type Description
System.Double

The real number equal to the triple product.

Remarks

The scalar triple product is defined as the dot product of one of the vectors with the cross product of the other two. Geometrically, this product is the (signed) volume of the parallelepiped formed by the three vectors given.

| Improve this Doc View Source

Unitize()

Unitizes the vector. A unit vector has length 1 unit.

Declaration
public Vector3 Unitize()
Returns
Type Description
Vector3

A new vector unitized.

| Improve this Doc View Source

VectorAngle(Vector3, Vector3)

Compute the angle in radians between two vectors.
This operation is commutative.

Declaration
public static double VectorAngle(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

First vector for angle.

Vector3 b

Second vector for angle.

Returns
Type Description
System.Double

If the input is valid, the angle in radians between a and b; GeoSharkMath.UNSET_VALUE otherwise.

| Improve this Doc View Source

VectorAngleOnPlane(Vector3, Vector3, Plane, out Double)

Computes the angle in radians on a plane between two vectors.

Declaration
public static double VectorAngleOnPlane(Vector3 a, Vector3 b, Plane plane, out double reflexAngle)
Parameters
Type Name Description
Vector3 a

First vector.

Vector3 b

Second vector.

Plane plane

Two-dimensional plane on which to perform the angle measurement.

System.Double reflexAngle
Returns
Type Description
System.Double

On success, the angle (in radians) between a and b as projected onto the plane; GeoSharkMath.UNSET_VALUE on failure.

Operators

| Improve this Doc View Source

Addition(Vector3, Vector3)

Sums up two vectors.

Declaration
public static Vector3 operator +(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

A vector.

Vector3 vector2

A second vector.

Returns
Type Description
Vector3

A new vector that results from the componentwise addition of the two vectors.

| Improve this Doc View Source

Division(Vector3, Double)

Divides a Vector3 by a number, having the effect of shrinking it.

Declaration
public static Vector3 operator /(Vector3 vector, double t)
Parameters
Type Name Description
Vector3 vector

A vector.

System.Double t

A number.

Returns
Type Description
Vector3

A new vector that is componentwise divided by t.

| Improve this Doc View Source

Equality(Vector3, Vector3)

Determines whether two vectors have the same value.

Declaration
public static bool operator ==(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

A vector.

Vector3 b

Another vector.

Returns
Type Description
System.Boolean

true if all coordinates are pairwise equal; false otherwise.

| Improve this Doc View Source

GreaterThan(Vector3, Vector3)

Determines 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.

Declaration
public static bool operator>(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

The first vector.

Vector3 b

The second vector.

Returns
Type Description
System.Boolean

true if a.X is larger than b.X, or a.X == b.X and a.Y is larger than b.Y, or a.X == b.X and a.Y == b.Y and a.Z is larger than b.Z; otherwise, false.

| Improve this Doc View Source

GreaterThanOrEqual(Vector3, Vector3)

Determines 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.

Declaration
public static bool operator >=(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

The first vector.

Vector3 b

The second vector.

Returns
Type Description
System.Boolean

true if a.X is larger than b.X, or a.X == b.X and a.Y is larger than b.Y, or a.X == b.X and a.Y == b.Y and a.Z >= b.Z; otherwise, false.

| Improve this Doc View Source

Implicit(Vector3 to Point3)

Converts a vector3d in a point3d, without needing casting.

Declaration
public static implicit operator Point3(Vector3 vector3d)
Parameters
Type Name Description
Vector3 vector3d

A Vector3d.

Returns
Type Description
Point3

The resulting Point3d.

| Improve this Doc View Source

Implicit(Vector3 to Vector)

Converts a vector3d in a vector3, without needing casting.

Declaration
public static implicit operator Vector(Vector3 vector3d)
Parameters
Type Name Description
Vector3 vector3d

A Vector3d.

Returns
Type Description
Vector

The resulting Vector3.

| Improve this Doc View Source

Inequality(Vector3, Vector3)

Determines whether two vectors have different values.

Declaration
public static bool operator !=(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

A vector.

Vector3 b

Another vector.

Returns
Type Description
System.Boolean

true if any coordinate pair is different; false otherwise.

| Improve this Doc View Source

LessThan(Vector3, Vector3)

Determines 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.

Declaration
public static bool operator <(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

The first vector.

Vector3 b

The second vector.

Returns
Type Description
System.Boolean

true if a.X is smaller than b.X, or a.X == b.X and a.Y is smaller than b.Y, or a.X == b.X and a.Y == b.Y and a.Z is smaller than b.Z; otherwise, false.

| Improve this Doc View Source

LessThanOrEqual(Vector3, Vector3)

Determines 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.

Declaration
public static bool operator <=(Vector3 a, Vector3 b)
Parameters
Type Name Description
Vector3 a

The first vector.

Vector3 b

The second vector.

Returns
Type Description
System.Boolean

true if a.X is smaller than b.X, or a.X == b.X and a.Y is smaller than b.Y, or a.X == b.X and a.Y == b.Y and a.Z <= b.Z; otherwise, false.

| Improve this Doc View Source

Multiply(Vector3, Vector3)

Multiplies two vectors together, returning the dot product (or inner product). This differs from the cross product.

Declaration
public static double operator *(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

A vector.

Vector3 vector2

A second vector.

Returns
Type Description
System.Double

A value that results from the evaluation of v1.Xv2.X + v1.Yv2.Y + v1.Z*v2.Z.

This value equals v1.Length * v2.Length * cos(alpha), where alpha is the angle between vectors.

| Improve this Doc View Source

Multiply(Vector3, Double)

Multiplies a vector by a number, having the effect of scaling it.

Declaration
public static Vector3 operator *(Vector3 vector, double t)
Parameters
Type Name Description
Vector3 vector

A vector.

System.Double t

A number.

Returns
Type Description
Vector3

A new vector that is the original vector coordinatewise multiplied by t.

| Improve this Doc View Source

Multiply(Double, Vector3)

Multiplies a vector by a number, having the effect of scaling it.

Declaration
public static Vector3 operator *(double t, Vector3 vector)
Parameters
Type Name Description
System.Double t

A number.

Vector3 vector

A vector.

Returns
Type Description
Vector3

A new vector that is the original vector coordinatewise multiplied by t.

| Improve this Doc View Source

Subtraction(Vector3, Vector3)

Subtracts the second vector from the first one.

Declaration
public static Vector3 operator -(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

A vector.

Vector3 vector2

A second vector.

Returns
Type Description
Vector3

A new vector that results from the componentwise difference of vector1 - vector2.

| Improve this Doc View Source

UnaryNegation(Vector3)

Computes the reversed vector.

Declaration
public static Vector3 operator -(Vector3 vector)
Parameters
Type Name Description
Vector3 vector

A vector to negate.

Returns
Type Description
Vector3

A new vector where all components were multiplied by -1.

Explicit Interface Implementations

| Improve this Doc View Source

IComparable.CompareTo(Object)

Declaration
int IComparable.CompareTo(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Int32

Implements

System.IEquatable<T>
System.IComparable<T>
System.IComparable