/** * 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 testValid() { final Triangle vec1 = new Triangle(); final Triangle vec2 = new Triangle(new Vector3(0, 0, Double.NaN), Vector3.ZERO, Vector3.ZERO); final Triangle vec3 = new Triangle(Vector3.ZERO, new Vector3(0, 0, Double.NaN), Vector3.ZERO); final Triangle vec4 = new Triangle(Vector3.ZERO, Vector3.ZERO, new Vector3(0, 0, Double.NaN)); assertTrue(Triangle.isValid(vec1)); assertFalse(Triangle.isValid(vec2)); assertFalse(Triangle.isValid(vec3)); assertFalse(Triangle.isValid(vec4)); vec4.setC(Vector3.ZERO); assertTrue(Triangle.isValid(vec4)); assertFalse(Triangle.isValid(null)); }
t.setA(vertices[0]); t.setB(vertices[1]); t.setC(vertices[2]);
t.setA(vertices[0]); t.setB(vertices[1]); t.setC(vertices[2]);
tri1.setC(Vector3.UNIT_Z); tri1.setIndex(1); assertEquals(Vector3.NEG_ONE, tri1.getA());