Tutorials
These tutorials teach the PyNGL math classes from the ground up, with runnable examples. They are written for students meeting 3D graphics maths for the first time, but they also serve as a practical reference.
Read them in this order — each one builds on the previous:
| # | Tutorial | What you will learn |
|---|---|---|
| 1 | Understanding the Method Names | The grammar rules behind the API — why normalized() ends in -ed, and the one method that mutates |
| 2 | Vectors | Vec2, Vec3, Vec4 — directions, positions, dot and cross products, normals, reflection |
| 3 | Matrices | Mat2, Mat3, Mat4 — rotation, scale, translation, combining transforms with @ |
| 4 | Quaternions | Quaternion — rotation without gimbal lock, slerp for smooth animation |
| 5 | The Transform Class | Transform — position + rotation + scale bundled into one model matrix |
| 6 | Cameras and Projection | look_at, perspective, ortho — building the view and projection matrices |
| 7 | Vector Arrays | Vec2Array, Vec3Array, Vec4Array — collections of vectors ready for the GPU |
| 8 | Geometry Maths | BBox, Plane, BezierCurve — bounding boxes, planes, and curves |
| 9 | Utility Functions | clamp, lerp, calc_normal — small helpers you will use everywhere |
Every code block in these tutorials is runnable. Try them in a Python shell as you read:
uv run python
>>> from ncca.ngl import Vec3
>>> Vec3(1.0, 2.0, 3.0) + Vec3(4.0, 5.0, 6.0)
Vec3(5.0, 7.0, 9.0)