/** * Adds the values of the given source vector to those of this vector and returns them in store. * * @param source * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. * @return (this.x + source.x, this.y + source.y, this.z + source.z, this.w + source.w) * @throws NullPointerException * if source is null. */ @Override public Vector4 add(final ReadOnlyVector4 source, final Vector4 store) { return add(source.getX(), source.getY(), source.getZ(), source.getW(), store); }
@Test public void testAdd() { final Vector4 vec1 = new Vector4(); final Vector4 vec2 = new Vector4(Vector4.ONE); vec1.addLocal(1, 2, 3, 4); assertEquals(new Vector4(1, 2, 3, 4), vec1); vec1.addLocal(-1, -2, -3, -4); assertEquals(Vector4.ZERO, vec1); vec1.zero(); vec1.addLocal(vec2); assertEquals(Vector4.ONE, vec1); vec1.zero(); final Vector4 vec3 = vec1.add(vec2, new Vector4()); assertEquals(Vector4.ZERO, vec1); assertEquals(Vector4.ONE, vec3); final Vector4 vec4 = vec1.add(0, 0, 0, 1, null); assertEquals(Vector4.ZERO, vec1); assertEquals(Vector4.UNIT_W, vec4); }
/** * Adds the values of the given source vector to those of this vector and returns them in store. * * @param source * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. * @return (this.x + source.x, this.y + source.y, this.z + source.z, this.w + source.w) * @throws NullPointerException * if source is null. */ @Override public Vector4 add(final ReadOnlyVector4 source, final Vector4 store) { return add(source.getX(), source.getY(), source.getZ(), source.getW(), store); }