org.apache.lucene.spatial.spatial4j.geo3d

## Class Vector

• Direct Known Subclasses:
GeoPoint, Plane

```public class Vector
extends Object```
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

Fields
Modifier and Type Field and Description
`static double` `MINIMUM_RESOLUTION`
Values that are all considered to be essentially zero have a magnitude less than this.
`static double` `MINIMUM_RESOLUTION_CUBED`
`static double` `MINIMUM_RESOLUTION_SQUARED`
For squared quantities, the bound is squared too.
`double` `x`
`double` `y`
`double` `z`
• ### Constructor Summary

Constructors
Constructor and Description
```Vector(double x, double y, double z)```
Construct from (U.S.) x,y,z coordinates.
```Vector(Vector A, Vector B)```
Construct a vector that is perpendicular to two other (non-zero) vectors.
• ### Method Summary

Methods
Modifier and Type Method and Description
`double` ```dotProduct(double x, double y, double z)```
Do a dot product.
`double` `dotProduct(Vector v)`
Do a dot product.
`boolean` `equals(Object o)`
`int` `hashCode()`
`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` `linearDistance(Vector v)`
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` `linearDistanceSquared(Vector v)`
Compute the square of a straight-line distance to a point described by the vector taken from the origin.
`double` `magnitude()`
Compute the magnitude of this vector.
`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` `normalDistance(Vector v)`
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` `normalDistanceSquared(Vector v)`
Compute the square of the normal distance to a vector described by a vector taken from the origin.
`Vector` `normalize()`
Compute a normalized unit vector based on the current vector.
`Vector` `rotateXY(double angle)`
Rotate vector counter-clockwise in x-y by an angle.
`Vector` ```rotateXY(double sinAngle, double cosAngle)```
Rotate vector counter-clockwise in x-y by an angle, expressed as sin and cos.
`Vector` `rotateXZ(double angle)`
Rotate vector counter-clockwise in x-z by an angle.
`Vector` ```rotateXZ(double sinAngle, double cosAngle)```
Rotate vector counter-clockwise in x-z by an angle, expressed as sin and cos.
`Vector` `rotateZY(double angle)`
Rotate vector counter-clockwise in z-y by an angle.
`Vector` ```rotateZY(double sinAngle, double cosAngle)```
Rotate vector counter-clockwise in z-y by an angle, expressed as sin and cos.
`String` `toString()`
`Vector` ```translate(double xOffset, double yOffset, double zOffset)```
Translate vector.
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### MINIMUM_RESOLUTION

`public static final double MINIMUM_RESOLUTION`
Values that are all considered to be essentially zero have a magnitude less than this.
Constant Field Values
• #### MINIMUM_RESOLUTION_SQUARED

`public static final double MINIMUM_RESOLUTION_SQUARED`
For squared quantities, the bound is squared too.
Constant Field Values
• #### MINIMUM_RESOLUTION_CUBED

`public static final double MINIMUM_RESOLUTION_CUBED`
Constant Field Values
• #### x

`public final double x`
• #### y

`public final double y`
• #### z

`public final double z`
• ### Constructor Detail

• #### Vector

```public Vector(double x,
double y,
double z)```
Construct from (U.S.) x,y,z coordinates.
• #### Vector

```public Vector(Vector A,
Vector B)```
Construct a vector that is perpendicular to two other (non-zero) vectors. If the vectors are parallel, the result vector will have magnitude 0.
Parameters:
`A` - is the first vector
`B` - is the second
• ### Method Detail

• #### normalize

`public Vector 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.
• #### dotProduct

`public double dotProduct(Vector v)`
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

```public boolean isWithin(Membership[] bounds,
Membership[] moreBounds)```
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

```public Vector translate(double xOffset,
double yOffset,
double zOffset)```
Translate vector.
• #### rotateXY

`public Vector rotateXY(double angle)`
Rotate vector counter-clockwise in x-y by an angle.
• #### rotateXY

```public Vector rotateXY(double sinAngle,
double cosAngle)```
Rotate vector counter-clockwise in x-y by an angle, expressed as sin and cos.
• #### rotateXZ

`public Vector rotateXZ(double angle)`
Rotate vector counter-clockwise in x-z by an angle.
• #### rotateXZ

```public Vector rotateXZ(double sinAngle,
double cosAngle)```
Rotate vector counter-clockwise in x-z by an angle, expressed as sin and cos.
• #### rotateZY

`public Vector rotateZY(double angle)`
Rotate vector counter-clockwise in z-y by an angle.
• #### rotateZY

```public Vector rotateZY(double sinAngle,
double cosAngle)```
Rotate vector counter-clockwise in z-y by an angle, expressed as sin and cos.
• #### linearDistanceSquared

`public double linearDistanceSquared(Vector v)`
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

`public double linearDistance(Vector v)`
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

`public double normalDistanceSquared(Vector v)`
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

`public double normalDistance(Vector v)`
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.
• #### equals

`public boolean equals(Object o)`
Overrides:
`equals` in class `Object`
• #### hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`