= x , y , z 말고 다른 축을 기준으로 돌리고 싶을 때 복잡해진다.

🔎 The order of rotation
= 회전할 때 order가 중요

☁️ Keyframe Animation in 2D
🔎 Keyframe
key frame을 직접 그리고, 사이는 interpolate.

- sampling

🔎 Animation smoothing
고차방정식을 이용해서 부드럽게 보간시킨다. 일반적으로 3차까지 사용한다.

☁️ A Problem of Euler Angles
- Euler angle은 intuitive(직관적)하며, 쉽게 사용할 수 있다.
- 특정축 (x,y,z)을 기준으로 회전시키는 것.
🔎 Problem 1
- two different Euler rotation을 할 때 interpolation이 제대로 되지 않는다.
Example - (60,20,40)으로 rotation 되어있는 object를 다시 Y축 회전 시킨다.
이때, 이전의 rotation으로 rotation axis가 이미 왜곡(distort)되어있다.
왜곡된 상태에서 Y축 회전을 시키면 x,y,z가 모두 변화하기 때문에 회전이 깔끔하지 않다.
🔎 Problem 2
- Gimbal lock
회전했을 때 축이 일치된 경우 = 한축에 대한 회전상태를 구현할 수 없게 된다.
y축 이동 = z축 이동이 되어버린다 -> 옛날에는 이 문제를 막기 위해서 90도 회전을 막기도 했다.

☁️ Quaternion
- Euler angle의 한계를 극복할 수 있다
- 장점 : more compact, efficient, numerically stable
- 단점 : more complex and difficult to understand
- x,y,z 축으로만 회전을 정의할 수 있었던 Euler와 달리 임의의 축을 기준으로 회전시킨다.
- sin cos를 이용하기 때문에 각도 값이 2π씩 차이 나는 경우에도 동일한 값이 나온다.
- 따라서, 쿼터니온을 사용하여 각도를 인코딩하고 다시 복원할 때, 항상 [0, 2π] 범위로 제한시킨다.
🔎 extended complex number
q=(qv,qw)
- qv : vector part / 허수부
= qxi+qyj+qzk
- qw : scalar part / 실수부

🔎 Hamilton Product
= pq

🔎 Conjugation of the quaternion
= 허수부에만 - 를 붙인다
- q∗=(−qv,qw) = −qxi−qyi−qki+qw
- (q∗)∗=q
- (pq)∗=q∗p∗
- 허수부와 실수부를 나눌 때도 사용된다.

🔎 Unit Quaternion
- unit quaternion


☁️ Rotation through complex numbers
🔎 2D Rotation
- p=(x,y)=x+yi
- q=cosθ+sinθi = unit length complex number
- pq = rotated coordinate


🔎 3D Rotation

- p = rotate 해야할 vector

- q = unit quaternion / u = unit vector

- rotated vector = qpq∗의 허수부
🔎 Multiple Quaternions
- p′ = qpq∗
- quaternion r로 p'을 또 회전할 때

- 두개 이상의 회전을 연속으로 할 때에도 간편하게 합칠 수 있구나!
🔎 Quaternion and Negation
u를 θ로 회전한 것 = -u를 -θ로 회전한 것
☁️ Quaternion and Matrix
= Matrix 가 주어졌을 때 Quaternion을 찾을 수도 있다.
- Quaternion q의 rotation matrix

- 대각 원소들의 합 구하기

- matrix의 m21,m12를 뺀다.

- 같은 방식으로 qx,qy도 구할 수 있다.