Cheatsheets

Personal collection of cheatsheets.

Computer Graphics

Computer graphics is a sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content.

Index

Transformation Matrices

Transformation matrices are a type of matrices that represent linear transformations. Affine transformations are transformations that preserve lines and parallelism but not necessarily distances and angles.

Translation Matrix

Translation is a transformation that moves objects to a position.

Rotation Matrix

Rotation is a transformation that moves objects relative to an axis by an angle θ.

Scaling Matrix

Scaling is a transformation that enlarges (increases) or shrinks (diminishes) objects by a scale factor.

Shearing Matrix

Shearing is a transformation that skews the coordinate space, stretching it nonuniformly. Areas and volumes are preserved but angles are not.

Animation

Computer animation is the process used for digitally generating animated images.

Case Studies

Procedural Generation

Procedural generation is a method of creating data algorithmically as opposed to manually, typically through a combination of human-generated assets and algorithms coupled with computer-generated randomness and processing power.

Map Generation

Wave Function Collapse

Superformula

The superformula is a generalization of the superellipse that can be used to describe many complex shapes and curves that are found in nature.

Algorithms

Letterbox

Given the image:

Given the canvas:

The new resolution is:

rc > ri ? (wi * hc/hi, hc) : (wc, hi * wc/wi)

To center the image:

top = (hc - hnew) / 2
left = (wc - wnew) / 2

Example.

         20
|------------------|
    10
|---------|

--------------------     ---   ---
|         |        |      | 7   |
|         |        |      |     | 10
|----------        |     ---    |
|                  |            |
--------------------           ---

wc = 20
hc = 10
wi = 10
hi = 7

20/10 > 10/7 ==> (wi * hc/hi, hc) = (10 * 10/7, 10) = (100/7, 10) ~ (14.3, 10)

References