added Vec2f and Vec2i

This commit is contained in:
Dani The Skunk 2022-09-14 05:44:38 +02:00
parent 0d13c30983
commit 77ef6a6e56
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,37 @@
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);
}
}

View File

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