/** * 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()); setIndex(in.readInt()); }
/** * 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()); setIndex(in.readInt()); }
/** * Sets a point to a new value. * * @param index * the index of the point to set (0-2, corresponding to A-C) * @param point * the new value * @throws IllegalArgumentException * if index is not in [0, 2] */ public void set(final int index, final ReadOnlyVector3 point) { switch (index) { case 0: setA(point); return; case 1: setB(point); return; case 2: setC(point); return; } throw new IllegalArgumentException("index must be 0, 1 or 2 (corresponding to A, B or C.)"); }
/** * Sets a point to a new value. * * @param index * the index of the point to set (0-2, corresponding to A-C) * @param point * the new value * @throws IllegalArgumentException * if index is not in [0, 2] */ public void set(final int index, final ReadOnlyVector3 point) { switch (index) { case 0: setA(point); return; case 1: setB(point); return; case 2: setC(point); return; } throw new IllegalArgumentException("index must be 0, 1 or 2 (corresponding to A, B or C.)"); }
@Test public void testCenter() { final Triangle tri1 = new Triangle(Vector3.ZERO, Vector3.UNIT_Y, Vector3.UNIT_X, 0); assertEquals(new Vector3(1 / 3., 1 / 3., 0), tri1.getCenter()); // dirty assertEquals(new Vector3(1 / 3., 1 / 3., 0), tri1.getCenter()); // clean tri1.setA(Vector3.ONE); assertEquals(new Vector3(2 / 3., 2 / 3., 1 / 3.), tri1.getCenter()); // dirty, but with existing center }
t = new Triangle(vertices[0], vertices[1], vertices[2]); } else { t.setA(vertices[0]); t.setB(vertices[1]); t.setC(vertices[2]);
t = new Triangle(vertices[0], vertices[1], vertices[2]); } else { t.setA(vertices[0]); t.setB(vertices[1]); t.setC(vertices[2]);
assertTrue(tri1.getIndex() == 0); tri1.setA(Vector3.NEG_ONE); tri1.setB(Vector3.UNIT_X); tri1.setC(Vector3.UNIT_Z);