package speiger.src.coreengine.math.vector.doubles;

import java.util.Objects;

public class Vec3dMutable implements Vec3d {
	double x;
	double y;
	double z;
	
	public Vec3dMutable() {
		x = 0;
		y = 0;
		z = 0;
	}
	
	public Vec3dMutable(double value) {
		x = value;
		y = value;
		z = value;
	}
	
	public Vec3dMutable(double x, double y, double z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	@Override
	public boolean isMutable() { return true; }
	@Override
	public double x() { return x; }
	@Override
	public double y() { return y; }
	@Override
	public double z() { return z; }
	
	@Override
	public Vec3d x(double x) {
		this.x = x;
		return this;
	}
	
	@Override
	public Vec3d y(double y) {
		this.y = y;
		return this;
	}
	
	@Override
	public Vec3d z(double z) {
		this.z = z;
		return this;
	}
	
	@Override
	public Vec3d copy() { return Vec3d.mutable(this); }
	
	@Override
	public Vec3d set(double x, double y, double z) {
		this.x = x;
		this.y = y;
		this.z = z;
		return this;
	}
	
	@Override
	public int hashCode() { return Objects.hash(x, y, z); }
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Vec3d) {
			Vec3d vec = (Vec3d)obj;
			return vec.x() == x && vec.y() == y && vec.z() == z;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec3d[x="+x+", y="+y+", z="+z+"]"; }
}
