@Override public Vector4 clone() { return new Vector4(this); }
public BMTextBackground(final String name, final BMText text, final Texture texture) { this(name, text, texture, new Vector4(0.25, 0.25, 0.25, 0.25)); }
@Override public Vector4 clone() { return new Vector4(this); }
public void setEnvPlaneR(final ReadOnlyVector4 plane) { if (plane == null) { _envPlaneR = null; return; } else if (_envPlaneR == null) { _envPlaneR = new Vector4(plane); } else { _envPlaneR.set(plane); } }
public void setEnvPlaneQ(final ReadOnlyVector4 plane) { if (plane == null) { _envPlaneQ = null; return; } else if (_envPlaneQ == null) { _envPlaneQ = new Vector4(plane); } else { _envPlaneQ.set(plane); } }
public void setEnvPlaneT(final ReadOnlyVector4 plane) { if (plane == null) { _envPlaneT = null; return; } else if (_envPlaneT == null) { _envPlaneT = new Vector4(plane); } else { _envPlaneT.set(plane); } }
public void setEnvPlaneS(final ReadOnlyVector4 plane) { if (plane == null) { _envPlaneS = null; return; } else if (_envPlaneS == null) { _envPlaneS = new Vector4(plane); } else { _envPlaneS.set(plane); } }
/** * @return An instance of Vector4 that is intended for temporary use in calculations and so forth. Multiple calls to * the method should return instances of this class that are not currently in use. */ public final static Vector4 fetchTempInstance() { if (MathConstants.useMathPools) { return Vector4.VEC_POOL.fetch(); } else { return new Vector4(); } }
/** * @return An instance of Vector4 that is intended for temporary use in calculations and so forth. Multiple calls to * the method should return instances of this class that are not currently in use. */ public final static Vector4 fetchTempInstance() { if (MathConstants.useMathPools) { return Vector4.VEC_POOL.fetch(); } else { return new Vector4(); } }
@Override public ResultSample doScaleTest(final int count, final int maxCount, final long timeOutMS) { final Matrix4 m1 = a3dMatrixRandom(); final Vector4 vec = new Vector4(1.0, 2.0, 3.0, 1.0); final long start = System.currentTimeMillis(); int loopCount = 0; while (System.currentTimeMillis() - start < timeOutMS && loopCount != maxCount) { ++loopCount; for (int i = 0; i < count; ++i) { m1.scaleLocal(vec); } } return populateResult(System.currentTimeMillis() - start, loopCount, m1.toArray(null)); }
@Test public void testScaleAdd() { final Vector4 vec1 = new Vector4(1, 1, 1, 1); final Vector4 vec2 = vec1.scaleAdd(2.0, new Vector4(1, 2, 3, 4), null); final Vector4 vec2B = vec1.scaleAdd(2.0, new Vector4(1, 2, 3, 4), new Vector4()); assertEquals(new Vector4(3.0, 4.0, 5.0, 6.0), vec2); assertEquals(new Vector4(3.0, 4.0, 5.0, 6.0), vec2B); vec1.scaleAddLocal(2.0, new Vector4(1, 2, 3, 4)); assertEquals(vec2, vec1); }
@Override public void write(final OutputCapsule capsule) throws IOException { super.write(capsule); capsule.write(_tintColor, "tintColor", new ColorRGBA(ColorRGBA.WHITE)); capsule.write(_textureBorderOffsets, "borderCoords", new Vector4(0.25, 0.25, 0.25, 0.25)); capsule.write(_contentPadding, "contentPadding", new Vector4()); capsule.write(_borderScale, "borderScale", 1f); }
@Override public void read(final InputCapsule capsule) throws IOException { super.read(capsule); _tintColor = (ColorRGBA) capsule.readSavable("tintColor", new ColorRGBA(ColorRGBA.WHITE)); _textureBorderOffsets = (Vector4) capsule.readSavable("borderCoords", new Vector4(0.25, 0.25, 0.25, 0.25)); _contentPadding = (Vector4) capsule.readSavable("contentPadding", new Vector4()); _borderScale = capsule.readFloat("borderScale", 1f); final TextureState ts = ((TextureState) getLocalRenderState(StateType.Texture)); if (ts != null) { _texture = ts.getTexture(); } } }
@Test public void testSimpleHash() { // Just a simple sanity check. final Vector4 vec1 = new Vector4(1, 2, 3, 4); final Vector4 vec2 = new Vector4(1, 2, 3, 4); final Vector4 vec3 = new Vector4(2, 2, 2, 2); assertTrue(vec1.hashCode() == vec2.hashCode()); assertTrue(vec1.hashCode() != vec3.hashCode()); } }
@Test public void testApplyVector4() { final Matrix4 mat4 = new Matrix4().applyRotationX(MathUtils.HALF_PI); final Vector4 vec4 = new Vector4(0, 1, 0, 1); final Vector4 result = mat4.applyPost(vec4, null); assertTrue(Math.abs(new Vector4(0, 0, 1, 1).distance(result)) <= MathUtils.EPSILON); vec4.set(0, 1, 1, 1); mat4.applyPost(vec4, result); assertTrue(Math.abs(new Vector4(0, -1, 1, 1).distance(result)) <= MathUtils.EPSILON); vec4.set(0, 1, 1, 1); mat4.applyPre(vec4, result); assertTrue(Math.abs(new Vector4(0, 1, -1, 1).distance(result)) <= MathUtils.EPSILON); vec4.set(1, 1, 1, 1); assertTrue(Math.abs(new Vector4(1, 1, -1, 1).distance(mat4.applyPre(vec4, null))) <= MathUtils.EPSILON); }
@Test public void testClone() { final Vector4 vec1 = new Vector4(0, 0, 0, 0); final Vector4 vec2 = vec1.clone(); assertEquals(vec1, vec2); assertNotSame(vec1, vec2); }
@Test public void testDistance() { final Vector4 vec1 = new Vector4(0, 0, 0, 0); assertTrue(4.0 == vec1.distance(4, 0, 0, 0)); assertTrue(3.0 == vec1.distance(0, 3, 0, 0)); assertTrue(2.0 == vec1.distance(0, 0, 2, 0)); assertTrue(1.0 == vec1.distance(0, 0, 0, 1)); final Vector4 vec2 = new Vector4(1, 1, 1, 1); assertTrue(Math.sqrt(4) == vec1.distance(vec2)); }
@Test public void testTranslation() { final Matrix4 src = new Matrix4(); src.applyRotation(MathUtils.QUARTER_PI, 1, 0, 0); final Matrix4 trans = new Matrix4(); trans.setColumn(3, new Vector4(1, 2, 3, 1)); final Matrix4 transThenRotate = trans.multiply(src, null); final Matrix4 rotateThenTrans = src.multiply(trans, null); final Matrix4 pre1 = new Matrix4(src).applyTranslationPre(1, 2, 3); final Matrix4 post1 = new Matrix4(src).applyTranslationPost(1, 2, 3); assertEquals(transThenRotate, pre1); assertEquals(rotateThenTrans, post1); }