MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / rotation_angle

Function rotation_angle

eval_code/recons/relpose/metric.py:16–29  ·  view source on GitHub ↗
(rot_gt, rot_pred, batch_size=None, eps=1e-15)

Source from the content-addressed store, hash-verified

14 return i1, i2
15
16def rotation_angle(rot_gt, rot_pred, batch_size=None, eps=1e-15):
17 #########
18 q_pred = mat_to_quat(rot_pred)
19 q_gt = mat_to_quat(rot_gt)
20
21 loss_q = (1 - (q_pred * q_gt).sum(dim=1) ** 2).clamp(min=eps)
22 err_q = torch.arccos(1 - 2 * loss_q)
23
24 rel_rangle_deg = err_q * 180 / np.pi
25
26 if batch_size is not None:
27 rel_rangle_deg = rel_rangle_deg.reshape(batch_size, -1)
28
29 return rel_rangle_deg
30
31
32

Callers 1

Calls 1

mat_to_quatFunction · 0.90

Tested by

no test coverage detected