Line { public Vec3 pointAt(double distance, Vec3 result) { if (result == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Line", "pointAt", "missingResult")); } result.x = this.origin.x + this.direction.x * distance; result.y = this.origin.y + this.direction.y * distance; result.z = this.origin.z + this.direction.z * distance; return result; } 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 testPointAt() throws Exception { Vec3 origin = new Vec3(1, 2, 3); Vec3 direction = new Vec3(4, 5, 6); Line line = new Line(origin, direction); double distance = -2.0; Vec3 expected = new Vec3(origin).add(new Vec3(direction).multiply(distance)); Vec3 point = line.pointAt(distance, new Vec3()); assertEquals("point at", expected, point); }
@Test(expected = IllegalArgumentException.class) public void testPointAt_NullArgument() throws Exception { Line line = new Line(); line.pointAt(0, null); fail("Expected an IllegalArgumentException to be thrown."); }
@Test public void testPointAt_NaN() throws Exception { Line line = new Line(); Vec3 point = line.pointAt(Double.NaN, new Vec3()); assertTrue(Double.isNaN(point.x)); assertTrue(Double.isNaN(point.y)); assertTrue(Double.isNaN(point.z)); }