Class Vector3D
java.lang.Object
org.locationtech.jts.math.Vector3D
Represents a vector in 3-dimensional Cartesian space.
- Author:
- mdavis
-
Constructor Summary
ConstructorsConstructorDescriptionVector3D(double x, double y, double z) Creates a vector with the givne components.Creates a new 3D vector from aCoordinate.Vector3D(Coordinate from, Coordinate to) Creates a new vector with the direction and magnitude of the difference between the to and fromCoordinates. -
Method Summary
Modifier and TypeMethodDescriptionComputes a vector which is the sum of this vector and the given vector.static Vector3Dcreate(double x, double y, double z) Creates a new vector with given X, Y and Z components.static Vector3Dcreate(Coordinate coord) Creates a vector from a 3DCoordinate.divide(double d) Creates a new vector which has the same direction and with length equals to the length of this vector divided by the scalar valued.static doubledot(Coordinate v1, Coordinate v2) Computes the 3D dot-product of twoCoordinates.static doubledot(Coordinate A, Coordinate B, Coordinate C, Coordinate D) Computes the dot product of the 3D vectors AB and CD.doubleComputes the dot-product of two vectorsbooleanTests if a vector o has the same values for the components.doublegetX()Gets the X component of this vector.doublegetY()Gets the Y component of this vector.doublegetZ()Gets the Z component of this vector.inthashCode()Gets a hashcode for this vector.doublelength()Computes the length of this vector.static doublelength(Coordinate v) Computes the length of a vector.Computes a vector having identical direction but normalized to have length 1.static CoordinateComputes a vector having identical direction but normalized to have length 1.Computes a vector which is the difference of this vector and the given vector.toString()Gets a string representation of this vector
-
Constructor Details
-
Vector3D
Creates a new 3D vector from aCoordinate. The coordinate should have the X,Y and Z ordinates specified.- Parameters:
v- the Coordinate to copy
-
Vector3D
Creates a new vector with the direction and magnitude of the difference between the to and fromCoordinates.- Parameters:
from- the origin Coordinateto- the destination Coordinate
-
Vector3D
public Vector3D(double x, double y, double z) Creates a vector with the givne components.- Parameters:
x- the X componenty- the Y componentz- the Z component
-
-
Method Details
-
dot
Computes the dot product of the 3D vectors AB and CD.- Parameters:
A- the start point of the first vectorB- the end point of the first vectorC- the start point of the second vectorD- the end point of the second vector- Returns:
- the dot product
-
create
Creates a new vector with given X, Y and Z components.- Parameters:
x- the X componenty- the Y componentz- the Z component- Returns:
- a new vector
-
create
Creates a vector from a 3DCoordinate. The coordinate should have the X,Y and Z ordinates specified.- Parameters:
coord- the Coordinate to copy- Returns:
- a new vector
-
dot
Computes the 3D dot-product of twoCoordinates.- Parameters:
v1- the first vectorv2- the second vector- Returns:
- the dot product of the vectors
-
getX
public double getX()Gets the X component of this vector.- Returns:
- the value of the X component
-
getY
public double getY()Gets the Y component of this vector.- Returns:
- the value of the Y component
-
getZ
public double getZ()Gets the Z component of this vector.- Returns:
- the value of the Z component
-
add
-
subtract
-
divide
Creates a new vector which has the same direction and with length equals to the length of this vector divided by the scalar valued.- Parameters:
d- the scalar divisor- Returns:
- a new vector with divided length
-
dot
Computes the dot-product of two vectors- Parameters:
v- a vector- Returns:
- the dot product of the vectors
-
length
public double length()Computes the length of this vector.- Returns:
- the length of the vector
-
length
Computes the length of a vector.- Parameters:
v- a coordinate representing a 3D vector- Returns:
- the length of the vector
-
normalize
Computes a vector having identical direction but normalized to have length 1.- Returns:
- a new normalized vector
-
normalize
Computes a vector having identical direction but normalized to have length 1.- Parameters:
v- a coordinate representing a 3D vector- Returns:
- a coordinate representing the normalized vector
-
toString
-
equals
-
hashCode
-