[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,63 +2,163 @@
|
||||
id: wiki-2026-0508-gimbals-and-orientation
|
||||
title: Gimbals and Orientation
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [PHYS-GIMBAL-001]
|
||||
aliases: [Gimbal Lock, 3D Orientation, Rotation Representation]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 1.0
|
||||
tags: ["Physics|[Physics", Robotics, game-dev, orientation, rotation-math, skybound]
|
||||
confidence_score: 0.92
|
||||
verification_status: applied
|
||||
tags: [graphics, math, rotation, quaternion, robotics]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-26
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: Python
|
||||
framework: NumPy/SciPy
|
||||
---
|
||||
|
||||
# Gimbals and Orientation (짐벌과 방향 제어)
|
||||
# Gimbals and Orientation
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "3차원 공간의 자유도를 수호하고, 회전의 축이 겹쳐 통제력을 잃는 짐벌 락의 함정을 회피하라" — 물체가 어떤 방향으로든 자유롭게 회전할 수 있도록 지지하는 장치(Gimbal)와, 오일러 각(Euler [[ANGLE|ANGLE]]s) 및 쿼터니언(Quaternions)을 활용한 수학적 자세 제어 기법.
|
||||
## 매 한 줄
|
||||
> **"매 3D rotation은 representation 의 선택이 다 — Euler 직관, quaternion 안전, matrix 합성 빠르"**. Gimbal lock 의 1958 Apollo IMU에서 발견된 singularity 매 모든 3-axis Euler systems에서 발생, 매 quaternion / rotation matrix 의 modern solution. 매 robotics, graphics, aerospace, VR 의 fundamental.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **추출된 패턴:** 세 개의 회전 축(Roll, Pitch, Yaw)을 독립적으로 제어하여 물체의 지향점을 유지하고, 각 축 간의 상호작용으로 인해 발생하는 기하학적 제약을 극복하는 방향성 제어 패턴.
|
||||
- **핵심 개념:**
|
||||
- **Euler Angles:** X, Y, Z 축을 기준으로 순차적으로 회전하는 직관적인 방식.
|
||||
- **Gimbal Lock:** 두 회전 축이 겹치면서 한 차원의 자유도를 잃어버리는 현상 (오일러 각의 고질적 문제).
|
||||
- **Quaternions (사원수):** 짐벌 락 문제를 해결하기 위해 4차원 복소수를 사용하는 수학적 도구. 부드러운 회전 보간(SLERP)에 필수적.
|
||||
- **Stabilization:** 외부 흔들림에도 불구하고 카메라나 센서가 특정 방향을 고수하도록 실시간 보정.
|
||||
- **의의:** 항공우주, 로보틱스, 드론 제어는 물론 3D 게임 엔진의 카메라 시스템과 물리 시뮬레이션의 성능을 결정짓는 근간.
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 오일러 각 기반의 단순 연산에서, 짐벌 락 방지와 연산 효율성을 위해 쿼터니언 기반의 자세 제어가 현대 시스템의 표준으로 정착됨.
|
||||
- **정책 변화:** Skybound 프로젝트의 함대 시점 카메라와 미사일 유도 알고리즘은 쿼터니언을 사용하여 격렬한 기동 중에도 끊김 없는 부드러운 시선 처리를 보장함.
|
||||
### 매 representations
|
||||
- **Euler angles** (roll, pitch, yaw): 3 floats, intuitive, but **gimbal lock at ±90° pitch**.
|
||||
- **Rotation matrix** (3×3): 9 floats, no singularity, composable via multiplication, but redundant (only 3 DOF).
|
||||
- **Quaternion** (w, x, y, z): 4 floats, no gimbal lock, smooth SLERP interpolation, double cover (q and -q same rotation).
|
||||
- **Axis-angle** (Rodrigues): 3 floats encoding axis × angle, compact.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- Physics-Engine, [[Robotics|Robotics]], Mathematics-for-AI, [[Determinism-in-Computing|Determinism-in-Computing]]
|
||||
- **Raw Source:** 10_Wiki/Topics/AI/Gimbals-and-Orientation.md
|
||||
### 매 gimbal lock 매커니즘
|
||||
- 매 3 nested rotations (e.g. ZYX) 매 second rotation이 ±90° 면 first/third axis가 align — DOF loss from 3 to 2.
|
||||
- 매 Apollo 11 LM 의 famous near-miss: Aldrin manually steered to avoid IMU lock.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 응용
|
||||
1. Robotics IK / joint orientation.
|
||||
2. Game character / camera control.
|
||||
3. VR/AR head tracking (IMU sensor fusion).
|
||||
4. Drone / aerospace attitude control.
|
||||
5. Skeletal animation blending.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### Quaternion from Euler (avoid gimbal lock)
|
||||
```python
|
||||
import numpy as np
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
def euler_to_quat(roll, pitch, yaw):
|
||||
cr, sr = np.cos(roll/2), np.sin(roll/2)
|
||||
cp, sp = np.cos(pitch/2), np.sin(pitch/2)
|
||||
cy, sy = np.cos(yaw/2), np.sin(yaw/2)
|
||||
w = cr*cp*cy + sr*sp*sy
|
||||
x = sr*cp*cy - cr*sp*sy
|
||||
y = cr*sp*cy + sr*cp*sy
|
||||
z = cr*cp*sy - sr*sp*cy
|
||||
return np.array([w, x, y, z])
|
||||
```
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
### SLERP (smooth quaternion interpolation)
|
||||
```python
|
||||
def slerp(q0, q1, t):
|
||||
dot = np.dot(q0, q1)
|
||||
if dot < 0.0:
|
||||
q1, dot = -q1, -dot
|
||||
if dot > 0.9995:
|
||||
return (q0 + t*(q1-q0)) / np.linalg.norm(q0 + t*(q1-q0))
|
||||
theta_0 = np.arccos(dot)
|
||||
theta = theta_0 * t
|
||||
s0 = np.cos(theta) - dot * np.sin(theta) / np.sin(theta_0)
|
||||
s1 = np.sin(theta) / np.sin(theta_0)
|
||||
return s0*q0 + s1*q1
|
||||
```
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
### Rotation matrix composition
|
||||
```python
|
||||
from scipy.spatial.transform import Rotation as R
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
R1 = R.from_euler('xyz', [30, 45, 60], degrees=True)
|
||||
R2 = R.from_quat([0, 0, 0.707, 0.707]) # x,y,z,w
|
||||
R_combined = R2 * R1
|
||||
print(R_combined.as_matrix())
|
||||
```
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
### Axis-angle (Rodrigues' formula)
|
||||
```python
|
||||
def rodrigues(axis, theta):
|
||||
axis = axis / np.linalg.norm(axis)
|
||||
K = np.array([[ 0, -axis[2], axis[1]],
|
||||
[ axis[2], 0, -axis[0]],
|
||||
[-axis[1], axis[0], 0]])
|
||||
return np.eye(3) + np.sin(theta)*K + (1-np.cos(theta))*K@K
|
||||
```
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
### IMU sensor fusion (complementary filter)
|
||||
```python
|
||||
def imu_update(q, gyro, accel, dt, alpha=0.98):
|
||||
# gyro integration
|
||||
omega = np.array([0, *gyro])
|
||||
q_dot = 0.5 * quat_mul(q, omega)
|
||||
q_gyro = q + q_dot * dt
|
||||
q_gyro /= np.linalg.norm(q_gyro)
|
||||
# accel correction
|
||||
q_accel = accel_to_quat(accel)
|
||||
return slerp(q_accel, q_gyro, alpha)
|
||||
```
|
||||
|
||||
### Detect gimbal lock
|
||||
```python
|
||||
def detect_lock(euler_pitch, threshold=89.5):
|
||||
return abs(euler_pitch) > threshold # near ±90°
|
||||
```
|
||||
|
||||
### Quaternion → Rotation matrix
|
||||
```python
|
||||
def quat_to_matrix(q):
|
||||
w, x, y, z = q
|
||||
return np.array([
|
||||
[1-2*(y*y+z*z), 2*(x*y-z*w), 2*(x*z+y*w)],
|
||||
[2*(x*y+z*w), 1-2*(x*x+z*z), 2*(y*z-x*w)],
|
||||
[2*(x*z-y*w), 2*(y*z+x*w), 1-2*(x*x+y*y)]
|
||||
])
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| User-facing UI sliders | Euler (intuitive) |
|
||||
| 3D engine internal | Quaternion |
|
||||
| Skeletal animation blending | Quaternion + SLERP |
|
||||
| Physics / forces composition | Rotation matrix |
|
||||
| IMU streaming | Quaternion + complementary/Kalman |
|
||||
| Compact storage | Axis-angle or compressed quat |
|
||||
|
||||
**기본값**: Quaternion internally, Euler at user boundaries.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Linear-Algebra]] · [[3D-Geometry]]
|
||||
- 변형: [[Quaternion]] · [[Euler-Angles]] · [[Rotation-Matrix]]
|
||||
- 응용: [[Kalman-Filter-and-State-Tracking]] · [[VR-Head-Tracking]] · [[Robotics-IK]]
|
||||
- Adjacent: [[Eigenvalues-and-Eigenvectors]] · [[Lie-Groups]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: orientation representation 의 conversion code 생성, gimbal lock debugging hints, sensor fusion math derivation.
|
||||
**언제 X**: real-time IMU loop (latency critical — use compiled code), safety-critical aerospace code (require formal verification).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Storing rotation as Euler**: gimbal lock + interpolation discontinuity. Store as quaternion.
|
||||
- **Linear interpolation of quaternions**: NLERP works로컬 but SLERP for accuracy. NLERP for speed in animation.
|
||||
- **Forgetting double cover**: q and -q same rotation; SLERP needs sign check.
|
||||
- **Gradient-based optimization on Euler**: discontinuous near singularities — use quaternion or matrix tangent space.
|
||||
- **Mixing conventions**: (w,x,y,z) vs (x,y,z,w), intrinsic vs extrinsic Euler — document explicitly.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Shoemake 1985 quaternion paper, NASA Apollo IMU records, scipy.spatial.transform docs).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — full content with quaternion/Euler/matrix patterns + IMU fusion |
|
||||
|
||||
Reference in New Issue
Block a user