「ゲームプログラミング/3Dグラフィック」の版間の差分

削除された内容 追加された内容
891 行
 
 
かなら先に被写体を公転させてから、あとからスクリーンに投影すること。
 
プログラムでアルゴリズムを書くときも先に公転させてから、あとから投影させることになる。
 
 
 
y軸を中心に回転させるとき、座標である点の位置の変わる座標軸成分は、x座標成分とz座標成分である。
 
 
 
数学の理論により回転行列の公式は
 
<math>
R =
\begin{pmatrix}
\cos \theta & -\sin \theta \\
\sin \theta & \cos \theta
\end{pmatrix}
</math>
 
である(『[[高等学校数学C/行列#回転行列]]』)。
 
 
実際にこの公式を3D-CGの回転計算で使うときは、
:<math> \begin{pmatrix}
\cos \theta & - \sin \theta \\
\sin \theta & \cos \theta
\end{pmatrix}
 
\begin{pmatrix} x \\ y \end{pmatrix}
 
= \begin{pmatrix} x \cos \theta - y \sin \theta
\\ x \sin \theta + y \cos \theta \end{pmatrix}
</math>
 
の形で使うだろう。
 
または、
:<math> \begin{pmatrix}
\cos \theta & - \sin \theta \\
\sin \theta & \cos \theta
\end{pmatrix}
 
\begin{pmatrix} x \\ y \end{pmatrix}
= x \begin{pmatrix} \cos \theta
\\ \sin \theta \end{pmatrix}
 
+
 
y \begin{pmatrix} - \sin \theta
\\ \cos \theta \end{pmatrix}
</math>
の形で使うだろう。
 
 
 
 
<syntaxhighlight lang="c">