Transform

Example

from processing import *
import math

rotate = PI/6
def setup():
    size(400, 400, P3D)

def draw():
    global rotate
    background(180)
    noFill()
    translate(150, 150, 0)
    rotate += 0.01
    if rotate >= TWO_PI:
        rotate = 0
    rotateY(rotate)
    stroke(153)
    box(35)
    # Set rotation angles
    ct = math.cos(PI/9.0)
    st = math.sin(PI/9.0)          
    # Matrix for rotation around the Y axis
    applyMatrix( ct,  0.0,  st,  0.0,
                 0.0, 1.0, 0.0,  0.0,
                 -st, 0.0,  ct,  0.0,
                 0.0, 0.0, 0.0,  1.0)
    stroke(255)
    box(50)

run()

Reference