Skip to content

plotting

angle_from_rotmat(R)

theta = np.random.rand() * 2*np.pi - np.pi thetae = angle_from_rotmat(rotmat2D(theta)) np.allclose(thetae, theta) True

Source code in bayes_cbf/plotting.py
189
190
191
192
193
194
195
196
def angle_from_rotmat(R):
    """
    >>> theta = np.random.rand() * 2*np.pi - np.pi
    >>> thetae = angle_from_rotmat(rotmat2D(theta))
    >>> np.allclose(thetae, theta)
    True
    """
    return np.arctan2(R[1, 0], R[0, 0])

var_to_scale_theta(V)

scale = np.abs(np.random.rand(2)) * 10 theta = np.random.rand() * (2*np.pi) - np.pi s, t = var_to_scale_theta(scale_theta_to_var(scale, theta)) allclose = partial(np.allclose, rtol=1e-2, atol=1e-5) allclose(s, scale) True allclose(t, theta) True

Source code in bayes_cbf/plotting.py
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
def var_to_scale_theta(V):
    """
    >>> scale = np.abs(np.random.rand(2)) * 10
    >>> theta = np.random.rand() * (2*np.pi) - np.pi
    >>> s, t = var_to_scale_theta(scale_theta_to_var(scale, theta))
    >>> allclose = partial(np.allclose, rtol=1e-2, atol=1e-5)
    >>> allclose(s, scale)
    True
    >>> allclose(t, theta)
    True
    """
    w, E = np.linalg.eig(V)
    scale = 3*w
    theta = angle_from_rotmat(E)
    return scale, theta