org.hipparchus.geometry.euclidean.twod

## Class FieldVector2D<T extends CalculusFieldElement<T>>

• Type Parameters:
T - the type of the field elements

public class FieldVector2D<T extends CalculusFieldElement<T>>
extends Object
This class is a re-implementation of Vector2D using CalculusFieldElement.

Instance of this class are guaranteed to be immutable.

Since:
1.6
• ### Constructor Summary

Constructors
Constructor and Description
FieldVector2D(double a, FieldVector2D<T> u)
Multiplicative constructor Build a vector from another one and a scale factor.
FieldVector2D(double a1, FieldVector2D<T> u1, double a2, FieldVector2D<T> u2)
Linear constructor.
FieldVector2D(double a1, FieldVector2D<T> u1, double a2, FieldVector2D<T> u2, double a3, FieldVector2D<T> u3)
Linear constructor.
FieldVector2D(double a1, FieldVector2D<T> u1, double a2, FieldVector2D<T> u2, double a3, FieldVector2D<T> u3, double a4, FieldVector2D<T> u4)
Linear constructor.
FieldVector2D(Field<T> field, Vector2D v)
FieldVector2D(T[] v)
Simple constructor.
FieldVector2D(T a, FieldVector2D<T> u)
Multiplicative constructor Build a vector from another one and a scale factor.
FieldVector2D(T a1, FieldVector2D<T> u1, T a2, FieldVector2D<T> u2)
Linear constructor Build a vector from two other ones and corresponding scale factors.
FieldVector2D(T a1, FieldVector2D<T> u1, T a2, FieldVector2D<T> u2, T a3, FieldVector2D<T> u3)
Linear constructor.
FieldVector2D(T a1, FieldVector2D<T> u1, T a2, FieldVector2D<T> u2, T a3, FieldVector2D<T> u3, T a4, FieldVector2D<T> u4)
Linear constructor.
FieldVector2D(T x, T y)
Simple constructor.
FieldVector2D(T a, Vector2D u)
Multiplicative constructor Build a vector from another one and a scale factor.
FieldVector2D(T a1, Vector2D u1, T a2, Vector2D u2)
Linear constructor.
FieldVector2D(T a1, Vector2D u1, T a2, Vector2D u2, T a3, Vector2D u3)
Linear constructor.
FieldVector2D(T a1, Vector2D u1, T a2, Vector2D u2, T a3, Vector2D u3, T a4, Vector2D u4)
Linear constructor.
• ### Method Summary

All Methods
Modifier and Type Method and Description
FieldVector2D<T> add(double factor, FieldVector2D<T> v)
Add a scaled vector to the instance.
FieldVector2D<T> add(double factor, Vector2D v)
Add a scaled vector to the instance.
FieldVector2D<T> add(FieldVector2D<T> v)
Add a vector to the instance.
FieldVector2D<T> add(T factor, FieldVector2D<T> v)
Add a scaled vector to the instance.
FieldVector2D<T> add(T factor, Vector2D v)
Add a scaled vector to the instance.
FieldVector2D<T> add(Vector2D v)
Add a vector to the instance.
static <T extends CalculusFieldElement<T>>T angle(FieldVector2D<T> v1, FieldVector2D<T> v2)
Compute the angular separation between two vectors.
static <T extends CalculusFieldElement<T>>T angle(FieldVector2D<T> v1, Vector2D v2)
Compute the angular separation between two vectors.
static <T extends CalculusFieldElement<T>>T angle(Vector2D v1, FieldVector2D<T> v2)
Compute the angular separation between two vectors.
T crossProduct(FieldVector2D<T> p1, FieldVector2D<T> p2)
Compute the cross-product of the instance and the given points.
T crossProduct(Vector2D p1, Vector2D p2)
Compute the cross-product of the instance and the given points.
T distance(FieldVector2D<T> v)
Compute the distance between the instance and another vector according to the L2 norm.
static <T extends CalculusFieldElement<T>>T distance(FieldVector2D<T> p1, FieldVector2D<T> p2)
Compute the distance between two vectors according to the L2 norm.
static <T extends CalculusFieldElement<T>>T distance(FieldVector2D<T> p1, Vector2D p2)
Compute the distance between two vectors according to the L2 norm.
T distance(Vector2D v)
Compute the distance between the instance and another vector according to the L2 norm.
static <T extends CalculusFieldElement<T>>T distance(Vector2D p1, FieldVector2D<T> p2)
Compute the distance between two vectors according to the L2 norm.
T distance1(FieldVector2D<T> v)
Compute the distance between the instance and another vector according to the L1 norm.
static <T extends CalculusFieldElement<T>>T distance1(FieldVector2D<T> p1, FieldVector2D<T> p2)
Compute the distance between two vectors according to the L2 norm.
static <T extends CalculusFieldElement<T>>T distance1(FieldVector2D<T> p1, Vector2D p2)
Compute the distance between two vectors according to the L2 norm.
T distance1(Vector2D v)
Compute the distance between the instance and another vector according to the L1 norm.
static <T extends CalculusFieldElement<T>>T distance1(Vector2D p1, FieldVector2D<T> p2)
Compute the distance between two vectors according to the L2 norm.
T distanceInf(FieldVector2D<T> v)
Compute the distance between the instance and another vector according to the L norm.
static <T extends CalculusFieldElement<T>>T distanceInf(FieldVector2D<T> p1, FieldVector2D<T> p2)
Compute the distance between two vectors according to the L norm.
static <T extends CalculusFieldElement<T>>T distanceInf(FieldVector2D<T> p1, Vector2D p2)
Compute the distance between two vectors according to the L norm.
T distanceInf(Vector2D v)
Compute the distance between the instance and another vector according to the L norm.
static <T extends CalculusFieldElement<T>>T distanceInf(Vector2D p1, FieldVector2D<T> p2)
Compute the distance between two vectors according to the L norm.
T distanceSq(FieldVector2D<T> v)
Compute the square of the distance between the instance and another vector.
static <T extends CalculusFieldElement<T>>T distanceSq(FieldVector2D<T> p1, FieldVector2D<T> p2)
Compute the square of the distance between two vectors.
static <T extends CalculusFieldElement<T>>T distanceSq(FieldVector2D<T> p1, Vector2D p2)
Compute the square of the distance between two vectors.
T distanceSq(Vector2D v)
Compute the square of the distance between the instance and another vector.
static <T extends CalculusFieldElement<T>>T distanceSq(Vector2D p1, FieldVector2D<T> p2)
Compute the square of the distance between two vectors.
T dotProduct(FieldVector2D<T> v)
Compute the dot-product of the instance and another vector.
T dotProduct(Vector2D v)
Compute the dot-product of the instance and another vector.
boolean equals(Object other)
Test for the equality of two 2D vectors.
static <T extends CalculusFieldElement<T>>FieldVector2D<T> getMinusI(Field<T> field)
Get opposite of the first canonical vector (coordinates: -1).
static <T extends CalculusFieldElement<T>>FieldVector2D<T> getMinusJ(Field<T> field)
Get opposite of the second canonical vector (coordinates: 0, -1).
static <T extends CalculusFieldElement<T>>FieldVector2D<T> getNaN(Field<T> field)
Get a vector with all coordinates set to NaN.
static <T extends CalculusFieldElement<T>>FieldVector2D<T> getNegativeInfinity(Field<T> field)
Get a vector with all coordinates set to negative infinity.
T getNorm()
Get the L2 norm for the vector.
T getNorm1()
Get the L1 norm for the vector.
T getNormInf()
Get the L norm for the vector.
T getNormSq()
Get the square of the norm for the vector.
static <T extends CalculusFieldElement<T>>FieldVector2D<T> getPlusI(Field<T> field)
Get first canonical vector (coordinates: 1, 0).
static <T extends CalculusFieldElement<T>>FieldVector2D<T> getPlusJ(Field<T> field)
Get second canonical vector (coordinates: 0, 1).
static <T extends CalculusFieldElement<T>>FieldVector2D<T> getPositiveInfinity(Field<T> field)
Get a vector with all coordinates set to positive infinity.
T getX()
Get the abscissa of the vector.
T getY()
Get the ordinate of the vector.
static <T extends CalculusFieldElement<T>>FieldVector2D<T> getZero(Field<T> field)
Get null vector (coordinates: 0, 0).
int hashCode()
Get a hashCode for the 3D vector.
boolean isInfinite()
Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise
boolean isNaN()
Returns true if any coordinate of this vector is NaN; false otherwise
FieldVector2D<T> negate()
Get the opposite of the instance.
FieldVector2D<T> normalize()
Get a normalized vector aligned with the instance.
static <T extends CalculusFieldElement<T>>T orientation(FieldVector2D<T> p, FieldVector2D<T> q, FieldVector2D<T> r)
Compute the orientation of a triplet of points.
FieldVector2D<T> scalarMultiply(double a)
Multiply the instance by a scalar.
FieldVector2D<T> scalarMultiply(T a)
Multiply the instance by a scalar.
FieldVector2D<T> subtract(double factor, FieldVector2D<T> v)
Subtract a scaled vector from the instance.
FieldVector2D<T> subtract(double factor, Vector2D v)
Subtract a scaled vector from the instance.
FieldVector2D<T> subtract(FieldVector2D<T> v)
Subtract a vector from the instance.
FieldVector2D<T> subtract(T factor, FieldVector2D<T> v)
Subtract a scaled vector from the instance.
FieldVector2D<T> subtract(T factor, Vector2D v)
Subtract a scaled vector from the instance.
FieldVector2D<T> subtract(Vector2D v)
Subtract a vector from the instance.
T[] toArray()
Get the vector coordinates as a dimension 2 array.
String toString()
Get a string representation of this vector.
String toString(NumberFormat format)
Get a string representation of this vector.
Vector2D toVector2D()
Convert to a constant vector without extra field parts.
• ### Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait
• ### Constructor Detail

• #### FieldVector2D

public FieldVector2D(T x,
T y)
Simple constructor. Build a vector from its coordinates
Parameters:
x - abscissa
y - ordinate
getX(), getY()
• #### FieldVector2D

public FieldVector2D(T[] v)
throws MathIllegalArgumentException
Simple constructor. Build a vector from its coordinates
Parameters:
v - coordinates array
Throws:
MathIllegalArgumentException - if array does not have 2 elements
toArray()
• #### FieldVector2D

public FieldVector2D(T a,
FieldVector2D<T> u)
Multiplicative constructor Build a vector from another one and a scale factor. The vector built will be a * u
Parameters:
a - scale factor
u - base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(T a,
Vector2D u)
Multiplicative constructor Build a vector from another one and a scale factor. The vector built will be a * u
Parameters:
a - scale factor
u - base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(double a,
FieldVector2D<T> u)
Multiplicative constructor Build a vector from another one and a scale factor. The vector built will be a * u
Parameters:
a - scale factor
u - base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(T a1,
FieldVector2D<T> u1,
T a2,
FieldVector2D<T> u2)
Linear constructor Build a vector from two other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(T a1,
Vector2D u1,
T a2,
Vector2D u2)
Linear constructor. Build a vector from two other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(double a1,
FieldVector2D<T> u1,
double a2,
FieldVector2D<T> u2)
Linear constructor. Build a vector from two other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(T a1,
FieldVector2D<T> u1,
T a2,
FieldVector2D<T> u2,
T a3,
FieldVector2D<T> u3)
Linear constructor. Build a vector from three other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2 + a3 * u3
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
a3 - third scale factor
u3 - third base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(T a1,
Vector2D u1,
T a2,
Vector2D u2,
T a3,
Vector2D u3)
Linear constructor. Build a vector from three other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2 + a3 * u3
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
a3 - third scale factor
u3 - third base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(double a1,
FieldVector2D<T> u1,
double a2,
FieldVector2D<T> u2,
double a3,
FieldVector2D<T> u3)
Linear constructor. Build a vector from three other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2 + a3 * u3
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
a3 - third scale factor
u3 - third base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(T a1,
FieldVector2D<T> u1,
T a2,
FieldVector2D<T> u2,
T a3,
FieldVector2D<T> u3,
T a4,
FieldVector2D<T> u4)
Linear constructor. Build a vector from four other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
a3 - third scale factor
u3 - third base (unscaled) vector
a4 - fourth scale factor
u4 - fourth base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(T a1,
Vector2D u1,
T a2,
Vector2D u2,
T a3,
Vector2D u3,
T a4,
Vector2D u4)
Linear constructor. Build a vector from four other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
a3 - third scale factor
u3 - third base (unscaled) vector
a4 - fourth scale factor
u4 - fourth base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(double a1,
FieldVector2D<T> u1,
double a2,
FieldVector2D<T> u2,
double a3,
FieldVector2D<T> u3,
double a4,
FieldVector2D<T> u4)
Linear constructor. Build a vector from four other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
Parameters:
a1 - first scale factor
u1 - first base (unscaled) vector
a2 - second scale factor
u2 - second base (unscaled) vector
a3 - third scale factor
u3 - third base (unscaled) vector
a4 - fourth scale factor
u4 - fourth base (unscaled) vector
• #### FieldVector2D

public FieldVector2D(Field<T> field,
Vector2D v)
Parameters:
field - field for the components
v - vector to convert
• ### Method Detail

• #### getZero

public static <T extends CalculusFieldElement<T>> FieldVector2D<T> getZero(Field<T> field)
Get null vector (coordinates: 0, 0).
Type Parameters:
T - the type of the field elements
Parameters:
field - field for the components
Returns:
a new vector
• #### getPlusI

public static <T extends CalculusFieldElement<T>> FieldVector2D<T> getPlusI(Field<T> field)
Get first canonical vector (coordinates: 1, 0).
Type Parameters:
T - the type of the field elements
Parameters:
field - field for the components
Returns:
a new vector
• #### getMinusI

public static <T extends CalculusFieldElement<T>> FieldVector2D<T> getMinusI(Field<T> field)
Get opposite of the first canonical vector (coordinates: -1).
Type Parameters:
T - the type of the field elements
Parameters:
field - field for the components
Returns:
a new vector
• #### getPlusJ

public static <T extends CalculusFieldElement<T>> FieldVector2D<T> getPlusJ(Field<T> field)
Get second canonical vector (coordinates: 0, 1).
Type Parameters:
T - the type of the field elements
Parameters:
field - field for the components
Returns:
a new vector
• #### getMinusJ

public static <T extends CalculusFieldElement<T>> FieldVector2D<T> getMinusJ(Field<T> field)
Get opposite of the second canonical vector (coordinates: 0, -1).
Type Parameters:
T - the type of the field elements
Parameters:
field - field for the components
Returns:
a new vector
• #### getNaN

public static <T extends CalculusFieldElement<T>> FieldVector2D<T> getNaN(Field<T> field)
Get a vector with all coordinates set to NaN.
Type Parameters:
T - the type of the field elements
Parameters:
field - field for the components
Returns:
a new vector
• #### getPositiveInfinity

public static <T extends CalculusFieldElement<T>> FieldVector2D<T> getPositiveInfinity(Field<T> field)
Get a vector with all coordinates set to positive infinity.
Type Parameters:
T - the type of the field elements
Parameters:
field - field for the components
Returns:
a new vector
• #### getNegativeInfinity

public static <T extends CalculusFieldElement<T>> FieldVector2D<T> getNegativeInfinity(Field<T> field)
Get a vector with all coordinates set to negative infinity.
Type Parameters:
T - the type of the field elements
Parameters:
field - field for the components
Returns:
a new vector
• #### toVector2D

public Vector2D toVector2D()
Convert to a constant vector without extra field parts.
Returns:
a constant vector
• #### getNorm1

public T getNorm1()
Get the L1 norm for the vector.
Returns:
L1 norm for the vector
• #### getNorm

public T getNorm()
Get the L2 norm for the vector.
Returns:
Euclidean norm for the vector
• #### getNormSq

public T getNormSq()
Get the square of the norm for the vector.
Returns:
square of the Euclidean norm for the vector
• #### getNormInf

public T getNormInf()
Get the L norm for the vector.
Returns:
L norm for the vector

public FieldVector2D<T> add(FieldVector2D<T> v)
Add a vector to the instance.
Parameters:
v - vector to add
Returns:
a new vector

public FieldVector2D<T> add(Vector2D v)
Add a vector to the instance.
Parameters:
v - vector to add
Returns:
a new vector

public FieldVector2D<T> add(T factor,
FieldVector2D<T> v)
Add a scaled vector to the instance.
Parameters:
factor - scale factor to apply to v before adding it
v - vector to add
Returns:
a new vector

public FieldVector2D<T> add(T factor,
Vector2D v)
Add a scaled vector to the instance.
Parameters:
factor - scale factor to apply to v before adding it
v - vector to add
Returns:
a new vector

public FieldVector2D<T> add(double factor,
FieldVector2D<T> v)
Add a scaled vector to the instance.
Parameters:
factor - scale factor to apply to v before adding it
v - vector to add
Returns:
a new vector

public FieldVector2D<T> add(double factor,
Vector2D v)
Add a scaled vector to the instance.
Parameters:
factor - scale factor to apply to v before adding it
v - vector to add
Returns:
a new vector
• #### subtract

public FieldVector2D<T> subtract(FieldVector2D<T> v)
Subtract a vector from the instance.
Parameters:
v - vector to subtract
Returns:
a new vector
• #### subtract

public FieldVector2D<T> subtract(Vector2D v)
Subtract a vector from the instance.
Parameters:
v - vector to subtract
Returns:
a new vector
• #### subtract

public FieldVector2D<T> subtract(T factor,
FieldVector2D<T> v)
Subtract a scaled vector from the instance.
Parameters:
factor - scale factor to apply to v before subtracting it
v - vector to subtract
Returns:
a new vector
• #### subtract

public FieldVector2D<T> subtract(T factor,
Vector2D v)
Subtract a scaled vector from the instance.
Parameters:
factor - scale factor to apply to v before subtracting it
v - vector to subtract
Returns:
a new vector
• #### subtract

public FieldVector2D<T> subtract(double factor,
FieldVector2D<T> v)
Subtract a scaled vector from the instance.
Parameters:
factor - scale factor to apply to v before subtracting it
v - vector to subtract
Returns:
a new vector
• #### subtract

public FieldVector2D<T> subtract(double factor,
Vector2D v)
Subtract a scaled vector from the instance.
Parameters:
factor - scale factor to apply to v before subtracting it
v - vector to subtract
Returns:
a new vector
• #### normalize

public FieldVector2D<T> normalize()
throws MathRuntimeException
Get a normalized vector aligned with the instance.
Returns:
a new normalized vector
Throws:
MathRuntimeException - if the norm is zero
• #### angle

public static <T extends CalculusFieldElement<T>> T angle(FieldVector2D<T> v1,
FieldVector2D<T> v2)
throws MathRuntimeException
Compute the angular separation between two vectors.

This method computes the angular separation between two vectors using the dot product for well separated vectors and the cross product for almost aligned vectors. This allows to have a good accuracy in all cases, even for vectors very close to each other.

Type Parameters:
T - the type of the field elements
Parameters:
v1 - first vector
v2 - second vector
Returns:
angular separation between v1 and v2
Throws:
MathRuntimeException - if either vector has a null norm
• #### angle

public static <T extends CalculusFieldElement<T>> T angle(FieldVector2D<T> v1,
Vector2D v2)
throws MathRuntimeException
Compute the angular separation between two vectors.

This method computes the angular separation between two vectors using the dot product for well separated vectors and the cross product for almost aligned vectors. This allows to have a good accuracy in all cases, even for vectors very close to each other.

Type Parameters:
T - the type of the field elements
Parameters:
v1 - first vector
v2 - second vector
Returns:
angular separation between v1 and v2
Throws:
MathRuntimeException - if either vector has a null norm
• #### angle

public static <T extends CalculusFieldElement<T>> T angle(Vector2D v1,
FieldVector2D<T> v2)
throws MathRuntimeException
Compute the angular separation between two vectors.

This method computes the angular separation between two vectors using the dot product for well separated vectors and the cross product for almost aligned vectors. This allows to have a good accuracy in all cases, even for vectors very close to each other.

Type Parameters:
T - the type of the field elements
Parameters:
v1 - first vector
v2 - second vector
Returns:
angular separation between v1 and v2
Throws:
MathRuntimeException - if either vector has a null norm
• #### negate

public FieldVector2D<T> negate()
Get the opposite of the instance.
Returns:
a new vector which is opposite to the instance
• #### scalarMultiply

public FieldVector2D<T> scalarMultiply(T a)
Multiply the instance by a scalar.
Parameters:
a - scalar
Returns:
a new vector
• #### scalarMultiply

public FieldVector2D<T> scalarMultiply(double a)
Multiply the instance by a scalar.
Parameters:
a - scalar
Returns:
a new vector
• #### isNaN

public boolean isNaN()
Returns true if any coordinate of this vector is NaN; false otherwise
Returns:
true if any coordinate of this vector is NaN; false otherwise
• #### isInfinite

public boolean isInfinite()
Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise
Returns:
true if any coordinate of this vector is infinite and none are NaN; false otherwise
• #### equals

public boolean equals(Object other)
Test for the equality of two 2D vectors.

If all coordinates of two 2D vectors are exactly the same, and none of their real part are NaN, the two 2D vectors are considered to be equal.

NaN coordinates are considered to affect globally the vector and be equals to each other - i.e, if either (or all) real part of the coordinates of the 3D vector are NaN, the 2D vector is NaN.

Overrides:
equals in class Object
Parameters:
other - Object to test for equality to this
Returns:
true if two 2D vector objects are equal, false if object is null, not an instance of FieldVector2D, or not equal to this FieldVector2D instance
• #### hashCode

public int hashCode()
Get a hashCode for the 3D vector.

All NaN values have the same hash code.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object
• #### distance1

public T distance1(FieldVector2D<T> v)
Compute the distance between the instance and another vector according to the L1 norm.

Calling this method is equivalent to calling: q.subtract(p).getNorm1() except that no intermediate vector is built

Parameters:
v - second vector
Returns:
the distance between the instance and p according to the L1 norm
• #### distance1

public T distance1(Vector2D v)
Compute the distance between the instance and another vector according to the L1 norm.

Calling this method is equivalent to calling: q.subtract(p).getNorm1() except that no intermediate vector is built

Parameters:
v - second vector
Returns:
the distance between the instance and p according to the L1 norm
• #### distance

public T distance(FieldVector2D<T> v)
Compute the distance between the instance and another vector according to the L2 norm.

Calling this method is equivalent to calling: q.subtract(p).getNorm() except that no intermediate vector is built

Parameters:
v - second vector
Returns:
the distance between the instance and p according to the L2 norm
• #### distance

public T distance(Vector2D v)
Compute the distance between the instance and another vector according to the L2 norm.

Calling this method is equivalent to calling: q.subtract(p).getNorm() except that no intermediate vector is built

Parameters:
v - second vector
Returns:
the distance between the instance and p according to the L2 norm
• #### distanceInf

public T distanceInf(FieldVector2D<T> v)
Compute the distance between the instance and another vector according to the L norm.

Calling this method is equivalent to calling: q.subtract(p).getNormInf() except that no intermediate vector is built

Parameters:
v - second vector
Returns:
the distance between the instance and p according to the L norm
• #### distanceInf

public T distanceInf(Vector2D v)
Compute the distance between the instance and another vector according to the L norm.

Calling this method is equivalent to calling: q.subtract(p).getNormInf() except that no intermediate vector is built

Parameters:
v - second vector
Returns:
the distance between the instance and p according to the L norm
• #### distanceSq

public T distanceSq(FieldVector2D<T> v)
Compute the square of the distance between the instance and another vector.

Calling this method is equivalent to calling: q.subtract(p).getNormSq() except that no intermediate vector is built

Parameters:
v - second vector
Returns:
the square of the distance between the instance and p
• #### distanceSq

public T distanceSq(Vector2D v)
Compute the square of the distance between the instance and another vector.

Calling this method is equivalent to calling: q.subtract(p).getNormSq() except that no intermediate vector is built

Parameters:
v - second vector
Returns:
the square of the distance between the instance and p
• #### dotProduct

public T dotProduct(FieldVector2D<T> v)
Compute the dot-product of the instance and another vector.

The implementation uses specific multiplication and addition algorithms to preserve accuracy and reduce cancellation effects. It should be very accurate even for nearly orthogonal vectors.

Parameters:
v - second vector
Returns:
the dot product this.v
MathArrays.linearCombination(double, double, double, double, double, double)
• #### dotProduct

public T dotProduct(Vector2D v)
Compute the dot-product of the instance and another vector.

The implementation uses specific multiplication and addition algorithms to preserve accuracy and reduce cancellation effects. It should be very accurate even for nearly orthogonal vectors.

Parameters:
v - second vector
Returns:
the dot product this.v
MathArrays.linearCombination(double, double, double, double, double, double)
• #### crossProduct

public T crossProduct(FieldVector2D<T> p1,
FieldVector2D<T> p2)
Compute the cross-product of the instance and the given points.

The cross product can be used to determine the location of a point with regard to the line formed by (p1, p2) and is calculated as: $P = (x_2 - x_1)(y_3 - y_1) - (y_2 - y_1)(x_3 - x_1)$ with $$p3 = (x_3, y_3)$$ being this instance.

If the result is 0, the points are collinear, i.e. lie on a single straight line L; if it is positive, this point lies to the left, otherwise to the right of the line formed by (p1, p2).

Parameters:
p1 - first point of the line
p2 - second point of the line
Returns:
the cross-product
Cross product (Wikipedia)
• #### crossProduct

public T crossProduct(Vector2D p1,
Vector2D p2)
Compute the cross-product of the instance and the given points.

The cross product can be used to determine the location of a point with regard to the line formed by (p1, p2) and is calculated as: $P = (x_2 - x_1)(y_3 - y_1) - (y_2 - y_1)(x_3 - x_1)$ with $$p3 = (x_3, y_3)$$ being this instance.

If the result is 0, the points are collinear, i.e. lie on a single straight line L; if it is positive, this point lies to the left, otherwise to the right of the line formed by (p1, p2).

Parameters:
p1 - first point of the line
p2 - second point of the line
Returns:
the cross-product
Cross product (Wikipedia)
• #### distance1

public static <T extends CalculusFieldElement<T>> T distance1(FieldVector2D<T> p1,
FieldVector2D<T> p2)
Compute the distance between two vectors according to the L2 norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNorm() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L2 norm
• #### distance1

public static <T extends CalculusFieldElement<T>> T distance1(FieldVector2D<T> p1,
Vector2D p2)
Compute the distance between two vectors according to the L2 norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNorm() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L2 norm
• #### distance1

public static <T extends CalculusFieldElement<T>> T distance1(Vector2D p1,
FieldVector2D<T> p2)
Compute the distance between two vectors according to the L2 norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNorm() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L2 norm
• #### distance

public static <T extends CalculusFieldElement<T>> T distance(FieldVector2D<T> p1,
FieldVector2D<T> p2)
Compute the distance between two vectors according to the L2 norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNorm() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L2 norm
• #### distance

public static <T extends CalculusFieldElement<T>> T distance(FieldVector2D<T> p1,
Vector2D p2)
Compute the distance between two vectors according to the L2 norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNorm() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L2 norm
• #### distance

public static <T extends CalculusFieldElement<T>> T distance(Vector2D p1,
FieldVector2D<T> p2)
Compute the distance between two vectors according to the L2 norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNorm() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L2 norm
• #### distanceInf

public static <T extends CalculusFieldElement<T>> T distanceInf(FieldVector2D<T> p1,
FieldVector2D<T> p2)
Compute the distance between two vectors according to the L norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNormInf() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L norm
• #### distanceInf

public static <T extends CalculusFieldElement<T>> T distanceInf(FieldVector2D<T> p1,
Vector2D p2)
Compute the distance between two vectors according to the L norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNormInf() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L norm
• #### distanceInf

public static <T extends CalculusFieldElement<T>> T distanceInf(Vector2D p1,
FieldVector2D<T> p2)
Compute the distance between two vectors according to the L norm.

Calling this method is equivalent to calling: p1.subtract(p2).getNormInf() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the distance between p1 and p2 according to the L norm
• #### distanceSq

public static <T extends CalculusFieldElement<T>> T distanceSq(FieldVector2D<T> p1,
FieldVector2D<T> p2)
Compute the square of the distance between two vectors.

Calling this method is equivalent to calling: p1.subtract(p2).getNormSq() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the square of the distance between p1 and p2
• #### distanceSq

public static <T extends CalculusFieldElement<T>> T distanceSq(FieldVector2D<T> p1,
Vector2D p2)
Compute the square of the distance between two vectors.

Calling this method is equivalent to calling: p1.subtract(p2).getNormSq() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the square of the distance between p1 and p2
• #### distanceSq

public static <T extends CalculusFieldElement<T>> T distanceSq(Vector2D p1,
FieldVector2D<T> p2)
Compute the square of the distance between two vectors.

Calling this method is equivalent to calling: p1.subtract(p2).getNormSq() except that no intermediate vector is built

Type Parameters:
T - the type of the field elements
Parameters:
p1 - first vector
p2 - second vector
Returns:
the square of the distance between p1 and p2
• #### orientation

public static <T extends CalculusFieldElement<T>> T orientation(FieldVector2D<T> p,
FieldVector2D<T> q,
FieldVector2D<T> r)
Compute the orientation of a triplet of points.
Type Parameters:
T - the type of the field elements
Parameters:
p - first vector of the triplet
q - second vector of the triplet
r - third vector of the triplet
Returns:
a positive value if (p, q, r) defines a counterclockwise oriented triangle, a negative value if (p, q, r) defines a clockwise oriented triangle, and 0 if (p, q, r) are collinear or some points are equal
Since:
1.2
• #### toString

public String toString()
Get a string representation of this vector.
Overrides:
toString in class Object
Returns:
a string representation of this vector
• #### toString

public String toString(NumberFormat format)
Get a string representation of this vector.
Parameters:
format - the custom format for components
Returns:
a string representation of this vector