Unity Matrix (Column-Major Order)

Vector3 Position = new Vector3(0.0f, 0.0f, 0.0f);
Matrix4x4 Model = Matrix4x4.Translate(new Vector3(1.0f, 2.0f, 3.0f));
// Debug.Log(Model);
// (1.0, 0.0, 0.0, 1.0)
// (0.0, 1.0, 0.0, 2.0)
// (0.0, 0.0, 1.0, 3.0)
// (0.0, 0.0, 0.0, 1.0)

Vector3 Transformed Model.MultiplyPoint3x4(Position)// P’ (1, 2, 3) (Unity Matrix uses Column-Major Order) 

Composing Transformation

// white cube at origin
cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.GetComponent().material.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
cube.transform.parent = this.gameObject.transform;

// translation, rotation, scale
Vector3 translation = new Vector3(1.5, 0, 0);
Quaternion rotation = Quaternion.Euler(0, 0, 45);
Vector3 scale = new Vector3(0.2, 0.2, 0.2);

// white cube with S->R->T
cube.transform.localScale = scale;
cube.transform.rotation = rotation;
cube.transform.position = translation;
Matrix4x4 matrix = cube.transform.localToWorldMatrix;
Debug.Log(“cube.transform.localToWorldMatrix=\n” + matrix);

// Create a composing transformation Scale -> Rotation -> Translation
Matrix4x4 m1 = Matrix4x4.TRS(translation, rotation, scale);
// Create a composing transformation Scale -> Rotation -> Translation
Matrix4x4 m2 = Matrix4x4.Translate(translation) *
Matrix4x4.Rotate(rotation) * Matrix4x4.Scale(scale); // Scale -> Rotation -> Translation
if (m1 == m2) Debug.Log(“m1 == m2”);
if (m1 == matrix) Debug.Log(“m1 == matrix”);

// Create a composing transformation Translation -> Rotation ->Scale
Matrix4x4 m3 = Matrix4x4.Scale(scale) *
Matrix4x4.Rotate(rotation) * Matrix4x4.Translate(translation); 
if (m1 != m3) Debug.Log(“m1 != m3”);

Affine Space

Affine Space (아핀공간) – 벡터공간에 점을 추가한 공간
http://mathworld.wolfram.com/AffineSpace.html

벡터와 벡터 간의 덧셈/뺄셈 -> 벡터 생성
스칼라와 벡터의 곱셈/나눗셈 -> 벡터 생성
벡터와 점의 덧셈/뺄셈 -> 점 생성
점과 점 간의 뺄셈 -> 벡터 생성
점과 점 간의 덧셈은 허용되지 않는다.
아핀공간에서 점의 덧셈은 각 점들 앞의 계수의 합이 1일 때에만 허용되고 이처럼 계수의 합이 1이 되는 경우를 Affine Sum(아핀합)이라 한다.

Homogeneous Coordinate (동차좌표) – 어떤 목적을 위해 한 차원의 좌표(n)을 추가한 좌표 (n+1)로 표현을 하는 것
http://mathworld.wolfram.com/HomogeneousCoordinates.html

4차원 동차 좌표 (x,y,z,w) => 3차원 좌표 (x/w , y/w , z/w)
만약 w == 1, (x,y,z,1)은 position이다.
만약 w == 0, (x,y,z,0)은 vector이다.