### Question:
DefaultEllipsoid extends AbstractShape3D implements Ellipsoid { @Override public Vector3d getIntersection(Ray3d ray) { Vector3d dir = getInverseTransform().mult(ray.getDirection().subtract(myCenter)); Vector3d pos = getInverseTransform().mult(ray.getPosition().subtract(myCenter)); Vector3d unitSphInter = new DefaultSphere(Vector3d.ORIGIN, 1d).getIntersection(new Ray3d(pos, dir)); if (unitSphInter != null) { return myTransform.mult(unitSphInter).add(myCenter); } return null; } DefaultEllipsoid();  DefaultEllipsoid(double radius, double radius2, double radius3);  DefaultEllipsoid(Vector3d center, double radius, double radius2, double radius3);  DefaultEllipsoid(Vector3d center, Vector3d xAxis, Vector3d yAxis, Vector3d zAxis); @Override Vector3d directionToLocal(Vector3d direction); @Override Vector3d directionToModel(Vector3d direction); @Override double getBoundingRadius(); @Override Vector3d getCenter(); @Override double getHeading(Vector3d location, Vector3d direction); @Override Vector3d getIntersection(Ray3d ray); @Override long getSizeBytes(); @Override Vector3d getTangent(Vector3d normal); @Override Vector3d getXAxis(); @Override Vector3d getYAxis(); @Override Vector3d getZAxis(); @Override boolean isSphere(); @Override Vector3d localToModel(Vector3d position); @Override Vector3d modelToLocal(Vector3d position); @Override Vector3d normalToLocal(Vector3d normal); @Override String toString();  }### Answer:
@Test public void testGetIntersectionEllipsoid45() { final double xRadius = 20; final double yRadius = 20; final double zRadius = 10; Ellipsoid shape = new DefaultEllipsoid(xRadius, yRadius, zRadius); double zInt = 1. / Math.sqrt(1. / xRadius / xRadius + 1. / zRadius / zRadius); double sqrt2 = Math.sqrt(2.); Ray3d ray = new Ray3d(new Vector3d(0., 0., zInt * 2.), new Vector3d(1. / sqrt2, 1. / sqrt2, -1.)); Vector3d intersection = shape.getIntersection(ray); Vector3d expected = new Vector3d(zInt / sqrt2, zInt / sqrt2, zInt); assertEquals(expected, intersection); }
@Test public void testGetIntersectionSphere30() { final double radius = 10.; Ellipsoid sphere = new DefaultEllipsoid(radius, radius, radius); final double sqrt3 = Math.sqrt(3); Ray3d ray = new Ray3d(new Vector3d(radius * sqrt3, 0., 0.), new Vector3d(-sqrt3, 1., 0.)); Vector3d intersection = sphere.getIntersection(ray); Vector3d expected = new Vector3d(radius * sqrt3 / 2., radius / 2., 0.); assertEquals(expected, intersection); }
@Test public void testGetIntersectionSphere46() { final double radius = 10.; Ellipsoid sphere = new DefaultEllipsoid(radius, radius, radius); double sqrt2 = Math.sqrt(2); final int ang = 46; Ray3d ray = new Ray3d(new Vector3d(radius * sqrt2, 0., 0.), new Vector3d(-1, Math.tan(Math.toRadians(ang)), 0.)); Vector3d intersection = sphere.getIntersection(ray); assertNull(intersection); }