3.5.3 · D4 · HinglishGuidance, Navigation & Control (GNC)

ExercisesDirection cosine matrix (DCM) — construction from Euler angles

2,327 words11 min read↑ Read in English

3.5.3 · D4 · Physics › Guidance, Navigation & Control (GNC) › Direction cosine matrix (DCM) — construction from Euler angl

Throughout, hum parent se shorthand use karte hain: , , angles degrees mein hain jab tak radian likha na ho. Ek DCM inertial-frame coordinates ko body-frame coordinates mein convert karta hai. Teen elementary rotations hain:

R_1(\phi)=\begin{bmatrix}1&0&0\\0&c\phi&s\phi\\0&-s\phi&c\phi\end{bmatrix},\quad R_2(\theta)=\begin{bmatrix}c\theta&0&-s\theta\\0&1&0\\ s\theta&0&c\theta\end{bmatrix}.$$ --- ## Level 1 — Recognition ### L1.1 Ek-ek sentence mein batao ki DCM ki entry $C_{23}$ **physically** kya hai aur $C$ ki har **row** ki unit-length property kya honi chahiye. > [!recall]- Solution > **$C_{23}$ kya hai:** $(2,3)$ entry $\hat b_2\cdot\hat n_3=\cos(\theta_{23})$ hai — **body axis 2** aur **inertial axis 3** ke beech ke angle ka cosine. Iska matlab hai "inertial axis 3 ka kitna hissa body axis 2 ki taraf point karta hai." > **Row property:** har row ek unit vector hai, isliye har row $i$ ke liye $\sum_j C_{ij}^2=1$. (Rows body axes hain jo inertial coordinates mein likhe gaye hain; body axes ki length 1 hoti hai.) ### L1.2 Kaun sa ek elementary matrix — $R_1$, $R_2$, ya $R_3$ — ka minus-sign **top-right** corner mein hai, aur yeh kis physical rotation axis se belong karta hai? > [!recall]- Solution > $R_2(\theta)$ ka top-right mein $-s\theta$ hai. Yeh **2-axis (pitch)** ke baare mein rotation hai. Axis 2 ka rotation plane 3–1 plane hai, aur cyclic order $3\to1$ (na ki $1\to2$) ki wajah se minus sign ki jagah badal jaati hai. ### L1.3 $\psi=0,\ \theta=0,\ \phi=0$ diya hai, $C_{BN}$ likho. > [!recall]- Solution > Har $\cos=1$, har $\sin=0$, isliye teeno elementary matrices identity ban jaati hain aur unka product hai: > $$C_{BN}=I=\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}.$$ > **Kyun $I$ hona chahiye:** zero rotation ka matlab hai body aur inertial frames ek hi jagah hain, isliye coordinates unchanged rehte hain. > [!mistake] L1 trap — "cosine of the angle" vs "the angle" > **Galat feeling:** students $C_{23}$ dekhte hain aur kehte hain "yeh body-2 aur inertial-3 ke beech ka angle hai." > **Kyun sahi lagta hai:** hum casually entries ko "direction cosines" kehte hain, aur word "angle" wahan hai hi. > **Fix:** entry us angle ka **cosine** hai, ek pure number $[-1,1]$ mein, kabhi angle khud nahi. Agar aapko kabhi koi DCM entry $30$ ya $\pi/2$ ke equal milti hai, toh aapne category error kiya hai — entries magnitude mein kabhi $1$ se zyada nahi ho sakti. --- ## Level 2 — Application ### L2.1 **Pure roll** $\phi=90^\circ$ ke liye $C_{BN}$ compute karo (with $\psi=\theta=0$). Phir inertial vector $\mathbf v_N=[0,1,0]^T$ ke body coordinates nikalo. > [!recall]- Solution > $\psi=\theta=0$ ke saath, $C_{BN}=R_1(90^\circ)$. Kyunki $\cos90^\circ=0,\ \sin90^\circ=1$: > $$C_{BN}=\begin{bmatrix}1&0&0\\0&0&1\\0&-1&0\end{bmatrix}.$$ > Phir > $$\mathbf v_B=C_{BN}\begin{bmatrix}0\\1\\0\end{bmatrix}=\begin{bmatrix}0\\0\\-1\end{bmatrix}.$$ > **Yeh kaisa dikhta hai:** body ko 1-axis ke baare mein $+90^\circ$ roll karne se purana $\hat n_2$ (inertial "right") body ke $-3$ direction par tip ho jaata hai. Neeche figure dekho. ![[deepdives/dd-physics-3.5.03-d4-s01.png]] ### L2.2 $\psi=30^\circ,\ \theta=0^\circ,\ \phi=0^\circ$ ke liye full 3-2-1 DCM compute karo aur confirm karo ki yeh $R_3(30^\circ)$ ke equal hai. > [!recall]- Solution > $\theta=\phi=0$ ke saath, $R_1=R_2=I$, isliye $C_{BN}=R_3(30^\circ)$. $c30^\circ=\tfrac{\sqrt3}{2}\approx0.8660$, $s30^\circ=0.5$ use karke: > $$C_{BN}=\begin{bmatrix}0.8660&0.5&0\\-0.5&0.8660&0\\0&0&1\end{bmatrix}.$$ > **Kyun:** sirf yaw nonzero hai, isliye 3-2-1 chain sirf ek 3-axis rotation mein collapse ho jaati hai. ### L2.3 L2.2 ke DCM ke liye, $\mathbf v_N=[1,0,0]^T$ ke body coordinates compute karo aur result ke sign ki interpretation karo. > [!recall]- Solution > $$\mathbf v_B=\begin{bmatrix}0.8660&0.5&0\\-0.5&0.8660&0\\0&0&1\end{bmatrix}\begin{bmatrix}1\\0\\0\end{bmatrix}=\begin{bmatrix}0.8660\\-0.5\\0\end{bmatrix}.$$ > **Interpretation:** body $+30^\circ$ yaw hua, isliye fixed inertial North ab **body ke peeche aur body ke right** mein dikhta hai — positive $b_1$ component ($0.866$) aur **negative** $b_2$ component ($-0.5$). Minus sign yeh batata hai ki body vector ki taraf muri, usse door nahi. > [!mistake] L2 trap — axes ki jagah vector rotate karna > **Galat feeling:** "Yaw $+30^\circ$ hai, toh main vector ke angle mein $30^\circ$ add karta hoon aur doosre slot mein $+0.5$ milta hai." > **Kyun sahi lagta hai:** hum physically object ko ghoomte hue imagine karte hain, aur left ghoomna $+$ jaisa lagta hai. > **Fix:** DCM ek *fixed* vector ko *rotated axes* mein re-express karta hai. Axes ko $+\theta$ se rotate karna vector ko $-\theta$ se rotate karne ke barabar hai — exactly isliye $R_3$ ke **lower**-left mein $-s\theta$ hai, jo $-0.5$ deta hai. Jab doubt ho, matrix par trust karo, phir sign ko sanity-check karo "kya body vector ki taraf muri ya door?" --- ## Level 3 — Analysis ### L3.1 Directly compute karke prove karo ki L2.1 ka DCM $C^{-1}=C^{T}$ satisfy karta hai, phir ek sentence mein explain karo ki bina compute kiye yeh kyun hona hi tha. > [!recall]- Solution > $C=\begin{bmatrix}1&0&0\\0&0&1\\0&-1&0\end{bmatrix}$, toh $C^{T}=\begin{bmatrix}1&0&0\\0&0&-1\\0&1&0\end{bmatrix}$. > Phir > $$CC^{T}=\begin{bmatrix}1&0&0\\0&0&1\\0&-1&0\end{bmatrix}\begin{bmatrix}1&0&0\\0&0&-1\\0&1&0\end{bmatrix}=\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}=I.$$ > Kyunki $CC^T=I$ hai, transpose **hi** inverse hai. > **Bina compute kiye kyun:** ek rotation lengths aur angles preserve karta hai, isliye uski rows orthonormal unit vectors hain $\Rightarrow C^TC=I \Rightarrow C^{-1}=C^T$. Har genuine DCM ko yeh free mein milta hai. ### L3.2 L2.2 matrix ke liye $\det C$ compute karo aur batao ki value $-1$ hoti toh physically kya matlab hota. > [!recall]- Solution > Teesri row (jo $[0,0,1]$ hai) ke saath expand karke: > $$\det C = 1\cdot\det\begin{bmatrix}0.8660&0.5\\-0.5&0.8660\end{bmatrix}=0.8660^2-(0.5)(-0.5)=0.75+0.25=1.$$ > **$-1$ ka matlab kya hota:** rotation mein ek **reflection** (left-handed frame flip) mix ho gayi. Ek proper rotation kabhi reflect nahi karta, isliye DCM ka $\det=+1$ hona chahiye. $\det=-1$ ka result coding sign error ya improper (mirror) transform ka signal hai. ### L3.3 Full 3-2-1 matrix ka bottom-left region messy hai, lekin $C_{13}=-s\theta$ clean hai. Iska use karke, agar ek measured DCM mein $C_{13}=-0.5$ hai, toh pitch $\theta$ find karo. Phir explain karo ki yahan $\arcsin$ kyun use karte hain lekin yaw aur roll ke liye $\operatorname{atan2}$ kyun. > [!recall]- Solution > $C_{13}=-s\theta=-0.5\Rightarrow s\theta=0.5\Rightarrow \theta=\arcsin(0.5)=30^\circ$. > **Pitch ke liye $\arcsin$ kyun:** pitch *defined* hai $[-90^\circ,+90^\circ]$ par, exactly woh range jo $\arcsin$ return karta hai, isliye ek single entry bina kisi quadrant ambiguity ke usse pin kar deti hai. > **Yaw/roll ke liye $\operatorname{atan2}$ kyun:** woh angles full $(-180^\circ,180^\circ]$ range mein hote hain. Ek akela $\arcsin$ ya $\arccos$ quadrant II aur I mein farq nahi kar sakta (unka same sine hota hai). $\operatorname{atan2}(y,x)$ angle ko sahi quadrant mein place karne ke liye **$y$ aur $x$ dono ke signs** use karta hai — same fix jo 2D vector ke $\arctan$ ke liye use hoti hai. > [!mistake] L3 trap — yeh bhool jaana ki det silently ek bad matrix chhupa sakta hai > **Galat feeling:** "Mere matrix ki rows unit-length hain, isliye yeh valid rotation honi chahiye." > **Kyun sahi lagta hai:** orthonormal rows zaroor zaroori hain. > **Fix:** orthonormal rows $CC^T=I$ guarantee karte hain lekin $\det=+1$ NAHI — ek reflection ke bhi orthonormal rows hote hain lekin $\det=-1$ hota hai. Proper rotation certify karne ke liye aapko **dono** check karne chahiye: $CC^T=I$ *aur* $\det C=+1$. Yeh $O(3)$ aur [[Rotation group SO(3) and orthogonal matrices|SO(3)]] ke beech ki boundary hai. --- ## Level 4 — Synthesis ### L4.1 $\psi=90^\circ,\ \theta=0^\circ,\ \phi=90^\circ$ ke liye full 3-2-1 DCM do tareekon se banao — (i) $R_1(90^\circ)R_2(0^\circ)R_3(90^\circ)$ multiply karke, aur (ii) parent se closed-form matrix mein plug in karke — aur confirm karo ki dono agree karte hain. > [!recall]- Solution > **(i) Multiplication se.** $R_2(0^\circ)=I$, isliye $C=R_1(90^\circ)R_3(90^\circ)$. > $$R_3(90^\circ)=\begin{bmatrix}0&1&0\\-1&0&0\\0&0&1\end{bmatrix},\quad > R_1(90^\circ)=\begin{bmatrix}1&0&0\\0&0&1\\0&-1&0\end{bmatrix}.$$ > $$C=R_1R_3=\begin{bmatrix}1&0&0\\0&0&1\\0&-1&0\end{bmatrix}\begin{bmatrix}0&1&0\\-1&0&0\\0&0&1\end{bmatrix}=\begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix}.$$ > **(ii) Closed form se.** $\theta=0$ ke saath: $c\theta=1,\ s\theta=0$, $c\psi=0,\ s\psi=1$, $c\phi=0,\ s\phi=1$. Parent ki entries se: > - Row 1: $[c\theta c\psi,\ c\theta s\psi,\ -s\theta]=[0,1,0]$. > - Row 2: $[s\phi s\theta c\psi - c\phi s\psi,\ s\phi s\theta s\psi + c\phi c\psi,\ s\phi c\theta]=[0-0,\ 0+0,\ 1]=[0,0,1]$. > - Row 3: $[c\phi s\theta c\psi + s\phi s\psi,\ c\phi s\theta s\psi - s\phi c\psi,\ c\phi c\theta]=[0+1,\ 0-0,\ 0]=[1,0,0]$. > $$C=\begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix}.\quad\text{✔ Dono agree karte hain.}$$ ### L4.2 Parent se small-angle form $C\approx I-[\boldsymbol\alpha\times]$ with $\boldsymbol\alpha=(\phi,\theta,\psi)$ lo, aur $\phi=\theta=\psi=0.01$ rad ke liye evaluate karo. Iske $(1,2)$ entry ko exact 3-2-1 value se compare karo. > [!recall]- Solution > $\boldsymbol\alpha=(\alpha_1,\alpha_2,\alpha_3)=(\phi,\theta,\psi)$ se bana skew matrix hai: > $$[\boldsymbol\alpha\times]=\begin{bmatrix}0&-\alpha_3&\alpha_2\\ \alpha_3&0&-\alpha_1\\ -\alpha_2&\alpha_1&0\end{bmatrix},\quad > C\approx\begin{bmatrix}1&\psi&-\theta\\-\psi&1&\phi\\ \theta&-\phi&1\end{bmatrix}.$$ > Teeno $=0.01$ ke saath: **approximate** $(1,2)$ entry $\psi=0.01$ hai. > **Exact** $(1,2)$ entry $c\theta\,s\psi=\cos(0.01)\sin(0.01)=0.99995\times0.0099998\approx0.0099993$ hai. > Difference $\approx7\times10^{-7}$, jo confirm karta hai ki linear model milliradian errors ke liye excellent hai — yeh [[Kalman filter — linearized attitude error state|linearized error state]] ki foundation hai. > [!mistake] L4 trap — yeh assume karna ki rotation order matter karna band ho jaata hai > **Galat feeling:** "L4.2 ne dikhaya ki order first order tak matter nahi karta, isliye main real angles ke liye bhi $R_1,R_2,R_3$ kisi bhi order mein multiply kar sakta hoon." > **Kyun sahi lagta hai:** small-angle result genuinely commute karta hai. > **Fix:** commutativity sirf first order tak (tiny angles) hold karta hai. Finite angles ke liye $R_1R_2R_3\ne R_3R_2R_1$ generally — matrix multiplication non-commutative hai. L4.1 mein $90^\circ$ angles ke saath order reverse karne par ek *different* matrix milega; try karo. Order sirf tab negotiable hai jab angles milliradian-small hon. --- ## Level 5 — Mastery ### L5.1 Ek star tracker DCM report karta hai: $$C=\begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix}.$$ $\theta=-\arcsin(C_{13})$, $\psi=\operatorname{atan2}(C_{12},C_{11})$, $\phi=\operatorname{atan2}(C_{23},C_{33})$ use karke 3-2-1 Euler angles $(\psi,\theta,\phi)$ recover karo. L4.1 ke saath cross-check karo. > [!recall]- Solution > Zaroori entries padhein: $C_{13}=0,\ C_{12}=1,\ C_{11}=0,\ C_{23}=1,\ C_{33}=0$. > - **Pitch:** $\theta=-\arcsin(0)=0^\circ$. > - **Yaw:** $\psi=\operatorname{atan2}(C_{12},C_{11})=\operatorname{atan2}(1,0)=+90^\circ$. > - **Roll:** $\phi=\operatorname{atan2}(C_{23},C_{33})=\operatorname{atan2}(1,0)=+90^\circ$. > Toh $(\psi,\theta,\phi)=(90^\circ,0^\circ,90^\circ)$ — exactly woh input jo L4.1 mein yeh matrix produce kiya tha. ✔ > **$\operatorname{atan2}(1,0)=90^\circ$ kyun:** argument positive $y$-axis par ek point correspond karta hai ($x=0,y=1$), jiska angle clean $+90^\circ$ hai; ek bare $\arctan(1/0)$ blow up ho jaata, exactly isliye hum $\operatorname{atan2}$ use karte hain. ### L5.2 Pitch $\theta=90^\circ$ (gimbal lock) set karo $\psi=40^\circ,\ \phi=0^\circ$ ke saath. $C_{BN}$ compute karo, phir dikhao ki $(\psi,\phi)=(40^\circ,0^\circ)$ aur $(\psi',\phi')=(0^\circ,-40^\circ)$ **same** matrix dete hain — lost uniqueness demonstrate karte hue. > [!recall]- Solution > $\theta=90^\circ$ par: $c\theta=0,\ s\theta=1$. Parent ke closed form mein plug in karo. > **Case A** $(\psi=40^\circ,\phi=0^\circ)$, $c\phi=1,s\phi=0$ ke saath: > - Row 1: $[0,\,0,\,-1]$. > - Row 2: $[s\phi\cdot1\cdot c\psi - c\phi s\psi,\ s\phi\cdot1\cdot s\psi + c\phi c\psi,\ 0]=[-s\psi,\ c\psi,\ 0]=[-s40^\circ,\ c40^\circ,\ 0]$. > - Row 3: $[c\phi\cdot1\cdot c\psi + s\phi s\psi,\ c\phi\cdot1\cdot s\psi - s\phi c\psi,\ 0]=[c\psi,\ s\psi,\ 0]=[c40^\circ,\ s40^\circ,\ 0]$. > $$C_A=\begin{bmatrix}0&0&-1\\-s40^\circ&c40^\circ&0\\ c40^\circ&s40^\circ&0\end{bmatrix}.$$ > **Case B** $(\psi'=0^\circ,\phi'=-40^\circ)$, $c\psi'=1,s\psi'=0$, $c\phi'=c40^\circ,s\phi'=-s40^\circ$ ke saath: > - Row 1: $[0,0,-1]$. > - Row 2: $[s\phi'\cdot1\cdot1 - 0,\ 0 + c\phi'\cdot1,\ 0]=[s\phi',\ c\phi',\ 0]=[-s40^\circ,\ c40^\circ,\ 0]$. > - Row 3: $[c\phi'\cdot1\cdot1 + 0,\ 0 - s\phi'\cdot1,\ 0]=[c\phi',\ -s\phi',\ 0]=[c40^\circ,\ s40^\circ,\ 0]$. > $$C_B=\begin{bmatrix}0&0&-1\\-s40^\circ&c40^\circ&0\\ c40^\circ&s40^\circ&0\end{bmatrix}=C_A.\ \text{✔}$$ > **Yeh kya dikhata hai:** $\theta=90^\circ$ par sirf **sum** (yahan $\psi-\phi$ style combination) matter karta hai; $\psi$ aur $\phi$ freely ek axis ke saath trade off karte hain. DCM bilkul well-defined hai, lekin *angle decomposition* nahi — yeh [[Quaternions — avoiding gimbal lock|gimbal lock]] hai, aur isliye flight software attitude ko quaternion mein store karta hai. ![[deepdives/dd-physics-3.5.03-d4-s02.png]] ### L5.3 $C=R_1(\phi)R_2(\theta)R_3(\psi)$ use karke prove karo ki composed matrix orthogonal hai ($CC^T=I$) **bina expand kiye**, given ki har $R_i$ orthogonal hai. > [!recall]- Solution > Har elementary matrix orthogonal hai: $R_i R_i^T=I$, yaani $R_i^T=R_i^{-1}$. Phir > $$CC^T=(R_1R_2R_3)(R_1R_2R_3)^T=R_1R_2R_3\,R_3^TR_2^TR_1^T.$$ > Andar se peel karo: $R_3R_3^T=I$, bacha $R_1R_2R_2^TR_1^T$; phir $R_2R_2^T=I$, bacha $R_1R_1^T=I$. > $$CC^T=I.$$ > **Yeh powerful kyun hai:** rotations ka product automatically ek rotation hota hai — group [[Rotation group SO(3) and orthogonal matrices|SO(3)]] multiplication ke under *closed* hai. Aapko kabhi composed DCM ki orthonormality re-verify nahi karni padti; yeh inherited hoti hai. > [!mistake] L5 trap — "gimbal lock matlab DCM toot gaya" > **Galat feeling:** "$\theta=90^\circ$ par mera angle solver garbage return karta hai, isliye DCM singular/unusable hai." > **Kyun sahi lagta hai:** recovery formulas $\operatorname{atan2}(C_{12},C_{11})$ hit $\operatorname{atan2}(0,0)$ karte hain, jo undefined hai. > **Fix:** **matrix** $C$ ek perfectly valid rotation hai jiska $\det=+1$ aur $CC^T=I$ hai — kuch nahi toota. Sirf *Euler-angle parameterization* non-unique ho jaati hai. Attitude ko ek non-singular representation (quaternion ya DCM directly) mein propagate karo aur sirf human display ke liye Euler angles mein convert karo, $\theta=\pm90^\circ$ case guard karte hue. --- > [!recall]- Feynman recap: in exercises ne kya train kiya > L1–L2 ne turn-tables ko *padhna aur plug in* karna sikhaya. L3 ne matrix *audit* karaya ($CC^T=I$ aur $\det=+1$ dono saath mein). L4 ne full attitudes do tareekon se banaye aur dikhaya ki order sirf tiny turns ke liye matter karna band karta hai. L5 ne aapko ek matrix diya aur pucha "kaunse turns ne yeh banaya?" — aur reveal kiya ki straight-up pitch ke paas answer unique rehna band ho jaata hai. Woh last lesson *hi* wajah hai ki spacecraft [[Quaternions — avoiding gimbal lock|quaternions]] carry karte hain. > [!mnemonic] Grading ladder > **"Read, Run, Reason, Rebuild, Rule."** L1 Read the entries · L2 Run the multiplication · L3 Reason about det/inverse · L4 Rebuild the full DCM · L5 Rule over the inverse problem and gimbal lock. ## Connections - [[Direction cosine matrix (DCM) — construction from Euler angles]] - [[Quaternions — avoiding gimbal lock]] - [[Euler angles — kinematic differential equations]] - [[Rotation group SO(3) and orthogonal matrices]] - [[Attitude determination — TRIAD & QUEST]] - [[Kalman filter — linearized attitude error state]] - [[Angular velocity and skew-symmetric matrices]]