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
CoordinateThe 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
CoordinateThe origin coordinate
to
CoordinateThe destination coordinate
Vector3D(Vector2D, double)
public Vector3D(Vector2D value, double z)
Parameters
value
Vector2DA vector containing the values with which to initialize the X and Y components.
z
doubleInitial 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
Properties
X
Gets a value indicating the x-ordinate
public double X { get; }
Property Value
Y
Gets a value indicating the y-ordinate
public double Y { get; }
Property Value
Z
Gets a value indicating the z-ordinate
public double Z { get; }
Property Value
Zero
Creates a new vector with all components set to Zero
public static Vector3D Zero { get; }
Property Value
Methods
Add(Vector3D)
Computes a vector which is the sum of this vector and the given vector.
public Vector3D Add(Vector3D v)
Parameters
v
Vector3DThe 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
CoordinateThe 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
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
Returns
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
doubleThe 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
CoordinateThe 1st vector
v2
CoordinateThe 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
CoordinateThe start point of the 1st vector
B
CoordinateThe end point of the 1st vector
C
CoordinateThe start point of the 2nd vector
D
CoordinateThe 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
GetHashCode()
public override int GetHashCode()
Returns
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
CoordinateA 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
CoordinateA 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
Vector3DThe vector to subtract
Returns
- Vector3D
The difference of this and
v
ToString()
public override string ToString()
Returns
Operators
operator +(Vector3D, Vector3D)
Adds two vectors.
public static Vector3D operator +(Vector3D left, Vector3D right)
Parameters
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
Returns
- Vector3D
The scaled vector.
operator /(Vector3D, double)
Scales a vector by the given value.
public static Vector3D operator /(Vector3D value, double scale)
Parameters
Returns
- Vector3D
The scaled vector.
operator ==(Vector3D, Vector3D)
Tests for equality between two objects.
public static bool operator ==(Vector3D left, Vector3D right)
Parameters
Returns
- bool
true
ifleft
has the same value asright
; otherwise,false
.
operator !=(Vector3D, Vector3D)
Tests for inequality between two objects.
public static bool operator !=(Vector3D left, Vector3D right)
Parameters
Returns
- bool
true
ifleft
has a different value thanright
; otherwise,false
.
operator *(Vector3D, Vector3D)
Modulates a vector with another by performing component-wise multiplication.
public static Vector3D operator *(Vector3D left, Vector3D right)
Parameters
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
Returns
- Vector3D
The scaled vector.
operator *(double, Vector3D)
Scales a vector by the given value.
public static Vector3D operator *(double scale, Vector3D value)
Parameters
Returns
- Vector3D
The scaled vector.
operator -(Vector3D, Vector3D)
Subtracts two vectors.
public static Vector3D operator -(Vector3D left, Vector3D right)
Parameters
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
Vector3DThe 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
Vector3DThe vector to assert (unchanged).
Returns
- Vector3D
The asserted (unchanged) vector.