Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,40 @@
class Vector {
constructor(x, y) {
this.x = x;
this.y = y;
this.length = Math.hypot(this.x, this.y);
this.angle = Math.atan2(this.y, this.x);
}
add(v) {
const sum = new Vector(this.x + v.x, this.y + v.y);
return sum;
}
sub(v) {
const diff = new Vector(this.x - v.x, this.y - v.y);
return diff;
}
mul(c) {
const scaled = new Vector(c * this.x, c * this.y);
return scaled;
}
div(c) {
const scaled = new Vector(this.x / c, this.y / c);
return scaled;
}
dot(v) {
return this.x * v.x + this.y * v.y;
}
print() {
console.log(`2D vector: (${this.x}, ${this.y})`);
}
polar() {
console.log(`2D vector (polar): (${this.length}, ${this.angle})`);
}
}