Package org.apache.lucene.spatial3d.geom
Class Vector
java.lang.Object
org.apache.lucene.spatial3d.geom.Vector
A 3d vector in space, not necessarily going through the origin.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
Angular version of minimum resolution.static final double
Values that are all considered to be essentially zero have a magnitude less than this.static final double
For cubed quantities, cube the bound.static final double
For squared quantities, the bound is squared too.final double
The x valuefinal double
The y valuefinal double
The z value -
Constructor Summary
ConstructorDescriptionVector
(double x, double y, double z) Construct from (U.S.) x,y,z coordinates.Vector
(double AX, double AY, double AZ, double BX, double BY, double BZ) Construct a vector that is perpendicular to two other (non-zero) vectors.Construct a vector that is perpendicular to two other (non-zero) vectors.Construct a vector that is perpendicular to two other (non-zero) vectors. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
crossProductEvaluateIsZero
(Vector A, Vector B, Vector point) Evaluate the cross product of two vectors against a point.double
dotProduct
(double x, double y, double z) Do a dot product.double
dotProduct
(Vector v) Do a dot product.boolean
int
hashCode()
boolean
isNumericallyIdentical
(double otherX, double otherY, double otherZ) Compute whether two vectors are numerically identical.boolean
isNumericallyIdentical
(Vector other) Compute whether two vectors are numerically identical.boolean
isParallel
(double otherX, double otherY, double otherZ) Compute whether two vectors are parallel.boolean
isParallel
(Vector other) Compute whether two vectors are numerically identical.boolean
isWithin
(Membership[] bounds, Membership... moreBounds) Determine if this vector, taken from the origin, describes a point within a set of planes.double
linearDistance
(double x, double y, double z) Compute the straight-line distance to a point described by the vector taken from the origin.double
Compute the straight-line distance to a point described by the vector taken from the origin.double
linearDistanceSquared
(double x, double y, double z) Compute the square of a straight-line distance to a point described by the vector taken from the origin.double
Compute the square of a straight-line distance to a point described by the vector taken from the origin.double
Compute the magnitude of this vector.static double
magnitude
(double x, double y, double z) Compute a magnitude of an x,y,z value.double
normalDistance
(double x, double y, double z) Compute the normal (perpendicular) distance to a vector described by a vector taken from the origin.double
Compute the normal (perpendicular) distance to a vector described by a vector taken from the origin.double
normalDistanceSquared
(double x, double y, double z) Compute the square of the normal distance to a vector described by a vector taken from the origin.double
Compute the square of the normal distance to a vector described by a vector taken from the origin.Compute a normalized unit vector based on the current vector.rotateXY
(double angle) Rotate vector counter-clockwise in x-y by an angle.rotateXY
(double sinAngle, double cosAngle) Rotate vector counter-clockwise in x-y by an angle, expressed as sin and cos.rotateXZ
(double angle) Rotate vector counter-clockwise in x-z by an angle.rotateXZ
(double sinAngle, double cosAngle) Rotate vector counter-clockwise in x-z by an angle, expressed as sin and cos.rotateZY
(double angle) Rotate vector counter-clockwise in z-y by an angle.rotateZY
(double sinAngle, double cosAngle) Rotate vector counter-clockwise in z-y by an angle, expressed as sin and cos.toString()
translate
(double xOffset, double yOffset, double zOffset) Translate vector.
-
Field Details
-
MINIMUM_RESOLUTION
public static final double MINIMUM_RESOLUTIONValues that are all considered to be essentially zero have a magnitude less than this.- See Also:
-
MINIMUM_ANGULAR_RESOLUTION
public static final double MINIMUM_ANGULAR_RESOLUTIONAngular version of minimum resolution.- See Also:
-
MINIMUM_RESOLUTION_SQUARED
public static final double MINIMUM_RESOLUTION_SQUAREDFor squared quantities, the bound is squared too.- See Also:
-
MINIMUM_RESOLUTION_CUBED
public static final double MINIMUM_RESOLUTION_CUBEDFor cubed quantities, cube the bound.- See Also:
-
x
public final double xThe x value -
y
public final double yThe y value -
z
public final double zThe z value
-
-
Constructor Details
-
Vector
public Vector(double x, double y, double z) Construct from (U.S.) x,y,z coordinates.- Parameters:
x
- is the x value.y
- is the y value.z
- is the z value.
-
Vector
Construct a vector that is perpendicular to two other (non-zero) vectors. If the vectors are parallel, IllegalArgumentException will be thrown. Produces a normalized final vector.- Parameters:
A
- is the first vectorBX
- is the X value of the secondBY
- is the Y value of the secondBZ
- is the Z value of the second
-
Vector
public Vector(double AX, double AY, double AZ, double BX, double BY, double BZ) Construct a vector that is perpendicular to two other (non-zero) vectors. If the vectors are parallel, IllegalArgumentException will be thrown. Produces a normalized final vector.- Parameters:
AX
- is the X value of the firstAY
- is the Y value of the firstAZ
- is the Z value of the firstBX
- is the X value of the secondBY
- is the Y value of the secondBZ
- is the Z value of the second
-
Vector
Construct a vector that is perpendicular to two other (non-zero) vectors. If the vectors are parallel, IllegalArgumentException will be thrown. Produces a normalized final vector.- Parameters:
A
- is the first vectorB
- is the second
-
-
Method Details
-
magnitude
public static double magnitude(double x, double y, double z) Compute a magnitude of an x,y,z value. -
normalize
Compute a normalized unit vector based on the current vector.- Returns:
- the normalized vector, or null if the current vector has a magnitude of zero.
-
crossProductEvaluateIsZero
Evaluate the cross product of two vectors against a point. If the dot product of the resultant vector resolves to "zero", then return true.- Parameters:
A
- is the first vector to use for the cross product.B
- is the second vector to use for the cross product.point
- is the point to evaluate.- Returns:
- true if we get a zero dot product.
-
dotProduct
Do a dot product.- Parameters:
v
- is the vector to multiply.- Returns:
- the result.
-
dotProduct
public double dotProduct(double x, double y, double z) Do a dot product.- Parameters:
x
- is the x value of the vector to multiply.y
- is the y value of the vector to multiply.z
- is the z value of the vector to multiply.- Returns:
- the result.
-
isWithin
Determine if this vector, taken from the origin, describes a point within a set of planes.- Parameters:
bounds
- is the first part of the set of planes.moreBounds
- is the second part of the set of planes.- Returns:
- true if the point is within the bounds.
-
translate
Translate vector. -
rotateXY
Rotate vector counter-clockwise in x-y by an angle. -
rotateXY
Rotate vector counter-clockwise in x-y by an angle, expressed as sin and cos. -
rotateXZ
Rotate vector counter-clockwise in x-z by an angle. -
rotateXZ
Rotate vector counter-clockwise in x-z by an angle, expressed as sin and cos. -
rotateZY
Rotate vector counter-clockwise in z-y by an angle. -
rotateZY
Rotate vector counter-clockwise in z-y by an angle, expressed as sin and cos. -
linearDistanceSquared
Compute the square of a straight-line distance to a point described by the vector taken from the origin. Monotonically increasing for arc distances up to PI.- Parameters:
v
- is the vector to compute a distance to.- Returns:
- the square of the linear distance.
-
linearDistanceSquared
public double linearDistanceSquared(double x, double y, double z) Compute the square of a straight-line distance to a point described by the vector taken from the origin. Monotonically increasing for arc distances up to PI.- Parameters:
x
- is the x part of the vector to compute a distance to.y
- is the y part of the vector to compute a distance to.z
- is the z part of the vector to compute a distance to.- Returns:
- the square of the linear distance.
-
linearDistance
Compute the straight-line distance to a point described by the vector taken from the origin. Monotonically increasing for arc distances up to PI.- Parameters:
v
- is the vector to compute a distance to.- Returns:
- the linear distance.
-
linearDistance
public double linearDistance(double x, double y, double z) Compute the straight-line distance to a point described by the vector taken from the origin. Monotonically increasing for arc distances up to PI.- Parameters:
x
- is the x part of the vector to compute a distance to.y
- is the y part of the vector to compute a distance to.z
- is the z part of the vector to compute a distance to.- Returns:
- the linear distance.
-
normalDistanceSquared
Compute the square of the normal distance to a vector described by a vector taken from the origin. Monotonically increasing for arc distances up to PI/2.- Parameters:
v
- is the vector to compute a distance to.- Returns:
- the square of the normal distance.
-
normalDistanceSquared
public double normalDistanceSquared(double x, double y, double z) Compute the square of the normal distance to a vector described by a vector taken from the origin. Monotonically increasing for arc distances up to PI/2.- Parameters:
x
- is the x part of the vector to compute a distance to.y
- is the y part of the vector to compute a distance to.z
- is the z part of the vector to compute a distance to.- Returns:
- the square of the normal distance.
-
normalDistance
Compute the normal (perpendicular) distance to a vector described by a vector taken from the origin. Monotonically increasing for arc distances up to PI/2.- Parameters:
v
- is the vector to compute a distance to.- Returns:
- the normal distance.
-
normalDistance
public double normalDistance(double x, double y, double z) Compute the normal (perpendicular) distance to a vector described by a vector taken from the origin. Monotonically increasing for arc distances up to PI/2.- Parameters:
x
- is the x part of the vector to compute a distance to.y
- is the y part of the vector to compute a distance to.z
- is the z part of the vector to compute a distance to.- Returns:
- the normal distance.
-
magnitude
public double magnitude()Compute the magnitude of this vector.- Returns:
- the magnitude.
-
isNumericallyIdentical
public boolean isNumericallyIdentical(double otherX, double otherY, double otherZ) Compute whether two vectors are numerically identical.- Parameters:
otherX
- is the other vector X.otherY
- is the other vector Y.otherZ
- is the other vector Z.- Returns:
- true if they are numerically identical.
-
isNumericallyIdentical
Compute whether two vectors are numerically identical.- Parameters:
other
- is the other vector.- Returns:
- true if they are numerically identical.
-
isParallel
public boolean isParallel(double otherX, double otherY, double otherZ) Compute whether two vectors are parallel.- Parameters:
otherX
- is the other vector X.otherY
- is the other vector Y.otherZ
- is the other vector Z.- Returns:
- true if they are parallel.
-
isParallel
Compute whether two vectors are numerically identical.- Parameters:
other
- is the other vector.- Returns:
- true if they are parallel.
-
equals
-
hashCode
public int hashCode() -
toString
-