Skip to content

Commit

Permalink
bugfix: fix div/0 err in quat->unit vec conversion
Browse files Browse the repository at this point in the history
Addresses portion of #19
  • Loading branch information
blackwer committed Dec 7, 2023
1 parent f29c537 commit daf142f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ManifoldEM/GetDistancesS2.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def quats_to_unit_vecs(q: NDArray[Shape["4,*"], Float64]) -> NDArray[Shape["3,*"
def get_psi(q: NDArray[Shape["4"], Float64], ref_vec: NDArray[Shape["3"], Float64]) -> float:
s = -(1 + ref_vec[2]) * q[3] - ref_vec[0] * q[1] - ref_vec[1] * q[2]
c = (1 + ref_vec[2]) * q[0] + ref_vec[1] * q[1] - ref_vec[0] * q[2]
psi = 2 * np.arctan(s / c) # note that the Psi are in the interval [-pi,pi]
if c == 0.0:
psi = np.sign(s) * np.pi
else:
psi = 2 * np.arctan(s / c) # note that the Psi are in the interval [-pi,pi]

return psi

Expand Down

0 comments on commit daf142f

Please sign in to comment.