pythagoras.d

## Class AbstractVector

• All Implemented Interfaces:
IVector, XY
Direct Known Subclasses:
Vector

```public abstract class AbstractVector
extends Object
implements IVector```
Provides most of the implementation of `IVector`, obtaining only x and y from the derived class.
• ### Constructor Summary

Constructors
Constructor and Description
`AbstractVector()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Vector` ```add(double x, double y)```
Adds a vector to this one.
`Vector` ```add(double x, double y, Vector result)```
Adds a vector to this one and stores the result in the object provided.
`Vector` `add(IVector other)`
Adds a vector to this one.
`Vector` ```add(IVector other, Vector result)```
Adds a vector to this one, storing the result in the object provided.
`Vector` ```addScaled(IVector other, double v)```
Adds a scaled vector to this one.
`Vector` ```addScaled(IVector other, double v, Vector result)```
Adds a scaled vector to this one and stores the result in the supplied vector.
`double` `angle()`
Returns the angle of this vector.
`double` `angleBetween(IVector other)`
Returns the angle between this vector and the specified other vector.
`Vector` `clone()`
Returns a mutable copy of this vector.
`Vector` `cross(IVector other)`
Computes the cross product of this and the specified other vector.
`Vector` ```cross(IVector other, Vector result)```
Computes the cross product of this and the specified other vector, placing the result in the object supplied.
`double` `distance(IVector other)`
Returns the distance from this vector to the specified other vector.
`double` `distanceSq(IVector other)`
Returns the squared distance from this vector to the specified other.
`double` `dot(IVector other)`
Computes and returns the dot product of this and the specified other vector.
`boolean` `equals(Object obj)`
`int` `hashCode()`
`boolean` `isZero()`
Returns true if this vector has zero magnitude.
`double` `length()`
Returns the length (magnitude) of this vector.
`double` `lengthSq()`
Returns the squared length of this vector.
`Vector` ```lerp(IVector other, double t)```
Linearly interpolates between this and the specified other vector by the supplied amount.
`Vector` ```lerp(IVector other, double t, Vector result)```
Linearly interpolates between this and the supplied other vector by the supplied amount, storing the result in the supplied object.
`Vector` `negate()`
Negates this vector.
`Vector` `negate(Vector result)`
Negates this vector, storing the result in the supplied object.
`Vector` `normalize()`
Normalizes this vector.
`Vector` `normalize(Vector result)`
Normalizes this vector, storing the result in the object supplied.
`Vector` `rotate(double angle)`
Rotates this vector by the specified angle.
`Vector` ```rotate(double angle, Vector result)```
Rotates this vector by the specified angle, storing the result in the vector provided.
`Vector` ```rotateAndAdd(double angle, IVector add, Vector result)```
Rotates this vector by the specified angle and adds another vector to it, placing the result in the object provided.
`Vector` ```rotateScaleAndAdd(double angle, double scale, IVector add, Vector result)```
Rotates this vector by the specified angle, applies a uniform scale, and adds another vector to it, placing the result in the object provided.
`Vector` `scale(double v)`
Scales this vector uniformly by the specified magnitude.
`Vector` ```scale(double v, Vector result)```
Scales this vector uniformly by the specified magnitude, and places the result in the supplied object.
`Vector` `scale(IVector other)`
Scales this vector's x and y components independently by the x and y components of the supplied vector.
`Vector` ```scale(IVector other, Vector result)```
Scales this vector's x and y components independently by the x and y components of the supplied vector, and stores the result in the object provided.
`Vector` ```subtract(double x, double y)```
Subtracts a vector from this one.
`Vector` ```subtract(double x, double y, Vector result)```
Subtracts a vector from this one and places the result in the supplied object.
`Vector` `subtract(IVector other)`
Subtracts a vector from this one.
`Vector` ```subtract(IVector other, Vector result)```
Subtracts a vector from this one and places the result in the supplied object.
`String` `toString()`
• ### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface pythagoras.d.XY

`x, y`
• ### Constructor Detail

• #### AbstractVector

`public AbstractVector()`
• ### Method Detail

• #### dot

`public double dot(IVector other)`
Description copied from interface: `IVector`
Computes and returns the dot product of this and the specified other vector.
Specified by:
`dot` in interface `IVector`
• #### cross

`public Vector cross(IVector other)`
Description copied from interface: `IVector`
Computes the cross product of this and the specified other vector.
Specified by:
`cross` in interface `IVector`
Returns:
a new vector containing the result.
• #### cross

```public Vector cross(IVector other,
Vector result)```
Description copied from interface: `IVector`
Computes the cross product of this and the specified other vector, placing the result in the object supplied.
Specified by:
`cross` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### negate

`public Vector negate()`
Description copied from interface: `IVector`
Negates this vector.
Specified by:
`negate` in interface `IVector`
Returns:
a new vector containing the result.
• #### negate

`public Vector negate(Vector result)`
Description copied from interface: `IVector`
Negates this vector, storing the result in the supplied object.
Specified by:
`negate` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### normalize

`public Vector normalize()`
Description copied from interface: `IVector`
Normalizes this vector.
Specified by:
`normalize` in interface `IVector`
Returns:
a new vector containing the result.
• #### normalize

`public Vector normalize(Vector result)`
Description copied from interface: `IVector`
Normalizes this vector, storing the result in the object supplied.
Specified by:
`normalize` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### length

`public double length()`
Description copied from interface: `IVector`
Returns the length (magnitude) of this vector.
Specified by:
`length` in interface `IVector`
• #### lengthSq

`public double lengthSq()`
Description copied from interface: `IVector`
Returns the squared length of this vector.
Specified by:
`lengthSq` in interface `IVector`
• #### isZero

`public boolean isZero()`
Description copied from interface: `IVector`
Returns true if this vector has zero magnitude.
Specified by:
`isZero` in interface `IVector`
• #### distance

`public double distance(IVector other)`
Description copied from interface: `IVector`
Returns the distance from this vector to the specified other vector.
Specified by:
`distance` in interface `IVector`
• #### distanceSq

`public double distanceSq(IVector other)`
Description copied from interface: `IVector`
Returns the squared distance from this vector to the specified other.
Specified by:
`distanceSq` in interface `IVector`
• #### angle

`public double angle()`
Description copied from interface: `IVector`
Returns the angle of this vector.
Specified by:
`angle` in interface `IVector`
• #### angleBetween

`public double angleBetween(IVector other)`
Description copied from interface: `IVector`
Returns the angle between this vector and the specified other vector.
Specified by:
`angleBetween` in interface `IVector`
• #### scale

`public Vector scale(double v)`
Description copied from interface: `IVector`
Scales this vector uniformly by the specified magnitude.
Specified by:
`scale` in interface `IVector`
Returns:
a new vector containing the result.
• #### scale

```public Vector scale(double v,
Vector result)```
Description copied from interface: `IVector`
Scales this vector uniformly by the specified magnitude, and places the result in the supplied object.
Specified by:
`scale` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### scale

`public Vector scale(IVector other)`
Description copied from interface: `IVector`
Scales this vector's x and y components independently by the x and y components of the supplied vector.
Specified by:
`scale` in interface `IVector`
Returns:
a new vector containing the result.
• #### scale

```public Vector scale(IVector other,
Vector result)```
Description copied from interface: `IVector`
Scales this vector's x and y components independently by the x and y components of the supplied vector, and stores the result in the object provided.
Specified by:
`scale` in interface `IVector`
Returns:
a reference to the result vector, for chaining.

`public Vector add(IVector other)`
Description copied from interface: `IVector`
Adds a vector to this one.
Specified by:
`add` in interface `IVector`
Returns:
a new vector containing the result.

```public Vector add(IVector other,
Vector result)```
Description copied from interface: `IVector`
Adds a vector to this one, storing the result in the object provided.
Specified by:
`add` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### subtract

`public Vector subtract(IVector other)`
Description copied from interface: `IVector`
Subtracts a vector from this one.
Specified by:
`subtract` in interface `IVector`
Returns:
a new vector containing the result.
• #### subtract

```public Vector subtract(IVector other,
Vector result)```
Description copied from interface: `IVector`
Subtracts a vector from this one and places the result in the supplied object.
Specified by:
`subtract` in interface `IVector`
Returns:
a reference to the result, for chaining.

```public Vector add(double x,
double y)```
Description copied from interface: `IVector`
Adds a vector to this one.
Specified by:
`add` in interface `IVector`
Returns:
a new vector containing the result.

```public Vector add(double x,
double y,
Vector result)```
Description copied from interface: `IVector`
Adds a vector to this one and stores the result in the object provided.
Specified by:
`add` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### subtract

```public Vector subtract(double x,
double y)```
Description copied from interface: `IVector`
Subtracts a vector from this one.
Specified by:
`subtract` in interface `IVector`
Returns:
a new vector containing the result.
• #### subtract

```public Vector subtract(double x,
double y,
Vector result)```
Description copied from interface: `IVector`
Subtracts a vector from this one and places the result in the supplied object.
Specified by:
`subtract` in interface `IVector`
Returns:
a reference to the result, for chaining.

```public Vector addScaled(IVector other,
double v)```
Description copied from interface: `IVector`
Adds a scaled vector to this one.
Specified by:
`addScaled` in interface `IVector`
Returns:
a new vector containing the result.

```public Vector addScaled(IVector other,
double v,
Vector result)```
Description copied from interface: `IVector`
Adds a scaled vector to this one and stores the result in the supplied vector.
Specified by:
`addScaled` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### rotate

`public Vector rotate(double angle)`
Description copied from interface: `IVector`
Rotates this vector by the specified angle.
Specified by:
`rotate` in interface `IVector`
Returns:
a new vector containing the result.
• #### rotate

```public Vector rotate(double angle,
Vector result)```
Description copied from interface: `IVector`
Rotates this vector by the specified angle, storing the result in the vector provided.
Specified by:
`rotate` in interface `IVector`
Returns:
a reference to the result vector, for chaining.

```public Vector rotateAndAdd(double angle,
Vector result)```
Description copied from interface: `IVector`
Rotates this vector by the specified angle and adds another vector to it, placing the result in the object provided.
Specified by:
`rotateAndAdd` in interface `IVector`
Returns:
a reference to the result, for chaining.

```public Vector rotateScaleAndAdd(double angle,
double scale,
Vector result)```
Description copied from interface: `IVector`
Rotates this vector by the specified angle, applies a uniform scale, and adds another vector to it, placing the result in the object provided.
Specified by:
`rotateScaleAndAdd` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### lerp

```public Vector lerp(IVector other,
double t)```
Description copied from interface: `IVector`
Linearly interpolates between this and the specified other vector by the supplied amount.
Specified by:
`lerp` in interface `IVector`
Returns:
a new vector containing the result.
• #### lerp

```public Vector lerp(IVector other,
double t,
Vector result)```
Description copied from interface: `IVector`
Linearly interpolates between this and the supplied other vector by the supplied amount, storing the result in the supplied object.
Specified by:
`lerp` in interface `IVector`
Returns:
a reference to the result, for chaining.
• #### clone

`public Vector clone()`
Description copied from interface: `IVector`
Returns a mutable copy of this vector.
Specified by:
`clone` in interface `IVector`
Overrides:
`clone` in class `Object`
• #### equals

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

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

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