@Override public Rectangle3 clone() { return new Rectangle3(this); }
/** * Constructor creates a new Rectangle3 with defined A, B, and C points that define the area of the rectangle. * * @param a * the first corner of the rectangle. * @param b * the second corner of the rectangle. * @param c * the third corner of the rectangle. */ public Rectangle3(final ReadOnlyVector3 a, final ReadOnlyVector3 b, final ReadOnlyVector3 c) { setA(a); setB(b); setC(c); }
public void stateChanged(final ChangeEvent e) { final Rectangle3 rect = ((RectangleEmitter) getEdittedParticles().getParticleEmitter()).getSource(); final double height = _rectHeightPanel.getDoubleValue(); final Vector3 helper = Vector3.fetchTempInstance(); helper.set(rect.getA()).setZ(-height / 2.0); rect.setA(helper); helper.set(rect.getB()).setZ(-height / 2.0); rect.setB(helper); helper.set(rect.getC()).setZ(height / 2.0); rect.setC(helper); Vector3.releaseTempInstance(helper); } });
@Test public void testRandom() { MathUtils.setRandomSeed(0); final Rectangle3 rect1 = new Rectangle3(); final Vector3 store = rect1.random(null); assertEquals(new Vector3(0.0, 0.0, 0.0), store); rect1.setA(new Vector3(1, 0, 0)); rect1.setB(new Vector3(1, 1, 0)); rect1.setC(new Vector3(0, 1, 0)); rect1.random(store); assertEquals(new Vector3(0.39365482330322266, 0.8468815684318542, 0.0), store); } }
@Test public void testEquals() { // couple of equals validity tests final Rectangle3 rect1 = new Rectangle3(); assertEquals(rect1, rect1); assertFalse(rect1.equals(null)); assertFalse(rect1.equals(new Vector2())); // throw in a couple pool accesses for coverage final Rectangle3 rect2 = Rectangle3.fetchTempInstance(); rect2.set(rect1); assertEquals(rect1, rect2); assertNotSame(rect1, rect2); Rectangle3.releaseTempInstance(rect2); // cover more of equals assertTrue(rect1.equals(new Rectangle3(Vector3.ZERO, Vector3.ZERO, Vector3.ZERO))); assertFalse(rect1.equals(new Rectangle3(Vector3.ZERO, Vector3.ZERO, Vector3.UNIT_X))); assertFalse(rect1.equals(new Rectangle3(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_X))); assertFalse(rect1.equals(new Rectangle3(Vector3.ZERO, Vector3.UNIT_X, Vector3.ZERO))); assertFalse(rect1.equals(new Rectangle3(Vector3.UNIT_X, Vector3.ZERO, Vector3.ZERO))); assertFalse(rect1.equals(new Rectangle3(Vector3.UNIT_X, Vector3.ZERO, Vector3.UNIT_X))); assertFalse(rect1.equals(new Rectangle3(Vector3.UNIT_X, Vector3.UNIT_X, Vector3.ZERO))); assertFalse(rect1.equals(new Rectangle3(Vector3.UNIT_X, Vector3.UNIT_X, Vector3.UNIT_X))); }
@Test public void testSimpleHash() { // Just a simple sanity check. final Rectangle3 rect1 = new Rectangle3(Vector3.ZERO, Vector3.UNIT_Y, Vector3.UNIT_X); final Rectangle3 rect2 = new Rectangle3(Vector3.ZERO, Vector3.UNIT_Y, Vector3.UNIT_X); final Rectangle3 rect3 = new Rectangle3(Vector3.ZERO, Vector3.UNIT_Y, Vector3.UNIT_Z); assertTrue(rect1.hashCode() == rect2.hashCode()); assertTrue(rect1.hashCode() != rect3.hashCode()); }
@Test public void testClone() { final Rectangle3 rect1 = new Rectangle3(); final Rectangle3 rect2 = rect1.clone(); assertEquals(rect1, rect2); assertNotSame(rect1, rect2); }
public Vector3 randomEmissionPoint(final Vector3 store) { Vector3 rVal = store; if (rVal == null) { rVal = new Vector3(); } getSource().random(rVal); return rVal; }
public void stateChanged(final ChangeEvent e) { final Rectangle3 rect = ((RectangleEmitter) getEdittedParticles().getParticleEmitter()).getSource(); final double width = _rectWidthPanel.getDoubleValue(); final Vector3 helper = Vector3.fetchTempInstance(); helper.set(rect.getA()).setX(-width / 2.0); rect.setA(helper); helper.set(rect.getB()).setX(width / 2.0); rect.setB(helper); helper.set(rect.getC()).setX(-width / 2.0); rect.setC(helper); Vector3.releaseTempInstance(helper); } });
public Vector3 randomEmissionPoint(final Vector3 store) { Vector3 rVal = store; if (rVal == null) { rVal = new Vector3(); } getSource().random(rVal); return rVal; }
@Test public void testGetSet() { final Rectangle3 rect = new Rectangle3(); assertEquals(Vector3.ZERO, rect.getA()); assertEquals(Vector3.ZERO, rect.getB()); assertEquals(Vector3.ZERO, rect.getC()); rect.setA(Vector3.ONE); rect.setB(Vector3.UNIT_X); rect.setC(Vector3.UNIT_Z); assertEquals(Vector3.ONE, rect.getA()); assertEquals(Vector3.UNIT_X, rect.getB()); assertEquals(Vector3.UNIT_Z, rect.getC()); final Rectangle3 rect2 = new Rectangle3(rect); assertEquals(Vector3.ONE, rect2.getA()); assertEquals(Vector3.UNIT_X, rect2.getB()); assertEquals(Vector3.UNIT_Z, rect2.getC()); final Rectangle3 rect3 = new Rectangle3(Vector3.NEG_ONE, Vector3.UNIT_Z, Vector3.NEG_UNIT_Y); assertEquals(Vector3.NEG_ONE, rect3.getA()); assertEquals(Vector3.UNIT_Z, rect3.getB()); assertEquals(Vector3.NEG_UNIT_Y, rect3.getC()); }
/** * Constructor creates a new Rectangle3 with defined A, B, and C points that define the area of the rectangle. * * @param a * the first corner of the rectangle. * @param b * the second corner of the rectangle. * @param c * the third corner of the rectangle. */ public Rectangle3(final ReadOnlyVector3 a, final ReadOnlyVector3 b, final ReadOnlyVector3 c) { setA(a); setB(b); setC(c); }
public RectangleEmitter() { _source = new Rectangle3(); }
/** * Used with serialization. Not to be called manually. * * @param in * ObjectInput * @throws IOException * @throws ClassNotFoundException */ @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { setA((Vector3) in.readObject()); setB((Vector3) in.readObject()); setC((Vector3) in.readObject()); }
public RectangleEmitter() { _source = new Rectangle3(); }
/** * Used with serialization. Not to be called manually. * * @param in * ObjectInput * @throws IOException * @throws ClassNotFoundException */ @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { setA((Vector3) in.readObject()); setB((Vector3) in.readObject()); setC((Vector3) in.readObject()); }
@Override public Rectangle3 clone() { return new Rectangle3(this); }
/** * @return An instance of Rectangle3 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 Rectangle3 fetchTempInstance() { if (MathConstants.useMathPools) { return Rectangle3.RECTANGLE_POOL.fetch(); } else { return new Rectangle3(); } }
/** * @return An instance of Rectangle3 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 Rectangle3 fetchTempInstance() { if (MathConstants.useMathPools) { return Rectangle3.RECTANGLE_POOL.fetch(); } else { return new Rectangle3(); } }