* exactly misses the sphere. Due to the envelope, we still expect a hit,
* and this hitpoint should be within the envelope around the sphere.
* Next, we move the sphere a bit, such that we expect a miss.
*/
public void testRay3() {
RayCast raycast = new RayCast();
// setup sphere geometry
Sphere s1 = new Sphere(1);
Body b1 = new Body("default", s1);
// select a point (5,1,0) and the raydirection (-1,0,0)
Vector3 point = new Vector3(5, 1, 0);
Vector3 direction = new Vector3(-1,0,0);
System.out.println("*********************************************************************");
// do the raycast
double lambda = raycast.run(s1, null, point, direction, new Vector3(), new Vector3(), 0, envelope, epsilon, false );
// calculate the point
Vector3 p = point.add(direction.multiply(lambda));
System.out.println("p norm="+p.norm());
// the hitpoint must be within the envelope
assertTrue( Math.abs(p.norm()-1) < envelope+epsilon);
// move the sphere a bit downwards
b1.setPosition(0,-envelope-2*epsilon, 0);
// do the raycast
lambda = raycast.run(s1, null, point, direction, new Vector3(), new Vector3(), 0, envelope, epsilon, false );
System.out.println("returned lambda="+lambda);
assertTrue( lambda == Double.POSITIVE_INFINITY);