109 lines
1.5 KiB
Java
109 lines
1.5 KiB
Java
package speiger.src.coreengine.math.vector.shorts;
|
|
|
|
import java.util.Objects;
|
|
|
|
public class Vec3sImmutable implements Vec3s
|
|
{
|
|
final short x;
|
|
final short y;
|
|
final short z;
|
|
|
|
public Vec3sImmutable()
|
|
{
|
|
x = 0;
|
|
y = 0;
|
|
z = 0;
|
|
}
|
|
|
|
public Vec3sImmutable(short value)
|
|
{
|
|
x = value;
|
|
y = value;
|
|
z = value;
|
|
}
|
|
|
|
public Vec3sImmutable(short x, short y, short z)
|
|
{
|
|
this.x = x;
|
|
this.y = y;
|
|
this.z = z;
|
|
}
|
|
|
|
@Override
|
|
public boolean isMutable()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public short getX()
|
|
{
|
|
return x;
|
|
}
|
|
|
|
@Override
|
|
public short getY()
|
|
{
|
|
return y;
|
|
}
|
|
|
|
@Override
|
|
public short getZ()
|
|
{
|
|
return z;
|
|
}
|
|
|
|
@Override
|
|
public Vec3s setX(short x)
|
|
{
|
|
return this.x == x ? this : Vec3s.of(x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public Vec3s setY(short y)
|
|
{
|
|
return this.y == y ? this : Vec3s.of(x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public Vec3s setZ(short z)
|
|
{
|
|
return this.z == z ? this : Vec3s.of(x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public Vec3s copy()
|
|
{
|
|
return Vec3s.of(this);
|
|
}
|
|
|
|
@Override
|
|
public Vec3s set(short x, short y, short z)
|
|
{
|
|
return this.x == x && this.y == y && this.z == z ? this : Vec3s.of(x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode()
|
|
{
|
|
return Objects.hash(x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj)
|
|
{
|
|
if(obj instanceof Vec3s)
|
|
{
|
|
Vec3s vec = (Vec3s)obj;
|
|
return vec.getX() == x && vec.getY() == y && vec.getZ() == z;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public String toString()
|
|
{
|
|
return "Vec3s[x="+x+", y="+y+", z="+z+"]";
|
|
}
|
|
}
|