clifford
clifford copied to clipboard
Unable to find square root of rotor formed by squaring a rotor
Not sure if this is an implementation bug or a flaw in Dorst's algorithm:
from clifford.g3c import *
import clifford.tools.g3c as gt
# a hopefully non-malicious rotor
root_R = (
-0.46193976625575045 +
(0.8001031451912575^e12) -
(0.191341716182552^e34) +
(0.3314135740356927^e1234)
)
assert root_R.isVersor()
assert root_R * ~root_R == 1
# square it
R = root_R * root_R
If I attempt to look at the root:
>>> R
-0.35355 - (0.61237^e12) - (0.35355^e34) - (0.61237^e1234)
>>> gt.general_root(R)
ValueError: No root exists
>>> gt.dorst_norm(R)
nan
I was using the wrong function, this is actually mostly fine:
>>> gt.square_roots_of_rotor(R)
(0.46194 - (0.8001^e12) + (0.19134^e34) - (0.33141^e1234),
nan + (nan^e1) + (nan^e2) + (nan^e3) + (nan^e4) + (nan^e5) + (nan^e12) + (nan^e13) + (nan^e14) + (nan^e15) + (nan^e23) + (nan^e24) + (nan^e25) + (nan^e34) + (nan^e35) + (nan^e45) + (nan^e123) + (nan^e124) + (nan^e125) + (nan^e134) + (nan^e135) + (nan^e145) + (nan^e234) + (nan^e235) + (nan^e245) + (nan^e345) + (nan^e1234) + (nan^e1235) + (nan^e1245) + (nan^e1345) + (nan^e2345) + (nan^e12345))
We should probably not return NaN for the second root though.