Course list http://www.c-jump.com/bcc/

Matrices


  1. Cartesian coordinates
  2. Homogeneous coordinates
  3. Matrix
  4. Matrix and vector math
  5. Matrix by vector multiplication
  6. Matrix by vector multiplication example
  7. Matrix by vector multiplication step-by-step
  8. Matrix by vector multiplication step-by-step
  9. Identity matrix
  10. 3D transformations
  11. 3D translation
  12. 3D rotation
  13. Object rotation example
  14. Scaling matrix
  15. Matrix by matrix multiplication
  16. Matrix by matrix multiplication, cont.
  17. Cumulating transformations
  18. Coordinate spaces in OpenGL
  19. Coordinate spaces, cont.
  20. Observer View Coordinates
  21. Perspective projection
  22. Orthographic projection
  23. OpenGL view volume
  24. Frustum clipping (clip space)
  25. Normalized device space
  26. NDC transformation
  27. Window space (viewport transformation)
  28. OpenGL coordinate systems and transformations
  29. Transforming normals

1. Cartesian coordinates


  • Cartesian coordinates are typically used to represent the world in 3D programming.

  • When creating a window, we must define where is our viewport in the Cartesian system

  • Middle of screen is (0, 0)

  • Dimensions are as follows:

    • x = horizontal

    • y = vertical

    • z = depth (can be RHS or LHS)

    • (0, 0, 0) is origin

    cartesian coordinates
  •  

2. Homogeneous coordinates



3. Matrix


  • Mathematically, a matrix is a set of numbers arranged in uniform rows and columns

  • OpenGL understands column-primary layout for matrices: in a 4x4 matrix, the first four elements of an array provide the first column of the matrix, followed by second column, and so on.

    4x4 matrix
  • 
        float matrix4x4[] = {
            a, e, i, 0,   // 1st column
            b, f, j, 0,   // 2nd column
            c, g, k, 0,   // 3rd column
            d, h, l, 1    // 4th column
        };
    
    

4. Matrix and vector math



5. Matrix by vector multiplication



6. Matrix by vector multiplication example



7. Matrix by vector multiplication step-by-step



8. Matrix by vector multiplication step-by-step



9. Identity matrix



10. 3D transformations



11. 3D translation


    3D translation
  • Translation matrix:

      3D translation matrix


12. 3D rotation


    3D rotation
    3D rotation matrices

13. Object rotation example



14. Scaling matrix



15. Matrix by matrix multiplication



16. Matrix by matrix multiplication, cont.



17. Cumulating transformations



18. Coordinate spaces in OpenGL



19. Coordinate spaces, cont.



20. Observer View Coordinates


  • In the view space,

    1. Positive z axis is pointed towards the observer of the scene, and positive x and y are pointed right and up, respectively.

    2. The viewport is at the z = 0

    3. Negative z values go farther away from the observer into the space behind the screen.

    cartesian coordinates
  •  


21. Perspective projection


  • Objects shrink with distance

  • Viewing volume is shaped like a pyramid (rectangular cone)

  • Objects in front of the near plane are culled

  • Objects behind the far plane are also culled

  • Objects intersecting with the near plane are partially clipped

  • Objects behind the far plane are also partially clipped

  • A viewing frustum:

      OpenGL viewing frustum

    fovy specifies the field of view angle, in degrees, in the y direction.


22. Orthographic projection


  • Projection is a box (no perspective).

  • The size of the viewing volume does not change.

  • Objects are clipped and culled as in perspective projection

      OpenGL Orthographic projection

  • CAD orthographic projection: CAD orthographic projection


23. OpenGL view volume



24. Frustum clipping (clip space)



25. Normalized device space


Upon exiting the clip space,
  1. all four coordinates (x, y, z, w) are divided by w

    
        -1.0 <= x <= +1.0
        -1.0 <= y <= +1.0
         0.0 <= z <= +1.0
                w = 1.0
    
    
  2. Everything inside the NDC space is shown on screen.

     


26. NDC transformation



27. Window space (viewport transformation)



28. OpenGL coordinate systems and transformations



29. Transforming normals