skunkworks/com/danitheskunk/skunkworks/Vec2f.java

38 lines
652 B
Java

package com.danitheskunk.skunkworks;
public final class Vec2f {
final double x, y;
//constructors
public Vec2f(double x, double y) {
this.x = x;
this.y = y;
}
//getters and setters
public double getX() {
return x;
}
public double getY() {
return y;
}
//static functions
public static Vec2f add(Vec2f a, Vec2f b) {
return new Vec2f(a.x + b.x, a.y + b.y);
}
public static Vec2f sub(Vec2f a, Vec2f b) {
return new Vec2f(a.x - b.x, a.y - b.y);
}
public static Vec2f mul(Vec2f a, double b) {
return new Vec2f(a.x * b, a.y * b);
}
public static Vec2f div(Vec2f a, double b) {
return new Vec2f(a.x / b, a.y / b);
}
}