rotation_matrix

rotation_matrix#

rapidtools.processing.street_localization.rotation_matrix(rotation_vector: Sequence[float] | ndarray) → ndarray[source]#

Rotation matrix of an axis-angle vector (Rodrigues’ formula).

Mapillary’s computed_rotation is such a vector in OpenSfM’s convention: it rotates world coordinates (east, north, up) into camera coordinates (x right, y down, z forward), so R.T maps camera rays back into the world.

Example

>>> import numpy as np
>>> R = rotation_matrix([0.0, 0.0, 0.0])
>>> bool(np.allclose(R, np.eye(3)))
True
>>> R = rotation_matrix([0.0, 0.0, np.pi / 2])   # quarter turn about z
>>> [round(float(v), 6) for v in R @ np.array([1.0, 0.0, 0.0])]
[0.0, 1.0, 0.0]