v9.1.1
Menu

Transform Point World to Camera

easyPROPose EstimationPoseCV: Structure from Motion and SLAM

Transform a 3D point from world coordinates to camera coordinates.

The transformation from world to camera frame uses a rotation matrix R and translation vector t:

Xcam=R⋅Xworld+tX_{cam} = R \cdot X_{world} + t

where:

  • XworldX_{world} is the point in world coordinates
  • RR is the 3×3 rotation matrix (camera orientation)
  • tt is the translation vector (camera position)
  • XcamX_{cam} is the point in camera coordinates

This is a rigid transformation - it preserves distances and angles. The camera "looks down" its Z-axis, with X pointing right and Y pointing down (typical convention).

Example

Input
transform_point([[1,0,0],[0,1,0],[0,0,1]], [1, 2, 3], [0, 0, 0])
Output
[1, 2, 3]
Reasoning
  • Inputs: R is the 3×33 \times 3 identity matrix II (ones on the diagonal, zeros elsewhere), so the camera axes line up exactly with the world axes. t is (1,2,3)(1, 2, 3), and point is the world origin (0,0,0)(0, 0, 0).
  • Rotate: each camera coordinate is one row of RR dotted with the point, e.g. the first is 1⋅0+0⋅0+0⋅0=01 \cdot 0 + 0 \cdot 0 + 0 \cdot 0 = 0. Every row gives 00, so R⋅Xworld=(0,0,0)R \cdot X_{world} = (0, 0, 0). Rotating the origin never moves it, whatever RR is.
  • Translate: add tt component by component: (0+1, 0+2, 0+3)=(1,2,3)(0 + 1,\ 0 + 2,\ 0 + 3) = (1, 2, 3).
  • Output: [1, 2, 3], a list of three numbers (X′,Y′,Z′)(X', Y', Z'). Since the inputs are integers, the entries stay integers.
  • Notice: tt is exactly where the world origin lands in the camera frame. Swap the roles (point (1,2,3)(1, 2, 3), t=0t = 0) and the identity rotation hands the point back unchanged, also giving (1,2,3)(1, 2, 3).

Constraints

  • R: 3x3 rotation matrix
  • t: translation vector [tx, ty, tz]
  • point: [X, Y, Z] in world coordinates
  • Return transformed point [X', Y', Z'] in camera coordinates

Learn this in

More from CV: Structure from Motion and SLAM

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.