pythagoras.f

## Class Vector

• All Implemented Interfaces:
IVector, XY

```public class Vector
extends AbstractVector```
Represents a vector in a plane.
• ### Field Summary

Fields
Modifier and Type Field and Description
`float` `x`
The x-component of the vector.
`float` `y`
The y-component of the vector.
• ### Constructor Summary

Constructors
Constructor and Description
`Vector()`
Creates a vector with zero x and y components.
```Vector(float x, float y)```
Creates a vector with the specified x and y components.
`Vector(XY other)`
Creates a vector equal to `other`.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Vector` ```addLocal(float x, float y)```
Adds a vector in-place to this one.
`Vector` `addLocal(IVector other)`
Adds a vector in-place to this one.
`Vector` ```addScaledLocal(IVector other, float v)```
Adds a scaled vector in-place to this one.
`Vector` `crossLocal(IVector other)`
Computes the cross product of this and the specified other vector, storing the result in this vector.
`Vector` ```lerpLocal(IVector other, float t)```
Linearly interpolates between this and `other` in-place by the supplied amount.
`Vector` `negateLocal()`
Negates this vector in-place.
`Vector` `normalizeLocal()`
Normalizes this vector in-place.
`Vector` `rotateLocal(float angle)`
Rotates this vector in-place by the specified angle.
`Vector` `scaleLocal(float v)`
Scales this vector in place, uniformly by the specified magnitude.
`Vector` `scaleLocal(IVector other)`
Scales this vector's x and y components, in place, independently by the x and y components of the supplied vector.
`Vector` `set(float[] values)`
Copies the elements of an array.
`Vector` ```set(float x, float y)```
Sets all of the elements of the vector.
`Vector` `set(XY other)`
Copies the elements of another vector.
`Vector` `setAngle(float angle)`
Sets this vector's angle, preserving its magnitude.
`Vector` `setLength(float length)`
Sets this vector's magnitude, preserving its angle.
`Vector` ```subtractLocal(float x, float y)```
Subtracts a vector in-place from this one.
`Vector` `subtractLocal(IVector other)`
Subtracts a vector in-place from this one.
`float` `x()`
The x coordinate.
`float` `y()`
The y coordinate.
• ### Methods inherited from class pythagoras.f.AbstractVector

`add, add, add, add, addScaled, addScaled, angle, angleBetween, clone, cross, cross, distance, distanceSq, dot, equals, hashCode, isZero, length, lengthSq, lerp, lerp, negate, negate, normalize, normalize, rotate, rotate, rotateAndAdd, rotateScaleAndAdd, scale, scale, scale, scale, subtract, subtract, subtract, subtract, toString`
• ### Methods inherited from class java.lang.Object

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

• #### x

`public float x`
The x-component of the vector.
• #### y

`public float y`
The y-component of the vector.
• ### Constructor Detail

• #### Vector

```public Vector(float x,
float y)```
Creates a vector with the specified x and y components.
• #### Vector

`public Vector(XY other)`
Creates a vector equal to `other`.
• #### Vector

`public Vector()`
Creates a vector with zero x and y components.
• ### Method Detail

• #### crossLocal

`public Vector crossLocal(IVector other)`
Computes the cross product of this and the specified other vector, storing the result in this vector.
Returns:
a reference to this vector, for chaining.
• #### negateLocal

`public Vector negateLocal()`
Negates this vector in-place.
Returns:
a reference to this vector, for chaining.
• #### normalizeLocal

`public Vector normalizeLocal()`
Normalizes this vector in-place.
Returns:
a reference to this vector, for chaining.
• #### scaleLocal

`public Vector scaleLocal(float v)`
Scales this vector in place, uniformly by the specified magnitude.
Returns:
a reference to this vector, for chaining.
• #### scaleLocal

`public Vector scaleLocal(IVector other)`
Scales this vector's x and y components, in place, independently by the x and y components of the supplied vector.
Returns:
a reference to this vector, for chaining.

`public Vector addLocal(IVector other)`
Adds a vector in-place to this one.
Returns:
a reference to this vector, for chaining.
• #### subtractLocal

`public Vector subtractLocal(IVector other)`
Subtracts a vector in-place from this one.
Returns:
a reference to this vector, for chaining.

```public Vector addLocal(float x,
float y)```
Adds a vector in-place to this one.
Returns:
a reference to this vector, for chaining.
• #### subtractLocal

```public Vector subtractLocal(float x,
float y)```
Subtracts a vector in-place from this one.
Returns:
a reference to this vector, for chaining.

```public Vector addScaledLocal(IVector other,
float v)```
Adds a scaled vector in-place to this one.
Returns:
a reference to this vector, for chaining.
• #### rotateLocal

`public Vector rotateLocal(float angle)`
Rotates this vector in-place by the specified angle.
Returns:
a reference to this vector, for chaining.
• #### lerpLocal

```public Vector lerpLocal(IVector other,
float t)```
Linearly interpolates between this and `other` in-place by the supplied amount.
Returns:
a reference to this vector, for chaining.
• #### set

`public Vector set(XY other)`
Copies the elements of another vector.
Returns:
a reference to this vector, for chaining.
• #### set

`public Vector set(float[] values)`
Copies the elements of an array.
Returns:
a reference to this vector, for chaining.
• #### set

```public Vector set(float x,
float y)```
Sets all of the elements of the vector.
Returns:
a reference to this vector, for chaining.
• #### setAngle

`public Vector setAngle(float angle)`
Sets this vector's angle, preserving its magnitude.
Returns:
a reference to this vector, for chaining.
• #### setLength

`public Vector setLength(float length)`
Sets this vector's magnitude, preserving its angle.
• #### x

`public float x()`
Description copied from interface: `XY`
The x coordinate.
• #### y

`public float y()`
Description copied from interface: `XY`
The y coordinate.