pythagoras.d

## Interface IVector

• ### 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` `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.
• ### Methods inherited from interface pythagoras.d.XY

`x, y`
• ### Method Detail

• #### dot

`double dot(IVector other)`
Computes and returns the dot product of this and the specified other vector.
• #### cross

`Vector cross(IVector other)`
Computes the cross product of this and the specified other vector.
Returns:
a new vector containing the result.
• #### cross

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

`Vector negate()`
Negates this vector.
Returns:
a new vector containing the result.
• #### negate

`Vector negate(Vector result)`
Negates this vector, storing the result in the supplied object.
Returns:
a reference to the result, for chaining.
• #### normalize

`Vector normalize()`
Normalizes this vector.
Returns:
a new vector containing the result.
• #### normalize

`Vector normalize(Vector result)`
Normalizes this vector, storing the result in the object supplied.
Returns:
a reference to the result, for chaining.
• #### length

`double length()`
Returns the length (magnitude) of this vector.
• #### lengthSq

`double lengthSq()`
Returns the squared length of this vector.
• #### isZero

`boolean isZero()`
Returns true if this vector has zero magnitude.
• #### distance

`double distance(IVector other)`
Returns the distance from this vector to the specified other vector.
• #### distanceSq

`double distanceSq(IVector other)`
Returns the squared distance from this vector to the specified other.
• #### angle

`double angle()`
Returns the angle of this vector.
• #### angleBetween

`double angleBetween(IVector other)`
Returns the angle between this vector and the specified other vector.
• #### scale

`Vector scale(double v)`
Scales this vector uniformly by the specified magnitude.
Returns:
a new vector containing the result.
• #### scale

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

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

```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.
Returns:
a reference to the result vector, for chaining.

`Vector add(IVector other)`
Adds a vector to this one.
Returns:
a new vector containing the result.

```Vector add(IVector other,
Vector result)```
Adds a vector to this one, storing the result in the object provided.
Returns:
a reference to the result, for chaining.

```Vector add(double x,
double y)```
Adds a vector to this one.
Returns:
a new vector containing the result.

```Vector add(double x,
double y,
Vector result)```
Adds a vector to this one and stores the result in the object provided.
Returns:
a reference to the result, for chaining.

```Vector addScaled(IVector other,
double v)```
Adds a scaled vector to this one.
Returns:
a new vector containing the result.

```Vector addScaled(IVector other,
double v,
Vector result)```
Adds a scaled vector to this one and stores the result in the supplied vector.
Returns:
a reference to the result, for chaining.
• #### subtract

`Vector subtract(IVector other)`
Subtracts a vector from this one.
Returns:
a new vector containing the result.
• #### subtract

```Vector subtract(IVector other,
Vector result)```
Subtracts a vector from this one and places the result in the supplied object.
Returns:
a reference to the result, for chaining.
• #### subtract

```Vector subtract(double x,
double y)```
Subtracts a vector from this one.
Returns:
a new vector containing the result.
• #### subtract

```Vector subtract(double x,
double y,
Vector result)```
Subtracts a vector from this one and places the result in the supplied object.
Returns:
a reference to the result, for chaining.
• #### rotate

`Vector rotate(double angle)`
Rotates this vector by the specified angle.
Returns:
a new vector containing the result.
• #### rotate

```Vector rotate(double angle,
Vector result)```
Rotates this vector by the specified angle, storing the result in the vector provided.
Returns:
a reference to the result vector, for chaining.

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

```Vector rotateScaleAndAdd(double angle,
double scale,
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.
Returns:
a reference to the result, for chaining.
• #### lerp

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

```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.
Returns:
a reference to the result, for chaining.
• #### clone

`Vector clone()`
Returns a mutable copy of this vector.