SvgCoordinateUtils { public static double calculateAngleBetweenTwoVectors(Vector vectorA, Vector vectorB) { return Math.acos((double) vectorA.dot(vectorB) / ((double) vectorA.length() * (double) vectorB.length())); }  static String[] makeRelativeOperatorCoordinatesAbsolute(String[] relativeCoordinates,
            double[] currentCoordinates); static double calculateAngleBetweenTwoVectors(Vector vectorA, Vector vectorB);  }
@Test public void calculateAngleBetweenTwoVectors45degTest() { Vector vectorA = new Vector(1, 0, 0); Vector vectorB = new Vector(1, 1, 0); double expected = Math.PI / 4; double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); Assert.assertEquals(expected, actual, delta); }
@Test public void calculateAngleBetweenTwoVectors45degInverseTest() { Vector vectorA = new Vector(1, 0, 0); Vector vectorB = new Vector(1, -1, 0); double expected = Math.PI / 4; double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); Assert.assertEquals(expected, actual, delta); }
@Test public void calculateAngleBetweenTwoVectors135degTest() { Vector vectorA = new Vector(1, 0, 0); Vector vectorB = new Vector(-1, 1, 0); double expected = (Math.PI - Math.PI / 4); double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); Assert.assertEquals(expected, actual, delta); }
@Test public void calculateAngleBetweenTwoVectors135degInverseTest() { Vector vectorA = new Vector(1, 0, 0); Vector vectorB = new Vector(-1, -1, 0); double expected = (Math.PI - Math.PI / 4); double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); Assert.assertEquals(expected, actual, delta); }
@Test public void calculateAngleBetweenTwoVectors90degTest() { Vector vectorA = new Vector(1, 0, 0); Vector vectorB = new Vector(0, 1, 0); double expected = Math.PI / 2; double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); Assert.assertEquals(expected, actual, delta); }
@Test public void calculateAngleBetweenTwoVectors180degTest() { Vector vectorA = new Vector(1, 0, 0); Vector vectorB = new Vector(-1, 0, 0); double expected = Math.PI; double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); Assert.assertEquals(expected, actual, delta); }