pycvcam.FisheyeDistortion._cartesian_to_polar#
- FisheyeDistortion._cartesian_to_polar(cartesian, dx=True)[source]#
Convert cartesian coordinates to polar coordinates.
The input
cartesianpoints are given in the form \((x, y)\) with shape (n_points, 2). The outputpolarpoints are given in the form \((r, \theta)\) with shape (n_points, 2), where \(r = \sqrt{x^2 + y^2}\) and \(\theta = \arctan2(y, x)\).\[\begin{split}\begin{bmatrix} r \\ \theta \\ \end{bmatrix} = \begin{bmatrix} \sqrt{x^2 + y^2} \\ \arctan2(y, x) \\ \end{bmatrix}\end{split}\]The jacobian with respect to the cartesian points is an array with shape (n_points, 2, 2).
\[\begin{split}J = \begin{bmatrix} \frac{\partial r}{\partial x} & \frac{\partial r}{\partial y} \\ \frac{\partial \theta}{\partial x} & \frac{\partial \theta}{\partial y} \\ \end{bmatrix} = \begin{bmatrix} \frac{x}{\sqrt{x^2 + y^2}} & \frac{y}{\sqrt{x^2 + y^2}} \\ -\frac{y}{x^2 + y^2} & \frac{x}{x^2 + y^2} \\ \end{bmatrix}\end{split}\]Warning
This method is not intended to be used directly, but rather through the
pycvcam.core.Transform.transform()method. Please ensure, the shape of the inputcartesianis (n_points, 2) before calling this method.- Parameters:
cartesian (numpy.ndarray) – The cartesian points to be converted. Shape (n_points, 2).
dx (bool, optional) – If True, the jacobian with respect to the cartesian points is computed. Default is True.
- Returns:
polar (numpy.ndarray) – The polar points. Shape (n_points, 2).
jacobian_dx (Optional[numpy.ndarray]) – The jacobian of the polar points with respect to the cartesian points. Shape (n_points, 2, 2) if dx is True, otherwise None.
- Return type: