using UnityEngine;

public class Vector {
    Vector3 vec; // in m

    public Vector(Vector3 vec) {
        this.vec = vec;
    }

	public Vector(float x, float y, float z) {
		this.vec = new Vector3(x, y, z);
	}

    public Vector3 getValue() {
        return vec;
    }

	public float x() {
		return vec.x;
	}

	public float y() {
		return vec.y;
	}

	public float z() {
		return vec.z;
	}

    public float norm() {
        return vec.magnitude;
    }

    public Vector normalized() {
        return new Vector(vec.normalized);
    }

	public float dot(Vector other) {
		return vec.x * other.vec.x + vec.y * other.vec.y + vec.z * other.vec.z;
	}

	public float angle(Vector other) {
		Vector firstNormalized = this.normalized();
		Vector secondNormalized = other.normalized();

		float dot = firstNormalized.dot(secondNormalized);
		if (dot > 1.0f) { //thanks shitty float precision
			dot = 1.0f;
		}

		return Mathf.Acos(dot) * Mathf.Sign(firstNormalized.x() * secondNormalized.y() - firstNormalized.y() * secondNormalized.x());
	}

    public static Vector operator *(Vector v, float val) {
        return new Vector(v.vec * val);
    }
}
