You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

114 lines
4.0 KiB

  1. \documentclass[letterpaper,10pt]{article}
  2. \usepackage{amsmath}
  3. \usepackage[empty,cm]{fullpage}
  4. \pagenumbering{gobble}
  5. \begin{document}
  6. \title{Pannellum Equirectangular Projection Reference}
  7. \author{Matthew Petroff}
  8. \date{January 2013}
  9. \maketitle
  10. Let a coordinate system be defined with the origin at the focal point, the
  11. x-axis parallel to the camera's horizontal axis with positive to the right as
  12. viewed from behind the camera, the y-axis parallel to the camera's vertical
  13. axis with positive upward as viewed from behind the camera, and the z-axis be
  14. perpendicular to these two axes with positive extending away from the
  15. camera.\footnote{Note that this is a left-handed coordinate system.}
  16. Let \(\lambda\) represent the panorama's longitude, \(\phi\) the panorama's
  17. latitude, \(\theta\) the latitudinal offset, \(\psi\) the longitudinal offset,
  18. and \(f\) the focal length. Let \(\mathbf{a}\) represent a point's position
  19. vector, \(\mathrm{R}_x(\theta)\) the latitudinal rotation matrix,
  20. \(\mathbf{d}\) a point's position vector in the camera's reference frame, \(x\)
  21. and \(y\) a point's position on the image plane, and \(p_x\) and \(p_y\) a
  22. point's position on an equirectangular projection.
  23. \begin{equation} \label{eq:posvec}
  24. \mathbf{a} = \begin{bmatrix}
  25. \mathbf{a}_x \\ \mathbf{a}_y \\ \mathbf{a}_z
  26. \end{bmatrix} = \begin{bmatrix}
  27. \sin(\lambda)\cos(\phi) \\ \sin(\phi) \\ \cos(\phi)\cos(\lambda) \end{bmatrix}
  28. \end{equation}
  29. \begin{equation} \label{eq:rotmat}
  30. \mathrm{R}_x(\theta) = \begin{bmatrix}
  31. 1 & 0 & 0 \\
  32. 0 & \cos(\theta) & -\sin(\theta) \\
  33. 0 & \sin(\theta) & \cos(\theta)
  34. \end{bmatrix}
  35. \end{equation}
  36. With a point's position vector \eqref{eq:posvec} and the latitudinal rotation
  37. matrix \eqref{eq:rotmat}, one can calculate a point's position in the camera's
  38. reference frame.\nopagebreak
  39. \begin{equation}
  40. \mathbf{d} = \begin{bmatrix}
  41. \mathbf{d}_x \\ \mathbf{d}_y \\ \mathbf{d}_z
  42. \end{bmatrix} = \mathrm{R}_x(\theta)\mathbf{a} = \begin{bmatrix}
  43. 1 & 0 & 0 \\
  44. 0 & \cos(\theta) & -\sin(\theta) \\
  45. 0 & \sin(\theta) & \cos(\theta)
  46. \end{bmatrix}
  47. \begin{bmatrix}
  48. \sin(\lambda)\cos(\phi) \\ \sin(\phi) \\ \cos(\phi)\cos(\lambda)
  49. \end{bmatrix} = \begin{bmatrix}
  50. \sin(\lambda)\cos(\phi) \\
  51. \sin(\phi)\cos(\theta) - \cos(\phi)\cos(\lambda)\sin(\theta) \\
  52. \sin(\phi)\sin(\theta) + \cos(\phi)\cos(\lambda)\cos(\theta)
  53. \end{bmatrix}
  54. \end{equation}
  55. Using the pinhole camera model, one can then calculate positions on the
  56. image plane.\nopagebreak
  57. \begin{equation}
  58. \begin{bmatrix} x \\ y \end{bmatrix} = \frac{f}{\mathbf{d}_z}
  59. \begin{bmatrix} \mathbf{d}_x \\ \mathbf{d}_y \end{bmatrix}
  60. = \frac{f}{\sin(\phi)\sin(\theta) + \cos(\phi)\cos(\lambda)\cos(\theta)}
  61. \begin{bmatrix}
  62. \sin(\lambda)\cos(\phi) \\
  63. \sin(\phi)\cos(\theta) - \cos(\phi)\cos(\lambda)\sin(\theta)
  64. \end{bmatrix}
  65. \end{equation}
  66. \begin{equation} \label{eq:xf}
  67. \frac{x}{f} = \frac{\sin(\lambda)\cos(\phi)}{\sin(\phi)\sin(\theta) +
  68. \cos(\phi)\cos(\lambda)\cos(\theta)}
  69. \end{equation}
  70. \begin{equation} \label{eq:yf}
  71. \frac{y}{f} = \frac{\sin(\phi)\cos(\theta) -
  72. \cos(\phi)\cos(\lambda)\sin(\theta)}{\sin(\phi)\sin(\theta) +
  73. \cos(\phi)\cos(\lambda)\cos(\theta)}
  74. \end{equation}
  75. Solving the system of \eqref{eq:xf} and \eqref{eq:yf} for \(\lambda\) and
  76. \(\phi\) and adding the longitudinal offset, one is able to find a point's
  77. position on the unit sphere from its position on the image plane.\nopagebreak
  78. \begin{equation}
  79. \lambda = \tan ^{-1}\left(\frac{x}{\sqrt{x^2 + \left(f \cos(\theta) -
  80. y \sin(\theta) \right)^2}},\frac{f \cos(\theta) - y \sin(\theta)}{\sqrt{x^2 +
  81. \left(f \cos(\theta) - y \sin(\theta) \right)^2}}\right) + \psi
  82. \end{equation}
  83. \begin{equation}
  84. \phi = \tan ^{-1}\left(\frac{y \cos(\theta) + f \sin(\theta)}{\sqrt{x^2 +
  85. \left(f \cos(\theta) - y \sin(\theta) \right)^2}}\right)
  86. \end{equation}
  87. Once a point's position on the unit sphere is known, it is trivial to find its
  88. position on an equirectangular projection.\nopagebreak
  89. \begin{equation}
  90. p_x = \frac{\lambda}{\pi}
  91. \end{equation}
  92. \begin{equation}
  93. p_y = \frac{\phi}{\frac{\pi}{2}}
  94. \end{equation}
  95. \end{document}