Computer Graphics- Cheatsheet

Computer Graphics- Cheatsheet

Will Perkins
Written by
Will Perkins
automotive
July 11, 2011

Homogeneous coordinates

Adding a fourth term: (w) makes it easier to work in 3D euclidian space.

homogeneous-coordinates

Why? Here's a long list of reasons, but a couple key points:

  • 3D scaling, rotation, and translation operations can be represented as a single linear transform (4x4 matrix)
  • A direction (Infinity) can be represented in 3D space: (x,y,z,0)

Transformations

Translation

for a point (p):

point p

for a vector (v):

vector

inverse transform: (T^{-1}(t) = T(-t))

Scaling

scaling

Rotation

When applying individual rotations (yaw, pitch, roll), the order of rotation operations is important. To get around this problem use axis-angle representation.

If you only need to rotate around a single axis, then applying the rotation transform can be straightforward.

Rotation matrices for each axis:

rotation

The inverse of a rotation matrix corresponds to its transpose.

Coordinate Systems

Local space, World space, View space, Clip space, Screen space

Coordinate Systems

The relationships between the various spaces - Source: LearnOpenGL.com

More on Coordinate Systems

Coordinate Systems Examples

The same scene as viewed in the different coordinate systems

Perspective vs Orthographic Projection

perspective / orthographic projection. near plane / far plane. clipping.

Screen Space

You can use the Viewport Transform to get to Screen Space (actual pixels)

Combining Transformations

To transform a vertex coordinate to clip coordinates:

combining transforms

Other Useful References

Coordinate systems we commonly reference for development.

Axis Orientations

Coordinate Systems for various frameworks

Pinhole camera model

pinhole

Source: Kyle Simek's excellent computer vision blog

FAQs

How do I get the camera direction from a given view matrix?

Column 2 of the view matrix is the camera's -Z direction.

camera direction

Where (u), (v), and (n) are the normalized vectors for the camera referential. (u) is the up vector, (n) is the direction the camera is looking at, and (v) is perpendicular to both (n) and (u).

Download this article

Get the markdown source for offline reading