65 lines
1.1 KiB
Java
65 lines
1.1 KiB
Java
package speiger.src.coreengine.math.vector.floats;
|
|
|
|
import java.util.Objects;
|
|
|
|
public class Vec2fMutable implements Vec2f {
|
|
float x;
|
|
float y;
|
|
|
|
public Vec2fMutable() {}
|
|
|
|
public Vec2fMutable(float value) {
|
|
x = value;
|
|
y = value;
|
|
}
|
|
|
|
public Vec2fMutable(float x, float y) {
|
|
this.x = x;
|
|
this.y = y;
|
|
}
|
|
|
|
@Override
|
|
public boolean isMutable() { return true; }
|
|
@Override
|
|
public float getX() { return x; }
|
|
@Override
|
|
public float getY() { return y; }
|
|
|
|
@Override
|
|
public Vec2f setX(float x) {
|
|
this.x = x;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Vec2f setY(float y) {
|
|
this.y = y;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Vec2f copy() { return Vec2f.mutable(this); }
|
|
|
|
@Override
|
|
public Vec2f set(float x, float y) {
|
|
this.x = x;
|
|
this.y = y;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() { return Objects.hash(x, y); }
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if(obj instanceof Vec2f) {
|
|
Vec2f vec = (Vec2f)obj;
|
|
return vec.getX() == x && vec.getY() == y;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public String toString() { return "Vec2f[x="+x+", y="+y+"]"; }
|
|
}
|