diff --git a/src/main/java/de/oshgnacknak/gruphi/Vector.java b/src/main/java/de/oshgnacknak/gruphi/Vector.java index 560fd50..1d6a453 100644 --- a/src/main/java/de/oshgnacknak/gruphi/Vector.java +++ b/src/main/java/de/oshgnacknak/gruphi/Vector.java @@ -2,18 +2,18 @@ package de.oshgnacknak.gruphi; public class Vector { - double x, y; + public double x, y; public Vector(double x, double y) { this.x = x; this.y = y; } - Vector copy() { + public Vector copy() { return new Vector(x, y); } - Vector add(Vector v) { + public Vector add(Vector v) { x += v.x; y += v.y; return this; @@ -25,7 +25,7 @@ public class Vector { return this; } - Vector mul(double d) { + public Vector mul(double d) { x *= d; y *= d; return this; @@ -35,11 +35,11 @@ public class Vector { return x*v.x + y*v.y; } - double mag() { + public double mag() { return Math.sqrt(dot(this)); } - Vector norm() { + public Vector norm() { return mul(1 / mag()); } @@ -47,18 +47,18 @@ public class Vector { return mul(mag/this.mag()); } - double dist(Vector v) { + public double dist(Vector v) { return dist(v.x, v.y); } - double dist(double x, double y) { + public double dist(double x, double y) { var dx = this.x - x; var dy = this.y - y; return Math.sqrt(dx*dx + dy*dy); } - double angle() { + public double angle() { return Math.atan2(y, x); } }