PIXELBANKv8.2.1
Menu

Compose 3D Transformations

Compose multiple 3D transformation matrices in the correct order using NumPy.

3D transformations are represented as 4×4 homogeneous matrices. Composing transformations requires multiplying matrices in reverse order of application.

If we want to apply T1 first, then T2: Result = T2 @ T1

Common 3D transformations:

  • Translation: Move by (tx, ty, tz)
  • Rotation: Rotate around X, Y, or Z axis
  • Scale: Scale by (sx, sy, sz)

This is crucial for camera positioning, object manipulation, and scene graph traversal in 3D CV.

Example:

Input:
transforms = [
  [[1,0,0,5],[0,1,0,0],[0,0,1,0],[0,0,0,1]],  # Translate X by 5
  [[2,0,0,0],[0,2,0,0],[0,0,2,0],[0,0,0,1]]   # Scale by 2
]
Output:
[[2,0,0,10],[0,2,0,0],[0,0,2,0],[0,0,0,1]]
Reasoning:

First translate by (5,0,0), then scale by 2.

Composed: Scale @ Translate (reverse order)

Point [0,0,0] → translate → [5,0,0] → scale → [10,0,0]

The translation component also gets scaled!

Constraints:

  • transforms: List of 4×4 transformation matrices
  • Return: Single composed 4×4 matrix
  • Apply transforms in order (first in list applied first)
Editor

Test Results

0/0
Run code to see test results.