3D Matrix Basics • tim rodenbröker creative coding

3D Matrix Basics

Courses / The Third Dimension / 3D Matrix Basics

This is probably the most important lesson of this course, because the 3D-martix is the foundation of any spacial sketch.

In the first course Creative Coding Essentials, you have already learned about the so called “matrix”. The word “matrix” is basically a synonym for “coordinate system”.

2D and 3D matrices

Until this point you have probably only worked with two-dimensional matrixes. Remember how to define a position in Processing? You can do so by defining x and y values, right? Let’s do so to make it clear.

//Processing & P5.js
translate(x,y);

// Example
translate(100,100);
A two-dimensional matrix

In a three-dimensional world, you have one additional axis: z!

//Processing & P5.js
translate(x,y,z);

// Example
translate(100,100,100);
A three-dimensional matrix with x-, y-, and z-axes

With x, y and z you can move things in the 3D-scene in any way you want. And that’s what we are going to talk about in the next lesson about 3D-transformations.

P5.js users beware!

In p5.js, the origin of the coordinate system in WEBGL is in the center of the Sketch window.

This means in 3D sketches in P5.js you don’t need to translate the coordoninate system before displaying objects in the center of the sketch.

Published by Tim on Sunday May 10, 2020

Last modified on December 8th, 2022 at 11:28

  1. The P3D-Renderer (Processing)
  2. The WEBGL-Renderer (p5.js)
  3. 3D Matrix Basics
  4. 3D Transformations
  5. push() and pop() recap
  6. 3D Geometry
  7. 3D Geometry (Examples)
  8. Lighting your Scene
  9. Directional Light
  10. The Camera
  11. Wrapping Up