空間における線形変換・アフィン変換

0. 立方体の面のデータ

P1:=5*{{0,0,0},{1,0,0},{1,1,0},{0,1,0},{0,0,0}};
P6:=5*{{0,0,1},{1,0,1},{1,1,1},{0,1,1},{0,0,1}};
P2:=5*{{0,0,0},{1,0,0},{1,0,1},{0,0,1},{0,0,0}};
P4:=5*{{0,1,0},{1,1,0},{1,1,1},{0,1,1},{0,1,0}};
P3:=5*{{0,0,0},{0,1,0},{0,1,1},{0,0,1},{0,0,0}};
P5:=5*{{1,0,0},{1,1,0},{1,1,1},{1,0,1},{1,0,0}};

Graphics3D[{Polygon[P1],Polygon[P2],Polygon[P3],Polygon[P4],Polygon[P5],Polygon[P6]}]

1. 一般の線形変換

M[a11_,a12_,a13_,a21_,a22_,a23_,a31_,a32_,a33_]:=(({{a11, a12, a13}, {a21, a22, a23}, {a31, a32, a33}}));
Manipulate[
Show[
Graphics3D[
{Arrow[{{-20,0,0},{20,0,0}}],Text["x軸",{21.5,0,0}],
Arrow[{{0,-20,0},{0,20,0}}],Text["y軸",{0,21.5,0}],
Arrow[{{0,0,-20},{0,0,20}}],Text["z軸",{0,0,21.5}]},Boxed->False
],
Graphics3D[{
Polygon[P1.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]],
Polygon[P2.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]],
Polygon[P3.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]],
Polygon[P4.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]],
Polygon[P5.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]],
Polygon[P6.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]],
Text[M[a1,a2,a3,b1,b2,b3,c1,c2,c3],{-15,-15,15}]
}],
Graphics3D[{Dashed,Line[P1],Line[P2],Line[P3],Line[P4],Line[P5],Line[P6]}]
],
Style["行列の第1列の成分",12,Bold],
{{a1,1,"第1行"},-4,4},{{b1,0,"第2行"},-4,4},{{c1,0,"第3行"},-4,4},
Delimiter,Style["行列の第1列の成分",12,Bold],
{{a2,0,"第1行"},-4,4},{{b2,1,"第2行"},-4,4},{{c2,0,"第3行"},-4,4},
Delimiter,Style["行列の第1列の成分",12,Bold],
{{a3,0,"第3行"},-4,4},{{b3,0,"第3行"},-4,4},{{c3,1,"第3行"},-4,4},
SaveDefinitions->True, ControlPlacement->Left
]

2.1. z軸を回転軸とする回転

Rz[s_]:=(({{Cos[s], -Sin[s], 0}, {Sin[s], Cos[s], 0}, {0, 0, 1}}));
Manipulate[
Show[
Graphics3D[
{Arrow[{{-10,0,0},{10,0,0}}],Text["x軸",{11.5,0,0}],
Arrow[{{0,-10,0},{0,10,0}}],Text["y軸",{0,11.5,0}],
Arrow[{{0,0,-10},{0,0,10}}],Text["z軸",{0,0,11.5}]},Boxed->False
],
Graphics3D[{
Polygon[P1.Transpose[Rz[s]]],
Polygon[P2.Transpose[Rz[s]]],
Polygon[P3.Transpose[Rz[s]]],
Polygon[P4.Transpose[Rz[s]]],
Polygon[P5.Transpose[Rz[s]]],
Polygon[P6.Transpose[Rz[s]]]}],
Graphics3D[{Dashed,Line[P1],Line[P2],Line[P3],Line[P4],Line[P5],Line[P6]}]
],
{{s,0,"回転角"},0,2Pi},
SaveDefinitions->True]

2.2. x軸を回転軸とする回転

Rx[s_]:=(({{1, 0, 0}, {0, Cos[s], -Sin[s]}, {0, Sin[s], Cos[s]}}));
Manipulate[
Show[
Graphics3D[
{Arrow[{{-10,0,0},{10,0,0}}],Text["x軸",{11.5,0,0}],
Arrow[{{0,-10,0},{0,10,0}}],Text["y軸",{0,11.5,0}],
Arrow[{{0,0,-10},{0,0,10}}],Text["z軸",{0,0,11.5}]},Boxed->False
],
Graphics3D[{
Polygon[P1.Transpose[Rx[s]]],
Polygon[P2.Transpose[Rx[s]]],
Polygon[P3.Transpose[Rx[s]]],
Polygon[P4.Transpose[Rx[s]]],
Polygon[P5.Transpose[Rx[s]]],
Polygon[P6.Transpose[Rx[s]]]}],
Graphics3D[{Dashed,Line[P1],Line[P2],Line[P3],Line[P4],Line[P5],Line[P6]}]
],
{{s,0,"回転角"},0,2Pi},
SaveDefinitions->True]

2.3. y軸を回転軸とする回転

Ry[s_]:=(({{Cos[s], 0, -Sin[s]}, {0, 1, 0}, {Sin[s], 0, Cos[s]}}));
Manipulate[
Show[
Graphics3D[
{Arrow[{{-10,0,0},{10,0,0}}],Text["x軸",{11.5,0,0}],
Arrow[{{0,-10,0},{0,10,0}}],Text["y軸",{0,11.5,0}],
Arrow[{{0,0,-10},{0,0,10}}],Text["z軸",{0,0,11.5}]},Boxed->False
],
Graphics3D[{
Polygon[P1.Transpose[Ry[s]]],
Polygon[P2.Transpose[Ry[s]]],
Polygon[P3.Transpose[Ry[s]]],
Polygon[P4.Transpose[Ry[s]]],
Polygon[P5.Transpose[Ry[s]]],
Polygon[P6.Transpose[Ry[s]]]}],
Graphics3D[{Dashed,Line[P1],Line[P2],Line[P3],Line[P4],Line[P5],Line[P6]}]
],
{{s,0,"回転角"},0,2Pi},
SaveDefinitions->True]

2.4. 原点を通る直線を回転軸とする回転

ax[u_,v_]:=Cos[u]*Cos[v];
ay[u_,v_]:=Sin[u]*Cos[v];
az[u_,v_]:=Sin[v];R3[s_][u_,v_]:=(({{Cos[s]+(1-Cos[s])*(ax[u,v])^2, (1-Cos[s])*ax[u,v]*ay[u,v]-az[u,v]*Sin[s], (1-Cos[s])*ax[u,v]*az[u,v]+ay[u,v]*Sin[s]}, {(1-Cos[s])*ax[u,v]*ay[u,v]+az[u,v]*Sin[s], Cos[s]+(1-Cos[s])*(ay[u,v])^2, (1-Cos[s])*ay[u,v]*az[u,v]-ax[u,v]*Sin[s]}, {(1-Cos[s])*ax[u,v]*az[u,v]-ay[u,v]*Sin[s], (1-Cos[s])*ay[u,v]*az[u,v]+ax[u,v]*Sin[s], Cos[s]+(1-Cos[s])*(az[u,v])^2}}));
Manipulate[
Show[
Graphics3D[
{Arrow[{{-10,0,0},{10,0,0}}],Text["x軸",{11.5,0,0}],
Arrow[{{0,-10,0},{0,10,0}}],Text["y軸",{0,11.5,0}],
Arrow[{{0,0,-10},{0,0,10}}],Text["z軸",{0,0,11.5}]},Boxed->False
],
Graphics3D[{Thick,Red,Line[{-10*{ax[u[[1]],u[[2]]],ay[u[[1]],u[[2]]],az[u[[1]],u[[2]]]},10*{ax[u[[1]],u[[2]]],ay[u[[1]],u[[2]]],az[u[[1]],u[[2]]]}}]}],
Graphics3D[{
Polygon[P1.Transpose[R3[s][u[[1]],u[[2]]]]],
Polygon[P2.Transpose[R3[s][u[[1]],u[[2]]]]],
Polygon[P3.Transpose[R3[s][u[[1]],u[[2]]]]],
Polygon[P4.Transpose[R3[s][u[[1]],u[[2]]]]],
Polygon[P5.Transpose[R3[s][u[[1]],u[[2]]]]],
Polygon[P6.Transpose[R3[s][u[[1]],u[[2]]]]]}],
Graphics3D[{Dashed,Line[P1],Line[P2],Line[P3],Line[P4],Line[P5],Line[P6]}]
],
{{u,{Pi/2,Pi/2},"回転軸"},{0,0},{2Pi,Pi/2}},
Delimiter,{{s,0,"回転角"},0,2Pi},
SaveDefinitions->True, ControlPlacement->Left
]

3.  原点を通る平面に関する鏡映

ax[u_,v_]:=Cos[u]*Cos[v];
ay[u_,v_]:=Sin[u]*Cos[v];
az[u_,v_]:=Sin[v];
S3[u_,v_]:=(({{1-2ax[u,v]^2, -2ax[u,v]*ay[u,v], -2ax[u,v]*az[u,v]}, {-2ax[u,v]*ay[u,v], 1-2ay[u,v]^2, -2ay[u,v]*az[u,v]}, {-2ax[u,v]*az[u,v], -2ay[u,v]*az[u,v], 1-2az[u,v]^2}}));
Manipulate[
Show[
Graphics3D[
{Arrow[{{-10,0,0},{10,0,0}}],Text["x軸",{11.5,0,0}],
Arrow[{{0,-10,0},{0,10,0}}],Text["y軸",{0,11.5,0}],
Arrow[{{0,0,-10},{0,0,10}}],Text["z軸",{0,0,11.5}]},Boxed->False
],
Graphics3D[{
Polygon[P1.Transpose[S3[u[[1]],u[[2]]]]],
Polygon[P2.Transpose[S3[u[[1]],u[[2]]]]],
Polygon[P3.Transpose[S3[u[[1]],u[[2]]]]],
Polygon[P4.Transpose[S3[u[[1]],u[[2]]]]],
Polygon[P5.Transpose[S3[u[[1]],u[[2]]]]],
Polygon[P6.Transpose[S3[u[[1]],u[[2]]]]]}],
Graphics3D[{Dashed,Line[P1],Line[P2],Line[P3],Line[P4],Line[P5],Line[P6]}],
ContourPlot3D[ax[u[[1]],u[[2]]]*X+ay[u[[1]],u[[2]]]*Y+az[u[[1]],u[[2]]]*Z==0,
{X,-11.5,11.5},{Y,-11.5,11.5},{Z,-11.5,11.5},Mesh->None,ContourStyle->Directive[Orange,Opacity[0.5]]
],
Graphics3D[{Blue,Thick,Arrow[{{0,0,0},8{ax[u[[1]],u[[2]]],ay[u[[1]],u[[2]]],az[u[[1]],u[[2]]]}}]}]
],
Delimiter,Style["平面の法線ベクトル",12,Bold],
{{u,{2Pi,Pi/2},"方向"},{0,0},{2Pi,Pi/2}},
SaveDefinitions->True, ControlPlacement->Left
]

4. 相似変換

H3[s_]:=(({{s, 0, 0}, {0, s, 0}, {0, 0, s}}));
Manipulate[
Show[
Graphics3D[
{Arrow[{{-20,0,0},{20,0,0}}],Text["x軸",{21.5,0,0}],
Arrow[{{0,-20,0},{0,20,0}}],Text["y軸",{0,21.5,0}],
Arrow[{{0,0,-20},{0,0,20}}],Text["z軸",{0,0,21.5}]},Boxed->False
],
Graphics3D[{
Polygon[P1.Transpose[H3[s]]],
Polygon[P2.Transpose[H3[s]]],
Polygon[P3.Transpose[H3[s]]],
Polygon[P4.Transpose[H3[s]]],
Polygon[P5.Transpose[H3[s]]],
Polygon[P6.Transpose[H3[s]]]}],
Graphics3D[{Dashed,Line[P1],Line[P2],Line[P3],Line[P4],Line[P5],Line[P6]}]
],
{{s,1,"拡大・縮小率"},-3,3},
SaveDefinitions->True]

5. 一般のアフィン変換

Manipulate[
Show[
Graphics3D[
{Arrow[{{-20,0,0},{20,0,0}}],Text["x軸",{21.5,0,0}],
Arrow[{{0,-20,0},{0,20,0}}],Text["y軸",{0,21.5,0}],
Arrow[{{0,0,-20},{0,0,20}}],Text["z軸",{0,0,21.5}]},Boxed->False
],
Graphics3D[{
Polygon[P1.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]+{{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3}}],
Polygon[P2.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]+{{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3}}],
Polygon[P3.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]+{{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3}}],
Polygon[P4.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]+{{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3}}],
Polygon[P5.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]+{{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3}}],
Polygon[P6.Transpose[M[a1,a2,a3,b1,b2,b3,c1,c2,c3]]+{{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3},{v1,v2,v3}}],
Text[M[a1,a2,a3,b1,b2,b3,c1,c2,c3],{-15,-15,15}]
}],
Graphics3D[{Dashed,Line[P1],Line[P2],Line[P3],Line[P4],Line[P5],Line[P6]}]
],
Style["行列の第1列の成分",12,Bold],
{{a1,1,"第1行"},-4,4},{{b1,0,"第2行"},-4,4},{{c1,0,"第3行"},-4,4},
Delimiter,Style["行列の第1列の成分",12,Bold],
{{a2,0,"第1行"},-4,4},{{b2,1,"第2行"},-4,4},{{c2,0,"第3行"},-4,4},
Delimiter,Style["行列の第1列の成分",12,Bold],
{{a3,0,"第3行"},-4,4},{{b3,0,"第3行"},-4,4},{{c3,1,"第3行"},-4,4},
Delimiter,Style["平行移動ベクトルの成分",12,Bold],
{{v1,0,"第1成分"},-5,5},{{v2,0,"第2成分"},-5,5},{{v3,0,"第3成分"},-5,5},
SaveDefinitions->True, ControlPlacement->Left
]