D.HOSKIA
Module 1·50 min

Rotation Matrices

Rotation Matrices

To describe where a robot link is in space, you need a mathematical object that captures both position and orientation. Rotation matrices handle the orientation part.

2D Rotation

A rotation by angle θ about the z-axis:

R(θ) = | cos(θ)  -sin(θ) |
       | sin(θ)   cos(θ) |

If you have a vector p expressed in frame A, you get it in frame B by:

p_B = R · p_A

3D Rotations

Three fundamental rotations about x, y, z axes:

import numpy as np

def Rx(t):
    return np.array([
        [1,          0,           0],
        [0,  np.cos(t),  -np.sin(t)],
        [0,  np.sin(t),   np.cos(t)],
    ])

def Ry(t):
    return np.array([
        [ np.cos(t), 0, np.sin(t)],
        [         0, 1,         0],
        [-np.sin(t), 0, np.cos(t)],
    ])

def Rz(t):
    return np.array([
        [np.cos(t), -np.sin(t), 0],
        [np.sin(t),  np.cos(t), 0],
        [        0,          0, 1],
    ])

Properties

Rotation matrices have important properties:

  • Orthogonal: R^T = R^(-1) — transpose is the inverse
  • Determinant = 1 — preserves lengths and handedness
  • Composition: R_total = R₁ · R₂ · R₃ (applied right-to-left)

CatBot Joint Frame Setup

Each leg of CatBot has 3 joints: hip abduction/adduction, hip flexion/extension, knee. We assign a coordinate frame to each link using the Denavit-Hartenberg convention — next lesson.