86 lines
1.6 KiB
Java
86 lines
1.6 KiB
Java
package speiger.src.coreengine.math.vector.quaternion;
|
|
|
|
import java.util.Arrays;
|
|
|
|
public class QuaternionMutable implements Quaternion {
|
|
float x;
|
|
float y;
|
|
float z;
|
|
float w;
|
|
|
|
public QuaternionMutable() {
|
|
x = 0F;
|
|
y = 0F;
|
|
z = 0F;
|
|
w = 1F;
|
|
}
|
|
|
|
public QuaternionMutable(float x, float y, float z, float w) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.z = z;
|
|
this.w = w;
|
|
}
|
|
|
|
@Override
|
|
public Quaternion setX(float x) {
|
|
this.x = x;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Quaternion setY(float y) {
|
|
this.y = y;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Quaternion setZ(float z) {
|
|
this.z = z;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Quaternion setW(float w) {
|
|
this.w = w;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public float getX() { return x; }
|
|
@Override
|
|
public float getY() { return y; }
|
|
@Override
|
|
public float getZ() { return z; }
|
|
@Override
|
|
public float getW() { return w; }
|
|
|
|
@Override
|
|
public Quaternion set(float x, float y, float z, float w) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.z = z;
|
|
this.w = w;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Quaternion copy() { return Quaternion.mutable(this); }
|
|
@Override
|
|
public boolean isMutable() { return true; }
|
|
@Override
|
|
public int hashCode() { return Arrays.hashCode(new float[] {x, y, z, w}); }
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if(obj instanceof Quaternion) {
|
|
Quaternion other = (Quaternion)obj;
|
|
return other.getX() == x && other.getY() == y && other.getZ() == z && other.getW() == w;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public String toString() { return "Quaternion[x="+x+", y="+y+", z="+z+", w="+w+"]"; }
|
|
}
|