public void NormalAt_should_calculate_the_normal_ona_translated_shape() { var shape = new TestShape(Matrix4x4.CreateTranslation(0, 1, 0)); var normal = shape.NormalAt(new Point(0, 1.70711, -0.70711)); normal.Should().Be(new Vector(0, 0.70711, -0.70711)); }
public void NormalAt_should_calculate_the_normal_on_a_transformed_shape() { var shape = new TestShape(Matrix4x4.CreateRotationZ(Math.PI / 5).Scale(1, 0.5, 1)); var normal = shape.NormalAt(new Point(0, Math.Sqrt(2) / 2, -Math.Sqrt(2) / 2)); normal.Should().Be(new Vector(0, 0.97014, -0.24254)); }
public void Ctor_should_store_the_transform_and_material() { var shape = new TestShape(Matrix4x4.CreateTranslation(2, 3, 4), new Material(Colors.Red)); shape.Transform.Should().Be(Matrix4x4.CreateTranslation(2, 3, 4)); shape.Material.Color.Should().Be(Colors.Red); }
public void Adding_a_child_to_a_group() { var group = new Group(); var shape = new TestShape(); group.AddChild(shape); group.Children.Should().NotBeEmpty(); group.Children.Should().Contain(shape); shape.Parent.Should().Be(group); }
public void Intersect_should_translate_world_coordinates_into_local_coordinates() { var ray = new Ray(new Point(0, 0, -5), Vector.UnitZ); var shape = new TestShape(Matrix4x4.CreateScaling(2, 2, 2)); shape.Intersect(ray); shape.SavedLocalRay !.Origin.Should().Be(new Point(0, 0, -2.5)); shape.SavedLocalRay !.Direction.Should().Be(new Vector(0, 0, 0.5)); shape = (TestShape)shape.ChangeTransform(Matrix4x4.CreateTranslation(5, 0, 0)); shape.Intersect(ray); shape.SavedLocalRay !.Origin.Should().Be(new Point(-5, 0, -5)); shape.SavedLocalRay !.Direction.Should().Be(new Vector(0, 0, 1)); }
public void Shape_should_default_to_having_a_null_parent() { var shape = new TestShape(); shape.Parent.Should().BeNull(); }
public void Shape_should_have_a_default_material() { var shape = new TestShape(); shape.Material.Should().BeEquivalentTo(new Material()); }
public void A_Shape_should_default_to_the_identity_matrix_for_the_transform() { var shape = new TestShape(); shape.Transform.Should().Be(Matrix4x4.Identity); }