Last active
January 17, 2021 10:14
-
-
Save iliakonnov/608432e0a96799b7b8012b7c0223f8c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy.algebras.quaternion import Quaternion | |
from sympy import latex, Matrix, symbols | |
i, j, k = symbols('i j k') | |
def display(q): | |
return sum([ | |
x*y | |
for x, y in [(q.a, 1), | |
(q.b, i), | |
(q.c, j), | |
(q.d, k)] | |
]) | |
t = [Quaternion(1,0,0,0), Quaternion(-1,0,0,0), | |
Quaternion(0,1,0,0), Quaternion(0,-1,0,0), | |
Quaternion(0,0,1,0), Quaternion(0,0,-1,0), | |
Quaternion(0,0,0,1), Quaternion(0,0,0,-1)] | |
m = [[display(b)] + [display(b*a) for a in t] for b in t] | |
m = [[None] + [display(i) for i in t]] + m | |
print(latex(Matrix(m)).replace(r'\\', '\\\\\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment