|
二重四元数(Dual quaternion)
OPTION BASE 0
DIM A(7),B(7),C(7)
DATA 1,2,3,4,0,0,0,0
DATA 4,3,2,1,0,0,0,0
MAT READ A,B
CALL MUL(C,A,B)
PRINT STR$(C(0));" + ";STR$(C(1));"i + ";STR$(C(2));"j + ";STR$(C(3));"k + ";STR$(C(4));"ε + ";STR$(C(5));"εi + ";STR$(C(6));"εj + ";STR$(C(7));"εk"
END
!'EXTERNAL SUB MUL(A(),B(),S()) !'掛け算
!'OPTION BASE 0
!'DIM T$(7,7)
!'MAT S=ZER
!'MAT READ T$
!'FOR I=0 TO 7
!' FOR J=0 TO 7
!' IF A(I)<>0 AND B(J)<>0 THEN
!' IF T$(I,J)="-0" THEN
!' LET S(0)=S(0)-A(I)*B(J)
!' ELSEIF T$(I,J)<>"*" THEN
!' LET D=VAL(T$(I,J))
!' IF D>=0 THEN
!' LET S(D)=S(D)+A(I)*B(J)
!' ELSE
!' LET S(-D)=S(-D)-A(I)*B(J)
!' END IF
!' END IF
!' END IF
!' NEXT J
!'NEXT I
!'DATA 0, 1, 2, 3, 4, 5, 6, 7
!'DATA 1, -0, 3, -2, 5, -4, 7, -6
!'DATA 2, -3, -0, 1, 6, -7, -4, 5
!'DATA 3, 2, -1, -0, 7, 6, -5, -4
!'DATA 4, 5, 6, 7, "*", "*", "*", "*"
!'DATA 5, -4, 7, -6, "*", "*", "*", "*"
!'DATA 6, -7, -4, 5, "*", "*", "*", "*"
!'DATA 7, 6, -5, -4, "*", "*", "*", "*"
!'(置換) "1" → 0 , "i" → 1 , "j" → 2 , "k" → 3 , "ε" → 4, "εi" → 5 , "εj" → 6 , "εk" → 7
!' 1, i, j, k, ε, εi, εj, εk
!' i, -1, k, -j, εi, -ε, εk, -εj
!' j, -k, -1, i, εj, -εk, -ε, εi
!' k, j, -i, -1, εk, εj, -εi, -ε
!' ε, εi, εj, εk, 0, 0, 0, 0
!' εi, -ε, εk, -εj, 0, 0, 0, 0
!' εj, -εk, -ε, εi, 0, 0, 0, 0
!' εk, εj, -εi, -ε, 0, 0, 0, 0
!'END SUB
EXTERNAL SUB MUL(S(),A(),B()) !'掛け算
LET S(0)=A(0)*B(0)-A(1)*B(1)-A(2)*B(2)-A(3)*B(3)
LET S(1)=A(0)*B(1)+A(1)*B(0)+A(2)*B(3)-A(3)*B(2)
LET S(2)=A(0)*B(2)-A(1)*B(3)+A(2)*B(0)+A(3)*B(1)
LET S(3)=A(0)*B(3)+A(1)*B(2)-A(2)*B(1)+A(3)*B(0)
LET S(4)=A(0)*B(4)-A(1)*B(5)-A(2)*B(6)-A(3)*B(7)+A(4)*B(0)-A(5)*B(1)-A(6)*B(2)-A(7)*B(3)
LET S(5)=A(0)*B(5)+A(1)*B(4)+A(2)*B(7)-A(3)*B(6)+A(4)*B(1)+A(5)*B(0)+A(6)*B(3)-A(7)*B(2)
LET S(6)=A(0)*B(6)-A(1)*B(7)+A(2)*B(4)+A(3)*B(5)+A(4)*B(2)-A(5)*B(3)+A(6)*B(0)+A(7)*B(1)
LET S(7)=A(0)*B(7)+A(1)*B(6)-A(2)*B(5)+A(3)*B(4)+A(4)*B(3)+A(5)*B(2)-A(6)*B(1)+A(7)*B(0)
END SUB
|
|