Table of Contents

Class Vector3D

Namespace
NetTopologySuite.Mathematics
Assembly
NetTopologySuite.dll

Represents a vector in 3-dimensional Cartesian space.

public class Vector3D
Inheritance
Vector3D
Inherited Members

Constructors

Vector3D(Coordinate)

Creates a new 3D vector from a Coordinate.

The coordinate should have the X,Y and Z ordinates specified.
public Vector3D(Coordinate coord)

Parameters

coord Coordinate

The coordinate to copy

Vector3D(Coordinate, Coordinate)

Creates a new vector with the direction and magnitude of the difference between the to and from Coordinates.

public Vector3D(Coordinate from, Coordinate to)

Parameters

from Coordinate

The origin coordinate

to Coordinate

The destination coordinate

Vector3D(Vector2D, double)

Creates a new Vector3D using a Vector2D plus a value for z component

public Vector3D(Vector2D value, double z)

Parameters

value Vector2D

A vector containing the values with which to initialize the X and Y components.

z double

Initial value for the Z component of the vector.

Vector3D(double, double, double)

Creates a new vector with the given x, y and z components

public Vector3D(double x, double y, double z)

Parameters

x double

The x component

y double

The y component

z double

The z component

Properties

X

Gets a value indicating the x-ordinate

public double X { get; }

Property Value

double

Y

Gets a value indicating the y-ordinate

public double Y { get; }

Property Value

double

Z

Gets a value indicating the z-ordinate

public double Z { get; }

Property Value

double

Zero

Creates a new vector with all components set to Zero

public static Vector3D Zero { get; }

Property Value

Vector3D

Methods

Add(Vector3D)

Computes a vector which is the sum of this vector and the given vector.

public Vector3D Add(Vector3D v)

Parameters

v Vector3D

The vector to add

Returns

Vector3D

The sum of this and v

Create(Coordinate)

Creates a vector from a 3D Coordinate.

The coordinate should have the X,Y and Z ordinates specified.
public static Vector3D Create(Coordinate coord)

Parameters

coord Coordinate

The coordinate to copy

Returns

Vector3D

A new vector

Create(double, double, double)

Creates a new vector with given x, y and z components.

public static Vector3D Create(double x, double y, double z)

Parameters

x double

The x component

y double

The y component

z double

The z component

Returns

Vector3D

A new vector

Cross(Vector3D)

Computes the cross-product of this Vector3D and v

public Vector3D Cross(Vector3D v)

Parameters

v Vector3D

Returns

Vector3D

The cross product of the vectors

Cross(Vector3D, Vector3D)

Calculates the cross product of two vectors.

public static Vector3D Cross(Vector3D left, Vector3D right)

Parameters

left Vector3D

First source vector.

right Vector3D

Second source vector.

Returns

Vector3D

Divide(double)

Creates a new vector which has the same direction and with length equals to the length of this vector divided by the scalar value d.

public Vector3D Divide(double d)

Parameters

d double

The scalar divisor

Returns

Vector3D

A new vector with divided length

Dot(Coordinate, Coordinate)

Computes the 3D dot-product of two Coordinates

public static double Dot(Coordinate v1, Coordinate v2)

Parameters

v1 Coordinate

The 1st vector

v2 Coordinate

The 2nd vector

Returns

double

The dot product of the (coordinate) vectors

Dot(Coordinate, Coordinate, Coordinate, Coordinate)

Computes the dot product of the 3D vectors AB and CD.

public static double Dot(Coordinate A, Coordinate B, Coordinate C, Coordinate D)

Parameters

A Coordinate

The start point of the 1st vector

B Coordinate

The end point of the 1st vector

C Coordinate

The start point of the 2nd vector

D Coordinate

The end point of the 2nd vector

Returns

double

The dot product

Dot(Vector3D)

Computes the dot-product of this Vector3D and v

public double Dot(Vector3D v)

Parameters

v Vector3D

Returns

double

The dot product of the vectors

Equals(object)

public override bool Equals(object o)

Parameters

o object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

Length()

Computes the length of this vector

public double Length()

Returns

double

The length of this vector

Length(Coordinate)

Computes the length of vector v.

public static double Length(Coordinate v)

Parameters

v Coordinate

A coordinate representing a 3D Vector

Returns

double

The length of v

Normalize()

Computes a vector having identical direction but normalized to have length 1.

public Vector3D Normalize()

Returns

Vector3D

A new normalized vector

Normalize(Coordinate)

Computes a vector having identical direction as v but normalized to have length 1.

public static Coordinate Normalize(Coordinate v)

Parameters

v Coordinate

A coordinate representing a 3D vector

Returns

Coordinate

A coordinate representing the normalized vector

Subtract(Vector3D)

Computes a vector which is the difference of this vector and the given vector.

public Vector3D Subtract(Vector3D v)

Parameters

v Vector3D

The vector to subtract

Returns

Vector3D

The difference of this and v

ToString()

public override string ToString()

Returns

string

Operators

operator +(Vector3D, Vector3D)

Adds two vectors.

public static Vector3D operator +(Vector3D left, Vector3D right)

Parameters

left Vector3D

The first vector to add.

right Vector3D

The second vector to add.

Returns

Vector3D

The sum of the two vectors.

operator /(Vector3D, Vector3D)

Scales a vector by the given value.

public static Vector3D operator /(Vector3D value, Vector3D scale)

Parameters

value Vector3D

The vector to scale.

scale Vector3D

The amount by which to scale the vector.

Returns

Vector3D

The scaled vector.

operator /(Vector3D, double)

Scales a vector by the given value.

public static Vector3D operator /(Vector3D value, double scale)

Parameters

value Vector3D

The vector to scale.

scale double

The amount by which to scale the vector.

Returns

Vector3D

The scaled vector.

operator ==(Vector3D, Vector3D)

Tests for equality between two objects.

public static bool operator ==(Vector3D left, Vector3D right)

Parameters

left Vector3D

The first value to compare.

right Vector3D

The second value to compare.

Returns

bool

true if left has the same value as right; otherwise, false.

operator !=(Vector3D, Vector3D)

Tests for inequality between two objects.

public static bool operator !=(Vector3D left, Vector3D right)

Parameters

left Vector3D

The first value to compare.

right Vector3D

The second value to compare.

Returns

bool

true if left has a different value than right; otherwise, false.

operator *(Vector3D, Vector3D)

Modulates a vector with another by performing component-wise multiplication.

public static Vector3D operator *(Vector3D left, Vector3D right)

Parameters

left Vector3D

The first vector to multiply.

right Vector3D

The second vector to multiply.

Returns

Vector3D

The multiplication of the two vectors.

operator *(Vector3D, double)

Scales a vector by the given value.

public static Vector3D operator *(Vector3D value, double scale)

Parameters

value Vector3D

The vector to scale.

scale double

The amount by which to scale the vector.

Returns

Vector3D

The scaled vector.

operator *(double, Vector3D)

Scales a vector by the given value.

public static Vector3D operator *(double scale, Vector3D value)

Parameters

scale double

The amount by which to scale the vector.

value Vector3D

The vector to scale.

Returns

Vector3D

The scaled vector.

operator -(Vector3D, Vector3D)

Subtracts two vectors.

public static Vector3D operator -(Vector3D left, Vector3D right)

Parameters

left Vector3D

The first vector to subtract.

right Vector3D

The second vector to subtract.

Returns

Vector3D

The difference of the two vectors.

operator -(Vector3D)

Reverses the direction of a given vector.

public static Vector3D operator -(Vector3D value)

Parameters

value Vector3D

The vector to negate.

Returns

Vector3D

A vector facing in the opposite direction.

operator +(Vector3D)

Assert a vector (return it unchanged).

public static Vector3D operator +(Vector3D value)

Parameters

value Vector3D

The vector to assert (unchanged).

Returns

Vector3D

The asserted (unchanged) vector.