summaryrefslogtreecommitdiff
path: root/2026/games_submissions/ellg/vector.js
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-08-18 00:08:28 -0400
committerLLLL Colonq <llll@colonq>2026-08-18 00:08:28 -0400
commit32a62cfcb925225359a5c90761b795f2f737ebd2 (patch)
tree95c2261964803b19f2d39cb35d8d514ed6e5a6f4 /2026/games_submissions/ellg/vector.js
parentde99c5f7636a952025ea13de02bafd25bcb6bdec (diff)
Re-populate games
Diffstat (limited to '2026/games_submissions/ellg/vector.js')
-rw-r--r--2026/games_submissions/ellg/vector.js64
1 files changed, 0 insertions, 64 deletions
diff --git a/2026/games_submissions/ellg/vector.js b/2026/games_submissions/ellg/vector.js
deleted file mode 100644
index cf32d81..0000000
--- a/2026/games_submissions/ellg/vector.js
+++ /dev/null
@@ -1,64 +0,0 @@
-export class Vector {
- static of([x, y]) {
- return new Vector(x, y)
- }
-
- constructor(x, y) {
- this.x = x
- this.y = y
- }
-
- add(val) {
- return new Vector(this.x + val.x, this.y + val.y)
- }
-
- subtract(val) {
- return new Vector(this.x - val.x, this.y - val.y)
- }
-
- multiply(scalar) {
- return new Vector(this.x * scalar, this.y * scalar)
- }
-
- divide(scalar) {
- return new Vector(this.x / scalar, this.y / scalar)
- }
-
- dot(other) {
- return this.x * other.x + this.y * other.y
- }
-
- cross(other) {
- return this.x * other.y - other.x * this.y
- }
-
- hadamard(other) {
- return new Vector(this.x * other.x, this.y * other.y)
- }
-
- length() {
- return Math.sqrt(this.x ** 2 + this.y ** 2)
- }
-
- distance(other) {
- return this.subtract(other).length()
- }
-
- normalize() {
- const length = this.length()
- if (length === 0) {
- return new Vector(0, 0)
- }
- return new Vector(this.x / length, this.y / length)
- }
-
- rotateByRadians(radians) {
- const cos = Math.cos(radians)
- const sin = Math.sin(radians)
- return new Vector(this.x * cos - this.y * sin, this.x * sin + this.y * cos)
- }
-
- rotateByDegrees(degrees) {
- return this.rotateByRadians((degrees * Math.PI) / 180)
- }
-}