As said above the square root of an arbitrary matrix is ambiguous and it's hard to say what the scipy implementation actually does.
When you have placement with rotation R and translation t and apply it twice, i.e. get the square you have:
y = R * (R * x + t) + t
y = R * (R * x) + R * t + t
y= (R * R) * x + (R + I) * t
this means you have the rotation Q = R * R and the translation s = (R + I) * t.
Now if you consider a placement with rotation Q and translation s you can easily get the square root of Q (by doing only the half rotation) but for the translation part you have to compute t = (R + I)^-1 * s and the question is if this matrix is always invertible.
Code: Select all
import math # arbitrarily rotate the object p=App.ActiveDocument.ActiveObject.Placement p.Base # Vector (-4.642491320876232, 2.744713842009025, 9.827212698728683) p.Rotation.Q # (0.14145656219842426, -0.6950597415393837, -0.4084936490538904, 0.5744692640906436) q=App.Rotation(p.Rotation.Axis, math.degrees(p.Rotation.Angle/2)) # compare the axes and angles p.Rotation.Axis q.Axis p.Rotation.Angle q.Angle # = p.Rotation.Angle/2 # get q as matrix r=q.toMatrix() r.determinant() # = 1.0 ok m = r + App.Matrix() # (R + I) from above m_inv = m.inverse() s = p.Base t = m_inv.multVec(s) p_root = App.Placement(t, q) # p_root * p_root gives the same as p p_root.multiply(p_root) # Placement [Pos=(-4.64249,2.74471,9.82721), Yaw-Pitch-Roll=(-114.246,-43.0795,90.4892)] p # Placement [Pos=(-4.64249,2.74471,9.82721), Yaw-Pitch-Roll=(-114.246,-43.0795,90.4892)] # the same for their matrix representations p.toMatrix() p_root.toMatrix().multiply(p_root.toMatrix())