Task 3: Transforms

Relevant lecture: 4

Implement the three transforms in the transforms.cpp file according to the SVG spec. The matrices are 3x3 because they operate in homogeneous coordinates – you can see how they will be used on instances of Vector2D by looking at the way the * operator is overloaded in the same file.

Once you’ve implemented these transforms, svg/transforms/robot.svg should render correctly, as follows:

Robot.

For convenience, here is a list of functions in transforms.cpp you will need to modify:

  1. translate
  2. scale
  3. rotate

Extra Credit (2 pts): Add an extra feature to the GUI. For example, you could make two unused keys to rotate the viewport. Save an example image to demonstrate your feature, and write about how you modified the SVG to NDC and NDC to screen-space matrix stack to implement it.

For Your Write-Up: Task 3

  • Create an updated version of svg/transforms/robot.svg with cubeman doing something more interesting, like waving or running. Feel free to change his colors or proportions to suit your creativity. Save your svg file as my_robot.svg in your docs/ directory and show a png screenshot of your rendered drawing in your write-up. Explain what you were trying to do with cubeman in words.
    • You can first copy over robot.svg and work within the svg/transforms/ folder. In order to apply the transforms that you wrote in transforms.cpp, you can apply them with the transform keyword. For instance, to rotate a group of objects (remember that we work in hierarchical transforms), I can include the following in the svg file:
     <g transform="rotate(135)">
     <code that defines the polygons of the objects>
     </g>
    
    • As a reminder, your screenshots need to be generated by using the 'S' hotkey, not using your operating systems native screenshotting mechanism. You can refer back to our guide on Using the GUI on how to generate these images, and where to find them once they’re generated.