public void When_intersecting_triangles_preserve_the_u_and_v_values_in_the_resulting_intersection() { var ray = new Ray(new Point(-0.2, 0.3, -2), Vector.UnitZ); var intersections = _triangle.LocalIntersect(ray); intersections[0].U.Should().BeApproximately(0.45, NumberExtensions.Epsilon); intersections[0].V.Should().BeApproximately(0.25, NumberExtensions.Epsilon); }
public void SmoothTriangleIntersection() { Ray r = new Ray(Tuple.Point(-0.2, 0.3, -2), Tuple.Vector(0, 0, 1)); List <Intersection> xs = tri.LocalIntersect(r); Assert.IsTrue(Globals.EqualityOfDouble(xs[0].U, 0.45)); Assert.IsTrue(Globals.EqualityOfDouble(xs[0].V, 0.25)); }
public void An_intersection_with_a_smooth_triangle_stores_u_and_v() { var ray = new Ray(Tuple.Point(-0.2, 0.3, -2), Tuple.Vector(0, 0, 1)); var xs = _tri.LocalIntersect(ray); Assert.AreEqual(1, xs.Count); xs[0].U.Should().BeApproximately(0.45, C.Epsilon); xs[0].V.Should().BeApproximately(0.25, C.Epsilon); }
public void IntersectionWithSmoothTriangle_ShouldStoresUv() { var p1 = new Point(0, 1, 0); var p2 = new Point(-1, 0, 0); var p3 = new Point(1, 0, 0); var n1 = new Vector(0, 1, 0); var n2 = new Vector(-1, 0, 0); var n3 = new Vector(1, 0, 0); var tri = new SmoothTriangle(p1, p2, p3, n1, n2, n3); var r = new Ray(new Point(-0.2, 0.3, -2), new Vector(0, 0, 1)); var xs = tri.LocalIntersect(r); Assert.Equal(0.45, xs[0].u, 2); Assert.Equal(0.25, xs[0].v, 2); }