VecmathUtil { static List<Vector2d> newUnitVectors(final IAtom fromAtom, final List<IAtom> toAtoms) { final List<Vector2d> unitVectors = new ArrayList<Vector2d>(toAtoms.size()); for (final IAtom toAtom : toAtoms) { unitVectors.add(newUnitVector(fromAtom.getPoint2d(), toAtom.getPoint2d())); } return unitVectors; } private  VecmathUtil();   }
@Test public void testNewUnitVectors() throws Exception { IAtom fromAtom = mock(IAtom.class); IAtom toAtom1 = mock(IAtom.class); IAtom toAtom2 = mock(IAtom.class); IAtom toAtom3 = mock(IAtom.class); when(fromAtom.getPoint2d()).thenReturn(new Point2d(4, 2)); when(toAtom1.getPoint2d()).thenReturn(new Point2d(-5, 3)); when(toAtom2.getPoint2d()).thenReturn(new Point2d(6, -4)); when(toAtom3.getPoint2d()).thenReturn(new Point2d(7, 5)); List<Vector2d> vectors = VecmathUtil.newUnitVectors(fromAtom, Arrays.asList(toAtom1, toAtom2, toAtom3)); assertThat(vectors.size(), is(3)); assertThat(vectors.get(0).x, closeTo(-0.993, 0.01)); assertThat(vectors.get(0).y, closeTo(0.110, 0.01)); assertThat(vectors.get(1).x, closeTo(0.316, 0.01)); assertThat(vectors.get(1).y, closeTo(-0.948, 0.01)); assertThat(vectors.get(2).x, closeTo(0.707, 0.01)); assertThat(vectors.get(2).y, closeTo(0.707, 0.01)); }