Computer Graphics (rasterisation, ray tracing, WebGPU) Module 2
The maths toolkit: vectors, matrices and precision interview questions
Interview questions on “The maths toolkit: vectors, matrices and precision”: warm-ups, then what each harder question tests and how a good answer starts.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
What do the dot product and the cross product of two vectors tell you?
Answered in the lesson Vectors, points, dot and cross products
-
Fresher to mid
Why do graphics programs use 4 × 4 matrices for 3D points?
-
Fresher to mid
In JavaScript, 0.1 + 0.2 === 0.3 is false. Why, and how should a test compare floating-point results?
Answered in the lesson Floating point, precision and robust geometry
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Mid to senior
A level designer mirrors a model by scaling it by −1 along x. In the game the mirrored copy looks inside out: its inside faces show and its lighting looks wrong. Explain both effects and fix them without editing the mesh.
- What it tests
- How a mirror reverses winding and handedness, how culling and normals depend on them, and a fix in the pipeline rather than in the asset.
- First step
- Compute what the transform does to orientation: the scale (−1, 1, 1) has a determinant of −1, so it mirrors. A mirror reverses the order in which every triangle's corners appear on screen, so front faces now wind the other way and back-face culling removes them, leaving the inside faces visible.
- Follow-ups
-
- What does the glTF standard say about this case?
- Why is the lighting wrong as well, and which normals are correct?
- How do you detect mirrored objects at load time?
From the lesson Vectors, points, dot and cross products
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
After a scanned mesh is imported, a few pixels flicker black and one object sometimes disappears. You suspect NaN normals. How do you find the cause and fix it?
- What it tests
- Degenerate triangles, normalising a zero vector, how NaN spreads through later arithmetic, and guards in the importer and the shader.
- First step
- Look for triangles whose two edges have a cross product of length 0, three corners on one line or repeated corners: normalising their normals divides by 0 and gives NaN, and every value computed from a NaN is NaN. Count such triangles in the mesh before suspecting the shader.
- Follow-ups
-
- Why can one NaN make a whole object vanish, not just one pixel?
- What should normalize do with a zero vector?
- How would you test the importer so that this cannot return?
From the lesson Vectors, points, dot and cross products
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
A game object placed at (10, 0, 0) should spin in place, but it swings round the world origin instead. Its matrix is built every frame as R times T, with R's angle growing. Explain what happens with numbers, fix it, and say how you would stop the bug from coming back.
- What it tests
- Reading a matrix product right to left, rotations turning about the origin, and a test that tells the two orders apart.
- First step
- Apply the product to the object's own origin, (0, 0, 0). With M = R T, T moves it to (10, 0, 0) first and R then turns that point about the world origin: at 90 degrees it is at (0, 10, 0), so the object travels a circle of radius 10. Spinning in place needs the rotation applied first: M = T R.
- Follow-ups
-
- The object should also be scaled. Where does S go, and why?
- How do you rotate an object about a pivot that is not its own origin?
- What test would have caught this before it shipped?
From the lesson Matrices and homogeneous coordinates
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
After an artist stretches a round lamp to twice its width, its highlights and shading look wrong, while unstretched copies of the same mesh look right. Diagnose it with numbers and fix it in the renderer, not in the mesh.
- What it tests
- Why normals need the inverse transpose of the model matrix, how big the error is, and where the normal matrix is computed in a renderer.
- First step
- The stretch is a non-uniform scale, S(2, 1, 1). If the shader transforms normals with the model matrix itself, they tilt the wrong way: on a sphere scaled like this they are off by up to 36.87 degrees. Check what matrix the shader uses for normals; it should be the inverse transpose of the model matrix's 3 × 3 part.
- Follow-ups
-
- Why did the unstretched copies look right with the same code?
- Where would you compute the normal matrix, and how often?
- What happens to the normal matrix when the stretch includes a mirror?
From the lesson Matrices and homogeneous coordinates
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
In a flight simulator, the cockpit and the wings visibly shake when the aircraft is far from the world's origin, and sit still near it. Explain the cause with numbers and fix it without changing the world's units.
- What it tests
- How float32 spacing grows with magnitude, where positions lose precision on their way to the GPU, and camera-relative rendering as the fix.
- First step
- Work out the float32 gap at the aircraft's distance. A million metres from the origin, neighbouring float32 values are 0.0625 m apart, so every vertex position the GPU receives is rounded to a grid of 6.25 cm, and as the plane moves, its vertices jump between grid points by different amounts: the model shakes.
- Follow-ups
-
- Why does scaling the whole world down not help?
- Where exactly in the pipeline must the subtraction happen?
- What else in the frame breaks for the same reason?
From the lesson Floating point, precision and robust geometry
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A software rasteriser shows sparkling pixels along the shared edges of neighbouring triangles: a few pixels are drawn twice and a few are missing. Explain the cause and fix it so that it cannot happen.
- What it tests
- Edge functions evaluated in floating point, why two triangles disagree about a shared edge, and exact fixed-point edge tests with a tie rule.
- First step
- Each triangle evaluates its own edge function for the shared edge, E(a, b, p) and E(b, a, p). Exactly, one is the negative of the other; in float32 they are rounded separately, so near the edge both can come out positive (drawn twice) or both negative (a hole). Compute them exactly instead.
- Follow-ups
-
- Why are the bad pixels so rare, and why do they still show?
- How many sub-pixel bits would you use, and what limits the choice?
- Which triangle gets a pixel whose centre lies exactly on the edge?
From the lesson Floating point, precision and robust geometry
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
All Computer Graphics (rasterisation, ray tracing, WebGPU) interview questions · The Computer Graphics (rasterisation, ray tracing, WebGPU) track