Line { public Line setToSegment(Vec3 pointA, Vec3 pointB) { if (pointA == null || pointB == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Line", "setToSegment", "missingVector")); } this.origin.set(pointA); this.direction.set(pointB.x - pointA.x, pointB.y - pointA.y, pointB.z - pointA.z); return this; } Line();  Line(Vec3 origin, Vec3 direction);  Line(Line line); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Line set(Vec3 origin, Vec3 direction); Line setToSegment(Vec3 pointA, Vec3 pointB); Vec3 pointAt(double distance, Vec3 result); boolean triStripIntersection(float[] points, int stride, short[] elements, int count, Vec3 result); final Vec3 origin; final Vec3 direction; }
@Test public void testSetToSegment() throws Exception { Vec3 pointA = new Vec3(1, 2, 3); Vec3 pointB = new Vec3(4, 5, 6); Vec3 origin = new Vec3(pointA); Vec3 direction = new Vec3(pointB).subtract(pointA); Line line = new Line(); line.setToSegment(pointA, pointB); assertEquals("origin", origin, line.origin); assertEquals("direction", direction, line.direction); }
@Test(expected = IllegalArgumentException.class) public void testSetToSegment_NullFirst() throws Exception { Line line = new Line(); line.setToSegment(null, new Vec3()); fail("Expected an IllegalArgumentException to be thrown."); }
@Test(expected = IllegalArgumentException.class) public void testSetToSegment_NullSecond() throws Exception { Line line = new Line(); line.setToSegment(new Vec3(), null); fail("Expected an IllegalArgumentException to be thrown."); }