<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [server](./server.md) &gt; [Vector2](./server.vector2.md)

## Vector2 class

Represents a 2D vector.

**Signature:**

```typescript
export default class Vector2 extends Float32Array implements Vector2Like 
```
**Extends:** Float32Array

**Implements:** [Vector2Like](./server.vector2like.md)

## Remarks

All vector methods result in mutation of the vector instance. This class extends `Float32Array` to provide an efficient way to create and manipulate a 2-dimensional vector. Various convenience methods are provided for common vector operations.

## Constructors

<table><thead><tr><th>

Constructor


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[(constructor)(x, y)](./server.vector2._constructor_.md)


</td><td>


</td><td>

Constructs a new instance of the `Vector2` class


</td></tr>
</tbody></table>

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[length](./server.vector2.length.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The length of the vector.


</td></tr>
<tr><td>

[magnitude](./server.vector2.magnitude.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The magnitude of the vector. Alias for `length`<!-- -->.


</td></tr>
<tr><td>

[squaredLength](./server.vector2.squaredlength.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The squared length of the vector.


</td></tr>
<tr><td>

[squaredMagnitude](./server.vector2.squaredmagnitude.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The squared magnitude of the vector. Alias for `squaredLength`<!-- -->.


</td></tr>
<tr><td>

[x](./server.vector2.x.md)


</td><td>


</td><td>

number


</td><td>

The x-component of the vector.


</td></tr>
<tr><td>

[y](./server.vector2.y.md)


</td><td>


</td><td>

number


</td><td>

The y-component of the vector.


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[add(vector2)](./server.vector2.add.md)


</td><td>


</td><td>

Adds a vector to the current vector.


</td></tr>
<tr><td>

[angle(vector2)](./server.vector2.angle.md)


</td><td>


</td><td>

Returns the angle between two vectors.


</td></tr>
<tr><td>

[ceil()](./server.vector2.ceil.md)


</td><td>


</td><td>

Rounds each component of the vector up to the nearest integer.


</td></tr>
<tr><td>

[clone()](./server.vector2.clone.md)


</td><td>


</td><td>

Returns a new vector with the same components as the current vector.


</td></tr>
<tr><td>

[copy(vector2)](./server.vector2.copy.md)


</td><td>


</td><td>

Copies the components of a vector to the current vector.


</td></tr>
<tr><td>

[create()](./server.vector2.create.md)


</td><td>

`static`


</td><td>

Creates a new `Vector2` instance.


</td></tr>
<tr><td>

[distance(vector2)](./server.vector2.distance.md)


</td><td>


</td><td>

Calculates the distance between the current vector and another vector.


</td></tr>
<tr><td>

[divide(vector2)](./server.vector2.divide.md)


</td><td>


</td><td>

Divides the current vector by another vector.


</td></tr>
<tr><td>

[dot(vector2)](./server.vector2.dot.md)


</td><td>


</td><td>

Calculates the dot product of the current vector and another vector.


</td></tr>
<tr><td>

[equals(vector2)](./server.vector2.equals.md)


</td><td>


</td><td>

Checks if the current vector is approximately equal to another vector.


</td></tr>
<tr><td>

[exactEquals(vector2)](./server.vector2.exactequals.md)


</td><td>


</td><td>

Checks if the current vector is exactly equal to another vector.


</td></tr>
<tr><td>

[floor()](./server.vector2.floor.md)


</td><td>


</td><td>

Rounds each component of the vector down to the nearest integer.


</td></tr>
<tr><td>

[invert()](./server.vector2.invert.md)


</td><td>


</td><td>

Inverts the components of the current vector.


</td></tr>
<tr><td>

[lerp(vector2, t)](./server.vector2.lerp.md)


</td><td>


</td><td>

Linearly interpolates between the current vector and another vector.


</td></tr>
<tr><td>

[max(vector2)](./server.vector2.max.md)


</td><td>


</td><td>

Sets each component of the vector to the maximum of the current vector and another vector.


</td></tr>
<tr><td>

[min(vector2)](./server.vector2.min.md)


</td><td>


</td><td>

Sets each component of the vector to the minimum of the current vector and another vector.


</td></tr>
<tr><td>

[multiply(vector2)](./server.vector2.multiply.md)


</td><td>


</td><td>

Multiplies each component of the current vector by the corresponding component of another vector.


</td></tr>
<tr><td>

[negate()](./server.vector2.negate.md)


</td><td>


</td><td>

Negates each component of the vector.


</td></tr>
<tr><td>

[normalize()](./server.vector2.normalize.md)


</td><td>


</td><td>

Normalizes the current vector.


</td></tr>
<tr><td>

[randomize(scale)](./server.vector2.randomize.md)


</td><td>


</td><td>

Randomizes the components of the current vector.


</td></tr>
<tr><td>

[rotate(vector2, angle)](./server.vector2.rotate.md)


</td><td>


</td><td>

Rotates the current vector around an origin.


</td></tr>
<tr><td>

[round()](./server.vector2.round.md)


</td><td>


</td><td>

Rounds each component of the vector to the nearest integer.


</td></tr>
<tr><td>

[scale(scale)](./server.vector2.scale.md)


</td><td>


</td><td>

Scales the current vector by a scalar value.


</td></tr>
<tr><td>

[scaleAndAdd(vector2, scale)](./server.vector2.scaleandadd.md)


</td><td>


</td><td>

Scales the current vector by a scalar value and adds the result to another vector.


</td></tr>
<tr><td>

[subtract(vector2)](./server.vector2.subtract.md)


</td><td>


</td><td>

Subtracts a vector from the current vector.


</td></tr>
<tr><td>

[toString()](./server.vector2.tostring.md)


</td><td>


</td><td>

Returns a string representation of the vector in x,y format.


</td></tr>
<tr><td>

[transformMatrix2(matrix2)](./server.vector2.transformmatrix2.md)


</td><td>


</td><td>

Transforms the current vector by a matrix2.


</td></tr>
<tr><td>

[transformMatrix3(matrix3)](./server.vector2.transformmatrix3.md)


</td><td>


</td><td>

Transforms the current vector by a matrix3.


</td></tr>
<tr><td>

[transformMatrix4(matrix4)](./server.vector2.transformmatrix4.md)


</td><td>


</td><td>

Transforms the current vector by a matrix4.


</td></tr>
<tr><td>

[zero()](./server.vector2.zero.md)


</td><td>


</td><td>

Sets each component of the vector to zero.


</td></tr>
</tbody></table>
