We estimate cube orientation using the TRIAD method, which builds an orthonormal basis from two non-collinear reference directions measured in both the reference frame and the body frame.
The goal of attitude determination is to compute the rotation that maps a vector expressed in a reference (inertial) frame \(\mathcal{N}\) into the same vector expressed in the body frame \(\mathcal{B}\). TRIAD solves this by comparing two non-collinear reference directions measured in both frames.
Given two reference vectors \(\mathbf{v}_1\) and \(\mathbf{v}_2\), TRIAD constructs an orthonormal triad:
\[ \hat{\mathbf{t}}_1=\frac{\mathbf{v}_1}{\|\mathbf{v}_1\|},\qquad \hat{\mathbf{t}}_2=\frac{\hat{\mathbf{t}}_1\times \mathbf{v}_2}{\|\hat{\mathbf{t}}_1\times \mathbf{v}_2\|},\qquad \hat{\mathbf{t}}_3=\hat{\mathbf{t}}_1\times \hat{\mathbf{t}}_2. \]
Stacking these basis vectors yields a direction cosine matrix (DCM):
\[ \mathbf{T}=\big[\hat{\mathbf{t}}_1\ \hat{\mathbf{t}}_2\ \hat{\mathbf{t}}_3\big]. \]
We form \(\mathbf{T}_N\) in the reference frame and \(\mathbf{T}_B\) in the body frame. Since each \(\mathbf{T}\) is orthonormal, \(\mathbf{T}^{-1}=\mathbf{T}^T\), and the rotation from \(\mathcal{N}\) to \(\mathcal{B}\) is:
\[ \mathbf{Q}=\mathbf{T}_B\mathbf{T}_N^T. \]
This produces a real-time rotation matrix \(\mathbf{Q}\), which drives the 3D cube rendering on the VGA display. Special thanks to Prof. Adams for introducing this method.