Compute angle difference between 3D vectors. Args: v1: torch.Tensor of shape (..., 3) v2: torch.Tensor of shape (..., 3) eps: Small epsilon value for numerical stability Returns: torch.Tensor: Angle differences in radians
(v1, v2, eps=1e-12)
| 1680 | |
| 1681 | |
| 1682 | def angle_diff_vec3(v1, v2, eps=1e-12): |
| 1683 | """ |
| 1684 | Compute angle difference between 3D vectors. |
| 1685 | |
| 1686 | Args: |
| 1687 | v1: torch.Tensor of shape (..., 3) |
| 1688 | v2: torch.Tensor of shape (..., 3) |
| 1689 | eps: Small epsilon value for numerical stability |
| 1690 | |
| 1691 | Returns: |
| 1692 | torch.Tensor: Angle differences in radians |
| 1693 | """ |
| 1694 | cross_norm = torch.cross(v1, v2, dim=-1).norm(dim=-1) + eps |
| 1695 | dot_prod = (v1 * v2).sum(dim=-1) |
| 1696 | return torch.atan2(cross_norm, dot_prod) |
| 1697 | |
| 1698 | |
| 1699 | def angle_diff_vec3_numpy(v1: np.ndarray, v2: np.ndarray, eps: float = 1e-12): |
nothing calls this directly
no outgoing calls
no test coverage detected