Skip to content

Class Vector2

Moderr edited this page Feb 28, 2023 · 1 revision
class Vector2

Structure represents 2D positions and vectors.

Constructor

Constructs a new Vector2 with the given coordinates.
Params:
number x - X-coordinate (Default: 0)
number y - Y-coordinate (Default: 0)

Public Properties

x - X-coordinate.
y - Y-coordinate.

Method Summary

Instance Methods

Method Description
getX() Gets the X-coordinate.
getY() Gets the Y-coordinate.
setX(newX) Sets the X-coordinate.
setY(newY) Sets the Y-coordinate.
addX(x) Adds the x to X-coordinate.
addY(y) Adds the y to Y-coordinate.
add(v) Adds the vector by another.
subtract(v) Performs subtraction components from the other vector components.
multiply(scalar) Performs scalar multiplication, multiplying all components with scalar.
divide(scalar) Performs scalar divination, dividing all components with scalar.
distance(v) Gets the distance between this vector and another.

Method Details

W.I.P

Clone this wiki locally