PIXELBANKv9.1.0
Menu

You are given a point in planar image coordinates (centered at optical axis) and need to project it onto a cylindrical surface.

Cylindrical projection wraps the image around a cylinder of radius equal to the focal length:

x′=f⋅arctan⁡(xf)x' = f \cdot \arctan\left(\frac{x}{f}\right) y′=f⋅yx2+f2y' = \frac{f \cdot y}{\sqrt{x^2 + f^2}}

Where:

  • (x,y)(x, y) is the input point (relative to image center)
  • ff is the focal length in pixels
  • (x′,y′)(x', y') is the cylindrical coordinate

Cylindrical projection has two key benefits:

  1. Rotation around the camera's vertical axis becomes pure horizontal translation
  2. This simplifies panorama stitching to 1D alignment

Example:

Input:
point = (100, 50)
f = 500
Output:
(98.6939, 49.0098)
Reasoning:

Applying cylindrical projection formulas:

  1. x' = f × arctan(x/f) = 500 × arctan(100/500) = 500 × arctan(0.2) = 500 × 0.1974 (radians) = 98.6939

  2. y' = f × y / √(x² + f²) = 500 × 50 / √(100² + 500²) = 25000 / √(10000 + 250000) = 25000 / √260000 = 25000 / 509.902 = 49.0098

Result: (98.6939, 49.0098)

The x coordinate shrinks slightly (100 → 98.69) and y also adjusts.

Constraints:

  • point is (x, y) in planar coordinates, centered at image center
  • f is the focal length in pixels
  • Return (x', y') in cylindrical coordinates
  • Round to 4 decimal places
🔒

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

0/0
Run code to see test results.
Cylindrical Projection - Medium | PixelBank