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
coordCoordinateThe 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
fromCoordinateThe origin coordinate
toCoordinateThe destination coordinate
Vector3D(Vector2D, double)
public Vector3D(Vector2D value, double z)
Parameters
valueVector2DA vector containing the values with which to initialize the X and Y components.
zdoubleInitial 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
vVector3DThe 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
coordCoordinateThe 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
vVector3D
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
ddoubleThe 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
v1CoordinateThe 1st vector
v2CoordinateThe 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
ACoordinateThe start point of the 1st vector
BCoordinateThe end point of the 1st vector
CCoordinateThe start point of the 2nd vector
DCoordinateThe 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
vVector3D
Returns
- double
The dot product of the vectors
Equals(object)
public override bool Equals(object o)
Parameters
oobject
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
vCoordinateA 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
vCoordinateA 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
vVector3DThe 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
trueiflefthas 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
trueiflefthas 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
valueVector3DThe 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
valueVector3DThe vector to assert (unchanged).
Returns
- Vector3D
The asserted (unchanged) vector.