空間座標上の2点の距離を算出


\[ distance = \sqrt{(B_x-A_x)^2+(B_y-A_y)^2+(B_z-A_z)^2} \]
空間の3点を通る円の中心を算出


\begin{align} \overrightarrow{AB}=& \begin{pmatrix} B_x-A_x \\ B_y-A_y \\ B_z-A_z \end{pmatrix} \\ \overrightarrow{AC}=& \begin{pmatrix} C_x-A_x \\ C_y-A_y \\ C_z-A_z \end{pmatrix} \\ \overrightarrow{ABAC}=&\overrightarrow{AB}\times \overrightarrow{AC} \\ \end{align} 3元連立方程式を解きます \[ \begin{bmatrix} 2AB_x & 2AB_y & 2AB_z \\ 2AC_x & 2AC_y & 2AC_z \\ ABAC_x & ABAC_y & ABAC_z \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} B^2-A^2 \\ C^2-A^2 \\ ABAC\circ A \end{bmatrix} \] \(\times \) は外積(クロス積)、\(\circ \) はアダマール積(成分ごとの積)
空間の3点を通る円の中心を算出


X軸周り \[ out= \begin{bmatrix} 1 & 0 & 0 \\ 0 & cos{\theta} & -sin{\theta} \\ 0 & sin{\theta} & cos{\theta} \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ \end{bmatrix} \] Y軸周り \[ out= \begin{bmatrix} cos{\theta} & 0 & sin{\theta} \\ 0 & 1 & 0 \\ -sin{\theta} & 0 & cos{\theta} \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ \end{bmatrix} \] Z軸周り \[ out= \begin{bmatrix} cos{\theta} & -sin{\theta} & 0 \\ sin{\theta} & cos{\theta} & 0 \\ 0 & 0 & 0 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ \end{bmatrix} \]
オイラー角を回転行列に変換(EulerToMatrix)して回転(matRotate3D)

# この動画は計算の手順をイメージするもので実際の計算は最初の位置から最後の位置を直接算出します

\[ out= \begin{bmatrix} m00 & m01 & m02 \\ m10 & m11 & m12 \\ m20 & m21 & m22 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ \end{bmatrix} \]


元のベクトル
\[
Q1=
\begin{bmatrix}
q_w \\
q_x \\
q_y \\
q_z \\
\end{bmatrix}
=
\begin{bmatrix}
0 \\
x \\
y \\
z \\
\end{bmatrix}
=
\begin{bmatrix}
0 \\
point.x \\
point.y \\
point.z \\
\end{bmatrix}
\]
回転軸(単位ベクトル)
\[
T=
\begin{bmatrix}
vector.x \\
vector.y \\
vector.z \\
\end{bmatrix}
\]
回転を表すクォータニオン
\[
R=
\begin{bmatrix}
q_w \\
q_x \\
q_y \\
q_z \\
\end{bmatrix}
=
\begin{bmatrix}
cos\frac{\theta}{2} \\
sin\frac{\theta}{2} T_x \\
sin\frac{\theta}{2} T_y \\
sin\frac{\theta}{2} T_z \\
\end{bmatrix}
\]
回転の計算
\[
out = R \times Q1 \times \bar{R}
\]

コイル
半径10で1回転にZ軸に10上に伸びるコイル形状の座標を求める例です
0度から1800度までを計算すると上記の「コイル」の図形が描けます

\begin{align} \theta = \frac{\pi}{180} \times Angle \\ r= \frac{dx}{360} \\ h= \frac{dz}{360} \end{align} コイル \begin{align} x= r \times \cos\theta \\ y= r \times \sin\theta \\ z= h \times Angle \end{align} 等間隔 \begin{align} x= r\theta \times cos\theta \\ y= r\theta \times sin\theta \\ z = h \times Angle \end{align} 平方根 \begin{align} x= r \sqrt{\theta} \times cos\theta \\ y= r \sqrt{\theta} \times sin\theta \\ z = h \times Angle \end{align} 指数関数 \begin{align} a= 1.1 \\ x= r \times a^{\theta} \times cos\theta \\ y= r \times a^{\theta} \times sin\theta \\ z = h \times Angle \end{align}