Commit 8ac0f810 authored by Stephen Thompson's avatar Stephen Thompson

Modified Procrustes to return rotation

parent 84de9241
Pipeline #3650 failed with stages
in 4 minutes and 37 seconds
......@@ -52,8 +52,9 @@ def orthogonal_procrustes(fixed, moving):
# Note: numpy factors h = u * np.diag(s) * v
svd = np.linalg.svd(H)
# Arun equation 13
X = np.matmul(svd[2].transpose(), svd[0].transpose())
# Replace Arun Equation 13 with Fitzpatrick, chapter 8, page 470,
# to avoid reflections, see issue #19
X = _fitzpatricks_X(svd)
# Arun step 5, after equation 13.
det_X = np.linalg.det(X)
......@@ -85,7 +86,11 @@ def orthogonal_procrustes(fixed, moving):
return R, T, fre
def _fitzpatricks_X(svd):
"""Replace Arun Equation 13 with Fitzpatrick, chapter 8, page 470."""
"""This is from Fitzpatrick, chapter 8, page 470.
it's used in preference to Arun's equation 13,
X = np.matmul(svd[2].transpose(), svd[0].transpose())
to avoid reflections.
"""
VU = np.matmul(svd[2].transpose(), svd[0])
detVU = np.linalg.det(VU)
......
......@@ -92,9 +92,9 @@ def test_reflection_data():
def test_reflection_BARD_data():
"""This is a reflection test using data taken from using
BARD at the 2019 summer school. With this data I
consistently got reflections which was not the case when
using C++ BARD"""
BARD at the 2019 summer school. This data set will give
you reflections, unless you replace equation 13 from Arun
with Fitzpatrick's modification. This was done at issue #19"""
ct_fids = np.zeros((4,3))
world_fids = np.zeros((4,3))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment