[GGP] 3. Spaces and Transforms

Cherish·2023년 5월 25일

Game Graphic Programming

목록 보기
2/14
post-thumbnail

☁️ DirectX



☁️ Scaling

🔎 2D Scaling

  • Sx, Sy = scaling factors
    x축으로 Sx배
    y축으로 Sy배

☁️ Rotation

  • Couterclockwse (CCW)
    양의 각도
  • Clockwise (CW)
    음의 각도


☁️ Translation

  • scaling , rotation과 달리 translation은 벡터의 덧셈이다
  • homogeneous coordinate라면 곱셈으로도 나타낼 수 있다

🔎 homogeneous coordinate ( 동차좌표계 )

  • (x, y)를 (x, y, 1)로 표현하는 것
  • 임의의 0이 아닌 상수 w에 대해 (x, y)를 (wx, wy, w)로 표현하는 것
    homogeneous 좌표계에서 스케일(scale)은 무시되며 (x, y)에 대한 homogeneous 좌표 표현은 무한히 많이 존재한다



☁️ Composition of 2D Transform

🔎 Multiple Transform

  • 위의 예시는 OpenGL 버전 (column vector)
  • Noncommutative (RT != TR)
  • 순서에 주의 해야한다!
  • DirectX의 경우 (0,4,1)RT -> row vector

🔎 Rotation about an arbitrary point

= 임의의 점을 기준으로 회전하고 싶을 때

  1. 회전 기준이 되는 점을 원점으로 옮긴다
  2. 회전
  3. 원점에서 원래 위치로 옮겨준다.



☁️ Affine transform

  • Linear transform (Scaling, Rotation..) = 단순 이동 계산
  • Translation = 특수 처리

여러 개의 아핀 변환도 하나의 matrix로 합쳐질 수 있다!

🔎 [Lt][L|t]

= 2 x 3 elements

  • LL : combined linear transform
  • tt : combined translation
  • 빨간 부분이 L, 파란부분이 t
  • Lp+tLp + t (p = 옮길 point)
  • LL이 먼저 적용된다.
  • linear transform이 완료된 object를 t로 옮겨준다.



☁️ Rigid Motion

  • rotation과 translation만 존재 / scaling은 포함 X
  • affine matrix를 적용하면 pose(position + orientation)는 변화지만 물체의 모양은 바뀌지 않는다.

    [Rt][R|t]

    • RR : combined rotation
    • tt : combined translation



☁️ 3D Scaling


☁️ 3D Rotation


☁️ 3D Translation


☁️ 3D Affine Transforms


☁️ Inverse

  • R-1 = RT







0개의 댓글