Package org.locationtech.jts.math
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 fromCoordinate
s. -
Method Summary
Modifier and TypeMethodDescriptionComputes a vector which is the sum of this vector and the given vector.static Vector3D
create
(double x, double y, double z) Creates a new vector with given X, Y and Z components.static Vector3D
create
(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 double
dot
(Coordinate v1, Coordinate v2) Computes the 3D dot-product of twoCoordinate
s.static double
dot
(Coordinate A, Coordinate B, Coordinate C, Coordinate D) Computes the dot product of the 3D vectors AB and CD.double
Computes the dot-product of two vectorsboolean
Tests if a vector o has the same values for the components.double
getX()
Gets the X component of this vector.double
getY()
Gets the Y component of this vector.double
getZ()
Gets the Z component of this vector.int
hashCode()
Gets a hashcode for this vector.double
length()
Computes the length of this vector.static double
length
(Coordinate v) Computes the length of a vector.Computes a vector having identical direction but normalized to have length 1.static Coordinate
Computes 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 fromCoordinate
s.- 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 twoCoordinate
s.- 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
Computes a vector which is the sum of this vector and the given vector.- Parameters:
v
- the vector to add- Returns:
- the sum of this and
v
-
subtract
Computes a vector which is the difference of this vector and the given vector.- Parameters:
v
- the vector to subtract- Returns:
- the difference of this and
v
-
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
Gets a string representation of this vector -
equals
Tests if a vector o has the same values for the components. -
hashCode
public int hashCode()Gets a hashcode for this vector.
-