Transformation and Clipping

Oct 31 2022 Computer Graphics Course Project C++ OpenGLUT

There are many test data in the forder and many input commands in each test data. I read the files and complete the following instructions. Also, each shape will automatically be assigned a random color.

🔗 See more details here.

Operating instructions

  • Comment:

    The instruction is # ......
    If a # appears, skip the line. (i.e. You don’t need to execute the line which # appears.)

  • Reset:

    The instruction is reset
    Reset the transformation matrix.

  • Translate:

    The instruction is translate x y
    x means moving along x-axis by x unit.
    y means moving along y-axis by y unit.

  • Scale:

    The instruction is scale x y
    x means scaling along x-axis by x unit.
    y means scaling along y-axis by y unit.

  • Rotate:

    The instruction is rotate θ
    θ means rotating along z-axis by θ degree.

  • Clear data:

    The instruction is clearData
    Clear the objects that you create (square and triangle).

  • Clear screen:

    The instruction is clearScreen
    Clear the screen.

  • View:

    The instruction is view wxl wxr wyb wyt vxl vxr vyb vyt
    wxl wxr wyb wyt means the position of object before mapping.
    vxl vxr vyb vyt means the position of object after mapping.

    In math words

      f(wxl,wyb) = (vxl,vyb)
      f(wxr,wyt) = (vxr,vyt)
    

    where it is a linear transformation.
    The objects outside the boundary need to clipped.
    Every time you execute view, the created objects must be displayed. Please draw the boundary of objects with points and lines.(Use the code in lab1) Please add system("pause"); when you display anything.

  • Square:

    The instruction is square
    Create a square with its vertex (-1,-1) (1,-1) (1,1) (-1,1).

  • Triangle:

    The instruction is triangle
    Create a triangle with its vertex (0,1) (-1,-1) (1,-1).

  • End:

    The instruction is end
    Destory the window.

Results