HP Forums

Full Version: Quaternions: Convert to a 2 x 2 matrix form
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
QTM(A,B,C,D)
BEGIN
RETURN [[A+B*i, C+D*i],
[-C+D*i, A-B*i]];
END;

For more details, please visit my blog at: http://edspi31415.blogspot.com/2015/06/h...nions.html
hi Eddie,
after your blog, a modified version with some extensions inside...

Salvo

Code:

// Quaternion by Eddie W. Shore

EXPORT QTM(A,B,C,D)
BEGIN
RETURN [[A+B*i, C+D*i],
[-C+D*i, A-B*i]];
END;

// Norm
EXPORT QTM_norm(A,B,C,D)
BEGIN
RETURN sqrt(A^2+B^2+C^2+D^2);
END;

// Unit Quaternion matrix
EXPORT QTM_Unit(A,B,C,D)
BEGIN
LOCAL mat, n;
mat:= QTM(A,B,C,D);
n:= QTM_norm(A,B,C,D);
RETURN mat/n;
END;

// Conjugate of Q. matrix
EXPORT QTM_conj(A,B,C,D)
BEGIN
RETURN (QTM(A,B,C,D))^(-1) * QTM_norm(A,B,C,D)^2;
END;
Reference URL's