Skip to content

Add a Camera.forward() getter (world-space viewing direction)#61

Open
dchaudhari7177 wants to merge 1 commit into
bamdadd:mainfrom
dchaudhari7177:feat/camera-forward
Open

Add a Camera.forward() getter (world-space viewing direction)#61
dchaudhari7177 wants to merge 1 commit into
bamdadd:mainfrom
dchaudhari7177:feat/camera-forward

Conversation

@dchaudhari7177

Copy link
Copy Markdown
Contributor

Closes #58.

Camera.centre() gives the camera position, but there was no getter for the direction the camera is looking — handy for logging, frustum checks, and "is this camera pointed the right way?" sanity tests.

Change: Camera.forward() -> FloatArray returns the world-space unit viewing direction. R's rows are the camera axes in world coordinates in the order [right, down, forward] (OpenCV, +z forward), so the forward axis is the third row — already unit length for an orthonormal R. Placed next to centre(). Pure read-only, no new dependency.

Acceptance criteria:

  • forward() returns a length-3 world-space unit vector (norm ≈ 1). ✅
  • Round-trip: a camera from Camera.look_at(0, intr, eye, target) has forward()normalize(target - eye). ✅

ruff check/format and mypy clean on the changed files; new tests pass.

@bamdadd

bamdadd commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Approved this one @dchaudhari7177 — thank you! It picked up a one-line conflict in cameras.py because #60 (the Intrinsics validator) merged just before it. Could you rebase on latest main and resolve? Should be trivial. Then it goes straight in. Closes #58.

centre() reads the camera position off R/t, but there was no getter for
the direction the camera is looking — useful for logging, frustum checks
and pointing sanity tests.

R's rows are the camera axes in world coordinates as [right, down, forward]
(OpenCV, +z forward), so the forward axis is the third row. forward()
returns it as a length-3 unit array. Read-only, no new dependency.

Closes bamdadd#58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Camera.forward() getter (world-space viewing direction)

3 participants