[[x1,x2],[y1,y2],[z1,z2]]Z
ṁ4ÆḊƝ
オンラインでお試しください!
SEマークダウンで処理できない場合のPDFの説明を次に示します。
分析形式のクロスプロダクト
(x1,y1,z1)v1→(x2,y2,z2)v2→
v1→=x1⋅i⃗ +y1⋅j⃗ +z1⋅k⃗
v2→=x2⋅i⃗ +y2⋅j⃗ +z2⋅k⃗
Oxyz
v1→×v2→=(x1⋅i⃗ +y1⋅j⃗ +z1⋅k⃗ )×(x2⋅i⃗ +y2⋅j⃗ +z2⋅k⃗ )
i⃗ ×j⃗ =k⃗ ,i⃗ ×k⃗ =−j⃗ ,j⃗ ×i⃗ =−k⃗ ,j⃗ ×k⃗ =i⃗ ,k⃗ ×i⃗ =j⃗ ,k⃗ ×j⃗ =−i⃗
After the necessary rearrangements and calculations:
v1→×v2→=(y1z2−z1y2)⋅i⃗ +(z1x2−x1z2)⋅j⃗ +(x1y2−y1x2)⋅k⃗
The close relationship with matrix determinants
There's an interesting thing to note here:
x1y2−y1x2=∣∣∣x1 x2y1y2∣∣∣
z1x2−x1z2=∣∣∣z1 z2x1x2∣∣∣
y1z2−z1y2=∣∣∣y1 y2z1z2∣∣∣
Where we use the notation |⋅| for matrix determinant. Notice the beautiful rotational symmetry?
Jelly code explanation
Well... not much to explain here. It just generates the matrix:
(x1 x2y1y2z1z2x1x2)
And for each pair of neighbouring matrices, it computes the determinant of the matrix formed by joining the two.
ṁ4ÆḊƝ – Monadic Link. Takes input as [[x1,x2],[y1,y2],[z1,z2]].
ṁ4 – Mold 4. Cycle the list up to length 4, reusing the elements if necessary.
Generates [[x1,x2],[y1,y2],[z1,z2],[x1,x2]].
Ɲ – For each pair of neighbours: [[x1,x2],[y1,y2]], [[y1,y2],[z1,z2]], [[z1,z2],[x1,x2]].
ÆḊ – Compute the determinant of those 2 paired together into a single matrix.