' '

Difficulty

2

Prerequisites

math/transformations

Reading material

materials/2d-vs-3d

Warning

Note: before you implement this extension, you need to have at least implemented some kind of 2D material and 3D material, otherwise material transformations will be useless.

Material transformers should not be confused with primitive transformers. Primitive transformers change the shape of primitives, i.e. they scale, move and rotate 3D objects. Material transformers only transform the materials themselves.

1. 2D

1.1. 2D Material Transformer

For this extension, you will implement the Material2DTransformer. It is able to perform arbitrary transformations on 2D materials.

Implement raytracer::materials::Material2DTransformer in files materials/material-transformer.cpp/.h.

  • A Material2DTransformer is a subclass of MaterialImplementation. It is parameterized by a child Material (the one that is being transformed) and a Transformation2D.

  • You will need to override the at member function. You will have to find out for yourself what should happen here. Testing whether you got it right will only be possible after you implemented one of the 2D transformations (see further below).

Tip

You might want to rely on the code defined for this extension.

1.2. 2D Translation

Use MaterialTransformer2D to implement a function

Material raytracer::materials::translate(const math::Vector2D& displacement,
                                         Material material);

1.3. 2D Scaling

Define a function

Material raytracer::materials::scale(double sx,
                                     double sy,
                                     Material material);

1.4. 2D Rotation

Define a function

Material raytracer::materials::rotate(math::Angle angle,
                                      Material material);

2. 3D

2.1. 3D Material Transformer

Implement Material3DTransformer.

  • A Material3DTransformer is a subclass of MaterialImplementation. It is parameterized by a child Material (the one that is being transformed) and a Transformation3D.

  • You will need to override the at member function. You will have to find out for yourself what should happen here.

2.2. 3D Translation

Define a function

Material raytracer::materials::translate(const math::Vector3D& v,
                                         Material material);

2.3. 3D Scaling

Define a function

Material raytracer::materials::scale(double sx,
                                     double sy,
                                     double sz,
                                     Material material);

2.4. 3D Rotation

Define functions

Material raytracer::materials::rotate_around_x(math::Angle angle,
                                               Material material)

Material raytracer::materials::rotate_around_y(math::Angle angle,
                                               Material material)

Material raytracer::materials::rotate_around_z(math::Angle angle,
                                               Material material)

3. Evaluation

Create one or more scenes that together show that each of your transformations work.