Scratch for Java

Vector2

The Vector2 class represents a 2D vector with x and y coordinates. It provides various methods for vector operations such as addition, subtraction, scalar multiplication, dot product, rotation, and more.

Instances of this class are immutable.

Example usage:

Vector2 v1 = new Vector2(3, 4);
Vector2 v2 = new Vector2(1, 2);
Vector2 sum = v1.add(v2);
double length = v1.length();
Vector2