C++ code to perform the Lorentz boosts and rotations of special relativity using complex quaternions The interface is a complex quaternion console-based calculator with operations + - * / and functions for Lorentz boosts and rotations.
THEORY
Complex quaternions have form
q = A + B * I + C * J + D * K
A, B, C, D complex
I * I = -1
J * J = -1
K * K = -1
I * J = K
J * I = -K
J * K = I
K * J = -I
K * I = J
I * K = -J
Transpose T takes I into -I, J into -J, K into -K
(q1 q2)T = q2T q1T
Star complex conjugates A, B, C, D
Bar is product of T and Star
Norm(q) = qTq can be complex, even zero
q in group H1 iff q qT = qT q = 1
4-vector X=t + i*x*I +i*y*J + i*z*K
XPRIME = q X Bar(q) for q in H1
Form with real scalar, imaginary spatial is preserved
Bar(X) = X
Bar(XPRRIME )= XPRIME
Norm(XPRIME) = Norm(X) = t*t - x*x - y*y - z*z
q=cos(theta/2)+K*sin(theta/2) rotates by theta about z
q=cosh(alpha/2)+i*I*sinh(alpha/2) boosts by alpha along x
Features
- Interface is a complex quaternion calculator with console command line.
- Lorentz boosts and rotations on 4-vectors performed using complex quaternion transformation functions. Thomas precession is easily calculated.
- Calculator has + - * / (when A*A+B*B+C*C+D*D is not zero), Lorentz rotation and boost functions
- Calculator has scientific notation and well-defined exp, sin, sinh,, ... for quaternions
- Variables can simultaneously be complex quaternions, arrays, of complex quaternions, and strings for user-defined functions or command sequences
- Arrays up to ten dimensions with definition by equation, resizing, mapping
- User defined functions. Execute commands strings with loop count and flag test.
- Help, examples, demo, and math explanations can be displayed by the calculator
- Uses namespaces and C++ classes such as class Quaternion and class Calculator with overloaded operators. Hash table for variable and function names with linked lists for collisions.
- Uses STL template libraries such as <complex> and <vector>
- Builds with WSL2 Ubuntu and Debian g++, Raspbian Bullseye g++, Visual Studio 2022. See notes in formulaquat.cpp
- Standard console text size can be made large using control key and center mouse wheel (WSL2) or Ctrl-Shift-Plus (Raspbian)