public void RayMissesCSG() { CSG c = new CSG("union", new Sphere(), new Cube()); Ray r = new Ray(Tuple.Point(0, 2, -5), Tuple.Vector(0, 0, 1)); List <Intersection> xs = c.LocalIntersect(r); Assert.AreEqual(xs.Count, 0); }
public void RayHitsCSG() { Shape s1 = new Sphere(); Shape s2 = new Sphere(); s2.Transform = new Translate(0, 0, 0.5).GetTransform(); CSG c = new CSG("union", s1, s2); Ray r = new Ray(Tuple.Point(0, 0, -5), Tuple.Vector(0, 0, 1)); List <Intersection> xs = c.LocalIntersect(r); Assert.AreEqual(xs.Count, 2); Assert.IsTrue(Globals.EqualityOfDouble(xs[0].T, 4)); Assert.AreEqual(xs[0].S, s1); Assert.IsTrue(Globals.EqualityOfDouble(xs[1].T, 6.5)); Assert.AreEqual(xs[1].S, s2); }