Class Vector3D
Represents a vector in 3-dimensional Cartesian space.
Inherited Members
Namespace: NetTopologySuite.Mathematics
Assembly: NetTopologySuite.dll
Syntax
public class Vector3D
Constructors
| Improve this Doc View SourceVector3D(Coordinate)
Creates a new 3D vector from a Coordinate.
The coordinate should have the X,Y and Z ordinates specified.
Declaration
public Vector3D(Coordinate coord)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | coord | 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.
Declaration
public Vector3D(Coordinate from, Coordinate to)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | from | The origin coordinate |
Coordinate | to | The destination coordinate |
Vector3D(Vector2D, Double)
Declaration
public Vector3D(Vector2D value, double z)
Parameters
Type | Name | Description |
---|---|---|
Vector2D | value | A vector containing the values with which to initialize the X and Y components. |
Double | z | 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
Declaration
public Vector3D(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
Double | x | The x component |
Double | y | The y component |
Double | z | The z component |
Properties
| Improve this Doc View SourceX
Gets a value indicating the x-ordinate
Declaration
public double X { get; }
Property Value
Type | Description |
---|---|
Double |
Y
Gets a value indicating the y-ordinate
Declaration
public double Y { get; }
Property Value
Type | Description |
---|---|
Double |
Z
Gets a value indicating the z-ordinate
Declaration
public double Z { get; }
Property Value
Type | Description |
---|---|
Double |
Zero
Creates a new vector with all components set to Zero
Declaration
public static Vector3D Zero { get; }
Property Value
Type | Description |
---|---|
Vector3D |
Methods
| Improve this Doc View SourceAdd(Vector3D)
Computes a vector which is the sum of this vector and the given vector.
Declaration
public Vector3D Add(Vector3D v)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | v | The vector to add |
Returns
Type | Description |
---|---|
Vector3D | The sum of this and |
Create(Coordinate)
Creates a vector from a 3D Coordinate.
The coordinate should have the X,Y and Z ordinates specified.
Declaration
public static Vector3D Create(Coordinate coord)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | coord | The coordinate to copy |
Returns
Type | Description |
---|---|
Vector3D | A new vector |
Create(Double, Double, Double)
Creates a new vector with given x
, y
and z
components.
Declaration
public static Vector3D Create(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
Double | x | The x component |
Double | y | The y component |
Double | z | The z component |
Returns
Type | Description |
---|---|
Vector3D | A new vector |
Cross(Vector3D)
Computes the cross-product of this Vector3D and v
Declaration
public Vector3D Cross(Vector3D v)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | v |
Returns
Type | Description |
---|---|
Vector3D | The cross product of the vectors |
Cross(Vector3D, Vector3D)
Calculates the cross product of two vectors.
Declaration
public static Vector3D Cross(Vector3D left, Vector3D right)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | left | First source vector. |
Vector3D | right | Second source vector. |
Returns
Type | Description |
---|---|
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
.
Declaration
public Vector3D Divide(double d)
Parameters
Type | Name | Description |
---|---|---|
Double | d | The scalar divisor |
Returns
Type | Description |
---|---|
Vector3D | A new vector with divided length |
Dot(Coordinate, Coordinate)
Computes the 3D dot-product of two Coordinates
Declaration
public static double Dot(Coordinate v1, Coordinate v2)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | v1 | The 1st vector |
Coordinate | v2 | The 2nd vector |
Returns
Type | Description |
---|---|
Double | The dot product of the (coordinate) vectors |
Dot(Coordinate, Coordinate, Coordinate, Coordinate)
Computes the dot product of the 3D vectors AB and CD.
Declaration
public static double Dot(Coordinate A, Coordinate B, Coordinate C, Coordinate D)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | A | The start point of the 1st vector |
Coordinate | B | The end point of the 1st vector |
Coordinate | C | The start point of the 2nd vector |
Coordinate | D | The end point of the 2nd vector |
Returns
Type | Description |
---|---|
Double | The dot product |
Dot(Vector3D)
Computes the dot-product of this Vector3D and v
Declaration
public double Dot(Vector3D v)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | v |
Returns
Type | Description |
---|---|
Double | The dot product of the vectors |
Equals(Object)
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
Object | o |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceGetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceLength()
Computes the length of this vector
Declaration
public double Length()
Returns
Type | Description |
---|---|
Double | The length of this vector |
Length(Coordinate)
Computes the length of vector v
.
Declaration
public static double Length(Coordinate v)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | v | A coordinate representing a 3D Vector |
Returns
Type | Description |
---|---|
Double | The length of |
Normalize()
Computes a vector having identical direction but normalized to have length 1.
Declaration
public Vector3D Normalize()
Returns
Type | Description |
---|---|
Vector3D | A new normalized vector |
Normalize(Coordinate)
Computes a vector having identical direction as v
but normalized to have length 1.
Declaration
public static Coordinate Normalize(Coordinate v)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | v | A coordinate representing a 3D vector |
Returns
Type | Description |
---|---|
Coordinate | A coordinate representing the normalized vector |
Subtract(Vector3D)
Computes a vector which is the difference of this vector and the given vector.
Declaration
public Vector3D Subtract(Vector3D v)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | v | The vector to subtract |
Returns
Type | Description |
---|---|
Vector3D | The difference of this and |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
Operators
| Improve this Doc View SourceAddition(Vector3D, Vector3D)
Adds two vectors.
Declaration
public static Vector3D operator +(Vector3D left, Vector3D right)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | left | The first vector to add. |
Vector3D | right | The second vector to add. |
Returns
Type | Description |
---|---|
Vector3D | The sum of the two vectors. |
Division(Vector3D, Vector3D)
Scales a vector by the given value.
Declaration
public static Vector3D operator /(Vector3D value, Vector3D scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | value | The vector to scale. |
Vector3D | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Vector3D | The scaled vector. |
Division(Vector3D, Double)
Scales a vector by the given value.
Declaration
public static Vector3D operator /(Vector3D value, double scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | value | The vector to scale. |
Double | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Vector3D | The scaled vector. |
Equality(Vector3D, Vector3D)
Tests for equality between two objects.
Declaration
public static bool operator ==(Vector3D left, Vector3D right)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | left | The first value to compare. |
Vector3D | right | The second value to compare. |
Returns
Type | Description |
---|---|
Boolean |
|
Inequality(Vector3D, Vector3D)
Tests for inequality between two objects.
Declaration
public static bool operator !=(Vector3D left, Vector3D right)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | left | The first value to compare. |
Vector3D | right | The second value to compare. |
Returns
Type | Description |
---|---|
Boolean |
|
Multiply(Vector3D, Vector3D)
Modulates a vector with another by performing component-wise multiplication.
Declaration
public static Vector3D operator *(Vector3D left, Vector3D right)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | left | The first vector to multiply. |
Vector3D | right | The second vector to multiply. |
Returns
Type | Description |
---|---|
Vector3D | The multiplication of the two vectors. |
Multiply(Vector3D, Double)
Scales a vector by the given value.
Declaration
public static Vector3D operator *(Vector3D value, double scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | value | The vector to scale. |
Double | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Vector3D | The scaled vector. |
Multiply(Double, Vector3D)
Scales a vector by the given value.
Declaration
public static Vector3D operator *(double scale, Vector3D value)
Parameters
Type | Name | Description |
---|---|---|
Double | scale | The amount by which to scale the vector. |
Vector3D | value | The vector to scale. |
Returns
Type | Description |
---|---|
Vector3D | The scaled vector. |
Subtraction(Vector3D, Vector3D)
Subtracts two vectors.
Declaration
public static Vector3D operator -(Vector3D left, Vector3D right)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | left | The first vector to subtract. |
Vector3D | right | The second vector to subtract. |
Returns
Type | Description |
---|---|
Vector3D | The difference of the two vectors. |
UnaryNegation(Vector3D)
Reverses the direction of a given vector.
Declaration
public static Vector3D operator -(Vector3D value)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | value | The vector to negate. |
Returns
Type | Description |
---|---|
Vector3D | A vector facing in the opposite direction. |
UnaryPlus(Vector3D)
Assert a vector (return it unchanged).
Declaration
public static Vector3D operator +(Vector3D value)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | value | The vector to assert (unchanged). |
Returns
Type | Description |
---|---|
Vector3D | The asserted (unchanged) vector. |