export class Angle {
	static angleB(a, b, c, inf) {
		return this.angle10(a.x, a.y, a.z, b.x, b.y, b.z, c.x, c.y, c.z, inf);
	}

	static angle10(xA, yA, zA, xB, yB, zB, xC, yC, zC, inf) {
            return this.degre9(xA, yA, zA, xB, yB, zB, xC, yC, zC) <= inf;
	}

	static degre3B(a, b, c) {
		return this.degre9(a.x, a.y, a.z, b.x, b.y, b.z, c.x, c.y, c.z);
	}

	static degre9(xA, yA, zA, xB, yB, zB, xC, yC, zC) {

            let normAB, normAC, tmp, cosA, angleA;
            let AC = [3];
            let AB = [3];

            AB[0] = xB - xA; AB[1] = yB - yA; AB[2] = zB - zA;
            AC[0] = xC - xA; AC[1] = yC - yA; AC[2] = zC - zA;

            normAB = Math.sqrt(Math.pow( AB[0] , 2) + Math.pow( AB[1] , 2) + Math.pow( AB[2] , 2));
            normAC = Math.sqrt(Math.pow( AC[0] , 2) + Math.pow( AC[1] , 2) + Math.pow( AC[2] , 2));

            tmp = AB[0] * AC[0] + AB[1] * AC[1] + AB[2] * AC[2];

            cosA = tmp / (normAB * normAC);

            angleA = Math.acos(cosA) * 180 / Math.PI;

            return angleA;
	}

}
