38 lines
660 B
Java
38 lines
660 B
Java
package com.danitheskunk.skunkworks;
|
|
|
|
public final class Vec2f {
|
|
private 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);
|
|
}
|
|
}
|