{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/cg-3d-math-fundamentals/",
  "atlas": "https://www.pystone.net/?node=cg-3d-math-fundamentals#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/cg-3d-math-fundamentals.md",
  "context": "https://www.pystone.net/notes/cg-3d-math-fundamentals.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:cg-3d-math-fundamentals",
  "slug": "cg-3d-math-fundamentals",
  "title": "【CG】3D数学基础",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "【CG】3D数学基础",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "a3d74a83bf80f8fde854845b731c697ea2952cc17d132fb4ebc670a858642c10",
  "assets": [
    {
      "reference": "assets/1605537132976.png",
      "url": "/media/2f94c8a9d6a73c851332.png",
      "mediaType": "image/png",
      "contentHash": "2f94c8a9d6a73c8513321f934586fb54302e485d75f1ce70d8c9988b75110ad6",
      "byteLength": 54315,
      "width": 758,
      "height": 289
    },
    {
      "reference": "assets/1605538126941.png",
      "url": "/media/7c252ae9c7dabae2fd9a.png",
      "mediaType": "image/png",
      "contentHash": "7c252ae9c7dabae2fd9a20e52eb0029bd6de8c19cbec19458a37336e2d8b509f",
      "byteLength": 1577,
      "width": 119,
      "height": 48
    },
    {
      "reference": "assets/1605538133244.png",
      "url": "/media/4a86f22a7052bb452249.png",
      "mediaType": "image/png",
      "contentHash": "4a86f22a7052bb452249efcad361d65a4ff8b1d13602bd3cdab99e3a764e9db7",
      "byteLength": 2057,
      "width": 132,
      "height": 44
    },
    {
      "reference": "assets/1605538191724.png",
      "url": "/media/08f72c0d36c19ca14640.png",
      "mediaType": "image/png",
      "contentHash": "08f72c0d36c19ca146407e0a761d59a221d52568fe4bf470f667b7b17795756f",
      "byteLength": 1293,
      "width": 190,
      "height": 44
    },
    {
      "reference": "assets/1605539840101.png",
      "url": "/media/1d58611c1cbc186c0339.png",
      "mediaType": "image/png",
      "contentHash": "1d58611c1cbc186c033903ff1ab9eaad573d81fd08bb389502215537378f164a",
      "byteLength": 580,
      "width": 86,
      "height": 36
    },
    {
      "reference": "assets/1605539845963.png",
      "url": "/media/17a8416c3c55695b57f6.png",
      "mediaType": "image/png",
      "contentHash": "17a8416c3c55695b57f6203aea5f8fd99ce926492602edcd95179aaeddb40d37",
      "byteLength": 1791,
      "width": 151,
      "height": 39
    },
    {
      "reference": "assets/1605539851349.png",
      "url": "/media/39942bfe29b6a17a0c68.png",
      "mediaType": "image/png",
      "contentHash": "39942bfe29b6a17a0c68f843559050c9ba9a0c09bd498e34109a8f6e7275a499",
      "byteLength": 1928,
      "width": 171,
      "height": 40
    },
    {
      "reference": "assets/1605539866622.png",
      "url": "/media/592e3d001e06dd682ca7.png",
      "mediaType": "image/png",
      "contentHash": "592e3d001e06dd682ca7073be8da6826357e446370cef0c104111314620eb36b",
      "byteLength": 2949,
      "width": 262,
      "height": 68
    },
    {
      "reference": "assets/1605540452731.png",
      "url": "/media/c8e56f16fe1772a77969.png",
      "mediaType": "image/png",
      "contentHash": "c8e56f16fe1772a77969b4a26a280a69185b122bdd94ff6964b42e9e23434dc0",
      "byteLength": 1379,
      "width": 130,
      "height": 41
    },
    {
      "reference": "assets/1605540483949.png",
      "url": "/media/dcb772b8cb7fbe9f3c8c.png",
      "mediaType": "image/png",
      "contentHash": "dcb772b8cb7fbe9f3c8cb886dfc146678212ec37c943a1e9dcf985048f8df61b",
      "byteLength": 1161,
      "width": 85,
      "height": 50
    },
    {
      "reference": "assets/1605540550815.png",
      "url": "/media/4b5daaaf10d6bad8b6f0.png",
      "mediaType": "image/png",
      "contentHash": "4b5daaaf10d6bad8b6f01dd19ab70de98f882233a8175aedbd5baed9e39b48d8",
      "byteLength": 6739,
      "width": 339,
      "height": 210
    },
    {
      "reference": "assets/1605537829384.png",
      "url": "/media/c44ecde5cb6989cb0a17.png",
      "mediaType": "image/png",
      "contentHash": "c44ecde5cb6989cb0a17d92cafb5e4883acf28ecd6626431e32961013a656174",
      "byteLength": 3673,
      "width": 364,
      "height": 55
    },
    {
      "reference": "assets/1605541294606.png",
      "url": "/media/f55e0a3d9f8fc42cc27d.png",
      "mediaType": "image/png",
      "contentHash": "f55e0a3d9f8fc42cc27d452c28f9387f8935eb048644e371fa175f2c6ec42392",
      "byteLength": 1458,
      "width": 181,
      "height": 34
    },
    {
      "reference": "assets/1605541332395.png",
      "url": "/media/7b719438c4d8b1b57ce5.png",
      "mediaType": "image/png",
      "contentHash": "7b719438c4d8b1b57ce5ac3ac8bd9d945e917b62c5cef0be26ed261428c28c14",
      "byteLength": 1757,
      "width": 243,
      "height": 32
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605537132976.png",
      "url": "/media/2f94c8a9d6a73c851332.png",
      "mediaType": "image/png",
      "contentHash": "2f94c8a9d6a73c8513321f934586fb54302e485d75f1ce70d8c9988b75110ad6",
      "byteLength": 54315,
      "width": 758,
      "height": 289
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605538126941.png",
      "url": "/media/7c252ae9c7dabae2fd9a.png",
      "mediaType": "image/png",
      "contentHash": "7c252ae9c7dabae2fd9a20e52eb0029bd6de8c19cbec19458a37336e2d8b509f",
      "byteLength": 1577,
      "width": 119,
      "height": 48
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605538133244.png",
      "url": "/media/4a86f22a7052bb452249.png",
      "mediaType": "image/png",
      "contentHash": "4a86f22a7052bb452249efcad361d65a4ff8b1d13602bd3cdab99e3a764e9db7",
      "byteLength": 2057,
      "width": 132,
      "height": 44
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605538191724.png",
      "url": "/media/08f72c0d36c19ca14640.png",
      "mediaType": "image/png",
      "contentHash": "08f72c0d36c19ca146407e0a761d59a221d52568fe4bf470f667b7b17795756f",
      "byteLength": 1293,
      "width": 190,
      "height": 44
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605539845963.png",
      "url": "/media/17a8416c3c55695b57f6.png",
      "mediaType": "image/png",
      "contentHash": "17a8416c3c55695b57f6203aea5f8fd99ce926492602edcd95179aaeddb40d37",
      "byteLength": 1791,
      "width": 151,
      "height": 39
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605539851349.png",
      "url": "/media/39942bfe29b6a17a0c68.png",
      "mediaType": "image/png",
      "contentHash": "39942bfe29b6a17a0c68f843559050c9ba9a0c09bd498e34109a8f6e7275a499",
      "byteLength": 1928,
      "width": 171,
      "height": 40
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605539866622.png",
      "url": "/media/592e3d001e06dd682ca7.png",
      "mediaType": "image/png",
      "contentHash": "592e3d001e06dd682ca7073be8da6826357e446370cef0c104111314620eb36b",
      "byteLength": 2949,
      "width": 262,
      "height": 68
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605540452731.png",
      "url": "/media/c8e56f16fe1772a77969.png",
      "mediaType": "image/png",
      "contentHash": "c8e56f16fe1772a77969b4a26a280a69185b122bdd94ff6964b42e9e23434dc0",
      "byteLength": 1379,
      "width": 130,
      "height": 41
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605540483949.png",
      "url": "/media/dcb772b8cb7fbe9f3c8c.png",
      "mediaType": "image/png",
      "contentHash": "dcb772b8cb7fbe9f3c8cb886dfc146678212ec37c943a1e9dcf985048f8df61b",
      "byteLength": 1161,
      "width": 85,
      "height": 50
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605540550815.png",
      "url": "/media/4b5daaaf10d6bad8b6f0.png",
      "mediaType": "image/png",
      "contentHash": "4b5daaaf10d6bad8b6f01dd19ab70de98f882233a8175aedbd5baed9e39b48d8",
      "byteLength": 6739,
      "width": 339,
      "height": 210
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605537829384.png",
      "url": "/media/c44ecde5cb6989cb0a17.png",
      "mediaType": "image/png",
      "contentHash": "c44ecde5cb6989cb0a17d92cafb5e4883acf28ecd6626431e32961013a656174",
      "byteLength": 3673,
      "width": 364,
      "height": 55
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605541294606.png",
      "url": "/media/f55e0a3d9f8fc42cc27d.png",
      "mediaType": "image/png",
      "contentHash": "f55e0a3d9f8fc42cc27d452c28f9387f8935eb048644e371fa175f2c6ec42392",
      "byteLength": 1458,
      "width": 181,
      "height": 34
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605541332395.png",
      "url": "/media/7b719438c4d8b1b57ce5.png",
      "mediaType": "image/png",
      "contentHash": "7b719438c4d8b1b57ce5ac3ac8bd9d945e917b62c5cef0be26ed261428c28c14",
      "byteLength": 1757,
      "width": 243,
      "height": 32
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1605541534485.png",
      "url": "/media/a51acfc8f50d3701a0f9.png",
      "mediaType": "image/png",
      "contentHash": "a51acfc8f50d3701a0f937f2a3428db9df70971c9d754866ca9f9b4e779b0f77",
      "byteLength": 4127,
      "width": 193,
      "height": 84
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__SVG_4655d932b869cde4cdf4976bd6ce0f7a.png",
      "url": "/media/1547a7fd486b9a6ee06b.png",
      "mediaType": "image/png",
      "contentHash": "1547a7fd486b9a6ee06bd31f11cd628d04087b57816d29dc53ead1cdb7a3e8c6",
      "byteLength": 5140,
      "width": 339,
      "height": 80
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__SVG_5a63411fc213ac47e7e48572f7e42bf6.png",
      "url": "/media/81e28b56406ed2340819.png",
      "mediaType": "image/png",
      "contentHash": "81e28b56406ed2340819ff01b6330c3732dccb7b824928ddaca391fb1b9fa303",
      "byteLength": 1625,
      "width": 68,
      "height": 28
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1606279331658.png",
      "url": "/media/8cd5364c8a673ec5ed76.png",
      "mediaType": "image/png",
      "contentHash": "8cd5364c8a673ec5ed76ce48feb9dbaca275a800e9fd1e41e363b2d383f057cc",
      "byteLength": 4302,
      "width": 345,
      "height": 124
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1606279370092.png",
      "url": "/media/836f503d028d2850cca7.png",
      "mediaType": "image/png",
      "contentHash": "836f503d028d2850cca73e7e2a4a0b933e7158665f858052d3631c4d898f6b5f",
      "byteLength": 3575,
      "width": 290,
      "height": 110
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1606279661653.png",
      "url": "/media/52b1b8b3dc04df125056.png",
      "mediaType": "image/png",
      "contentHash": "52b1b8b3dc04df125056823df4daa271a1112be37552403ed8a90c2e3fec1bdf",
      "byteLength": 2553,
      "width": 177,
      "height": 125
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1606279452094.png",
      "url": "/media/3a1a2f6bda8f737460f7.png",
      "mediaType": "image/png",
      "contentHash": "3a1a2f6bda8f737460f70a6c0ec9767b70e5ffa4b7feefb4b5241be3b0376a4a",
      "byteLength": 4102,
      "width": 327,
      "height": 119
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1606279456390.png",
      "url": "/media/3cc708bcd3c8f07b4e2f.png",
      "mediaType": "image/png",
      "contentHash": "3cc708bcd3c8f07b4e2f0c09237cbeea0b88ccd97ab23810888f1e99462187e8",
      "byteLength": 3939,
      "width": 312,
      "height": 111
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__SVG_84b3c3dcfa5c3c02d966703bf3f600be.png",
      "url": "/media/d7d7722731978af0a43b.png",
      "mediaType": "image/png",
      "contentHash": "d7d7722731978af0a43bd8d2ab86c67ad34045a6f637a194cb1ff6d8d43da962",
      "byteLength": 2476,
      "width": 161,
      "height": 33
    },
    {
      "reference": "assets/0007 - 【CG】3D数学基础__1606279673503.png",
      "url": "/media/7bc1a47e16f168a221c9.png",
      "mediaType": "image/png",
      "contentHash": "7bc1a47e16f168a221c9637ba92b6963eb5493120ab33e0a14e2bc05d197fa76",
      "byteLength": 2516,
      "width": 183,
      "height": 115
    }
  ],
  "headings": [
    {
      "depth": 1,
      "text": "【CG】3D数学基础",
      "anchor": "cg3d数学基础",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#cg3d%E6%95%B0%E5%AD%A6%E5%9F%BA%E7%A1%80"
    },
    {
      "depth": 2,
      "text": "坐标系与基",
      "anchor": "坐标系与基",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%9D%90%E6%A0%87%E7%B3%BB%E4%B8%8E%E5%9F%BA"
    },
    {
      "depth": 2,
      "text": "矢量",
      "anchor": "矢量",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%9F%A2%E9%87%8F"
    },
    {
      "depth": 3,
      "text": "点积 / 内积 （dot product）/（innr product）",
      "anchor": "点积-内积-dot-productinnr-product",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%82%B9%E7%A7%AF-%E5%86%85%E7%A7%AF-dot-productinnr-product"
    },
    {
      "depth": 3,
      "text": "叉积 / 外积 （cross product）/（outer product）",
      "anchor": "叉积-外积-cross-productouter-product",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%8F%89%E7%A7%AF-%E5%A4%96%E7%A7%AF-cross-productouter-product"
    },
    {
      "depth": 2,
      "text": "矩阵",
      "anchor": "矩阵",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%9F%A9%E9%98%B5"
    },
    {
      "depth": 3,
      "text": "特殊矩阵",
      "anchor": "特殊矩阵",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%89%B9%E6%AE%8A%E7%9F%A9%E9%98%B5"
    },
    {
      "depth": 4,
      "text": "逆矩阵（inverse matrix）",
      "anchor": "逆矩阵inverse-matrix",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E9%80%86%E7%9F%A9%E9%98%B5inverse-matrix"
    },
    {
      "depth": 4,
      "text": "正交矩阵（orthogonal matrix）",
      "anchor": "正交矩阵orthogonal-matrix",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E6%AD%A3%E4%BA%A4%E7%9F%A9%E9%98%B5orthogonal-matrix"
    },
    {
      "depth": 3,
      "text": "矩阵运算",
      "anchor": "矩阵运算",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%9F%A9%E9%98%B5%E8%BF%90%E7%AE%97"
    },
    {
      "depth": 3,
      "text": "矩阵存储",
      "anchor": "矩阵存储",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%9F%A9%E9%98%B5%E5%AD%98%E5%82%A8"
    },
    {
      "depth": 3,
      "text": "矩阵的几何意义 - 变换",
      "anchor": "矩阵的几何意义---变换",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%9F%A9%E9%98%B5%E7%9A%84%E5%87%A0%E4%BD%95%E6%84%8F%E4%B9%89---%E5%8F%98%E6%8D%A2"
    },
    {
      "depth": 4,
      "text": "线性变换（linear transform）",
      "anchor": "线性变换linear-transform",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%BA%BF%E6%80%A7%E5%8F%98%E6%8D%A2linear-transform"
    },
    {
      "depth": 4,
      "text": "仿射变换（affine transform）",
      "anchor": "仿射变换affine-transform",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E4%BB%BF%E5%B0%84%E5%8F%98%E6%8D%A2affine-transform"
    },
    {
      "depth": 5,
      "text": "平移",
      "anchor": "平移",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%B9%B3%E7%A7%BB"
    },
    {
      "depth": 5,
      "text": "缩放",
      "anchor": "缩放",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%BC%A9%E6%94%BE"
    },
    {
      "depth": 5,
      "text": "旋转",
      "anchor": "旋转",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E6%97%8B%E8%BD%AC"
    },
    {
      "depth": 5,
      "text": "复合",
      "anchor": "复合",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%A4%8D%E5%90%88"
    },
    {
      "depth": 2,
      "text": "矩阵与坐标空间变换",
      "anchor": "矩阵与坐标空间变换",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E7%9F%A9%E9%98%B5%E4%B8%8E%E5%9D%90%E6%A0%87%E7%A9%BA%E9%97%B4%E5%8F%98%E6%8D%A2"
    },
    {
      "depth": 3,
      "text": "坐标空间变换基础",
      "anchor": "坐标空间变换基础",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%9D%90%E6%A0%87%E7%A9%BA%E9%97%B4%E5%8F%98%E6%8D%A2%E5%9F%BA%E7%A1%80"
    },
    {
      "depth": 3,
      "text": "渲染管线中的坐标空间转换过程",
      "anchor": "渲染管线中的坐标空间转换过程",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E6%B8%B2%E6%9F%93%E7%AE%A1%E7%BA%BF%E4%B8%AD%E7%9A%84%E5%9D%90%E6%A0%87%E7%A9%BA%E9%97%B4%E8%BD%AC%E6%8D%A2%E8%BF%87%E7%A8%8B"
    },
    {
      "depth": 4,
      "text": "模型空间（model space） | 对象空间（object space） | 局部空间（local space）",
      "anchor": "模型空间model-space-对象空间object-space-局部空间local-space",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E6%A8%A1%E5%9E%8B%E7%A9%BA%E9%97%B4model-space-%E5%AF%B9%E8%B1%A1%E7%A9%BA%E9%97%B4object-space-%E5%B1%80%E9%83%A8%E7%A9%BA%E9%97%B4local-space"
    },
    {
      "depth": 4,
      "text": "世界空间(world space)",
      "anchor": "世界空间world-space",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E4%B8%96%E7%95%8C%E7%A9%BA%E9%97%B4world-space"
    },
    {
      "depth": 4,
      "text": "观察空间(view space) | 摄像机空间(camera space)",
      "anchor": "观察空间view-space-摄像机空间camera-space",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E8%A7%82%E5%AF%9F%E7%A9%BA%E9%97%B4view-space-%E6%91%84%E5%83%8F%E6%9C%BA%E7%A9%BA%E9%97%B4camera-space"
    },
    {
      "depth": 4,
      "text": "（齐次）裁剪空间（clip space）",
      "anchor": "齐次裁剪空间clip-space",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E9%BD%90%E6%AC%A1%E8%A3%81%E5%89%AA%E7%A9%BA%E9%97%B4clip-space"
    },
    {
      "depth": 5,
      "text": "透视投影（perspective projection）",
      "anchor": "透视投影perspective-projection",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E9%80%8F%E8%A7%86%E6%8A%95%E5%BD%B1perspective-projection"
    },
    {
      "depth": 5,
      "text": "正交投影（orthographic projection）",
      "anchor": "正交投影orthographic-projection",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E6%AD%A3%E4%BA%A4%E6%8A%95%E5%BD%B1orthographic-projection"
    },
    {
      "depth": 4,
      "text": "屏幕空间（screen space）",
      "anchor": "屏幕空间screen-space",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%B1%8F%E5%B9%95%E7%A9%BA%E9%97%B4screen-space"
    },
    {
      "depth": 5,
      "text": "齐次除法（homogeneous division） | 透视除法（perspective division）",
      "anchor": "齐次除法homogeneous-division-透视除法perspective-division",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E9%BD%90%E6%AC%A1%E9%99%A4%E6%B3%95homogeneous-division-%E9%80%8F%E8%A7%86%E9%99%A4%E6%B3%95perspective-division"
    },
    {
      "depth": 4,
      "text": "屏幕空间（screen space）",
      "anchor": "屏幕空间screen-space-1",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%B1%8F%E5%B9%95%E7%A9%BA%E9%97%B4screen-space-1"
    },
    {
      "depth": 5,
      "text": "屏幕映射",
      "anchor": "屏幕映射",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%B1%8F%E5%B9%95%E6%98%A0%E5%B0%84"
    },
    {
      "depth": 3,
      "text": "法线变换",
      "anchor": "法线变换",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E6%B3%95%E7%BA%BF%E5%8F%98%E6%8D%A2"
    },
    {
      "depth": 2,
      "text": "其他问题",
      "anchor": "其他问题",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#%E5%85%B6%E4%BB%96%E9%97%AE%E9%A2%98"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/cg-3d-math-fundamentals/#ref"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "渲染基础中的“【CG】3D数学基础”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#%E6%B8%B2%E6%9F%93%E5%9F%BA%E7%A1%80"
    }
  ],
  "contentMarkdown": "# 【CG】3D数学基础\n\n> 创建时间：2020/11/16 22:29\n\n  * 【CG】3D数学基础\n    * 坐标系与基\n    * 矢量\n      * 点积 / 内积 （dot product）/（innr product）\n      * 叉积 / 外积 （cross product）/（outer product）\n    * 矩阵\n      * 特殊矩阵\n        * 逆矩阵（inverse matrix）\n        * 正交矩阵（orthogonal matrix）\n      * 矩阵运算\n      * 矩阵存储\n      * 矩阵的几何意义 - 变换\n        * 线性变换（linear transform）\n        * 仿射变换（affine transform）\n          * 平移\n          * 缩放\n          * 旋转\n          * 复合\n    * 矩阵与坐标空间变换\n      * 坐标空间变换基础\n      * 渲染管线中的坐标空间转换过程\n        * 模型空间（model space） | 对象空间（object space） | 局部空间（local space）\n        * 世界空间(world space)\n        * 观察空间(view space) | 摄像机空间(camera space)\n        * （齐次）裁剪空间（clip space）\n          * 透视投影（perspective projection）\n          * 正交投影（orthographic projection）\n        * 屏幕空间（screen space）\n          * 齐次除法（homogeneous division） | 透视除法（perspective division）\n        * 屏幕空间（screen space）\n          * 屏幕映射\n      * 法线变换\n    * 其他问题\n    * Ref\n\n## 坐标系与基\n\n  * 笛卡儿坐标系（ Cartesian Coordinate System）\n\n  * 基向量（basis vector）\n\n  * 正交基（orthogonal basis）：基向量互相垂直\n\n  * 标准正交基（orthonormal basis）：基向量互相垂直，长度为1\n\n  * 左/右手坐标空间（left/right-handed coordinate space）\n\n  * 旋向性（handedness）\n\n> Unity坐标系：\n>  左手坐标系 - 模型空间，世界空间\n>  右手坐标系 - 观察空间，摄像机前向是z轴负方向，值越小，深度越大，越远\n\n## 矢量\n\n  * 标量（Scalar）\n\n  * 矢量（vector）\n\n    * 模（magnitude）\n\n    * 方向（direction）\n\n    * 头（head）尾（tail）\n\n> 矢量表示相对于某个点的偏移（displacement）\n\n  * 单位矢量（unit vector） / 被归一化的矢量（normalized vector）\n\n  * 归一化（normalization） - 将非零矢量归一化的过程\n\n> 零矢量不可归一化\n\n### 点积 / 内积 （dot product）/（innr product）\n\n几何意义 - 投影（projection）\n\n![Alt text](assets/1605537132976.png)\n\n### 叉积 / 外积 （cross product）/（outer product）\n\n  * a × b= −( b × a)\n\n  * ｜ a × b ｜= ｜ a ｜ ｜ b ｜ sin θ\n\n几何意义 - 平行四边形面积\n\n## 矩阵\n\n### 特殊矩阵\n\n  * 方块矩阵（square matrix）\n\n  * 对角元素（diagonal elements）\n\n  * 对角矩阵（diagonal matrix）\n\n  * 单位矩阵（identity matrix）\n\n  * 转置矩阵（transposed matrix）\n\n![Alt text](assets/1605538126941.png)\n\n![Alt text](assets/1605538133244.png)\n\n#### 逆矩阵（inverse matrix）\n\n可逆的条件: 首先应该是方阵\n\n![Alt text](assets/1605538191724.png)\n\n  * 可逆的 / 非奇异的 （invertible / nonsingular）\n\n  * 不可逆的 / 奇异的 （noninvertible / singular）\n\n行列式（determinant） 为零 <=> 不可逆\n行列式（determinant） 不为零 <=> 可逆\n\n![Alt text](assets/1605539840101.png)\n\n![Alt text](assets/1605539845963.png)\n\n![Alt text](assets/1605539851349.png)\n\n![Alt text](assets/1605539866622.png)\n\n#### 正交矩阵（orthogonal matrix）\n\n![Alt text](assets/1605540452731.png)\n\n![Alt text](assets/1605540483949.png)\n\n![Alt text](assets/1605540550815.png)\n\n  * c1, c2, c3 是单位向量\n\n  * c1, c2, c3 互相垂直\n\n标准正交基向量构成的矩阵\n\n### 矩阵运算\n\n  * 行（ row） 列（ column）\n\n> 矢量\n>  n × 1 的列矩阵（column matrix）\n>  1 × n 的行矩阵（row matrix）\n\n  * 不满足交换律\n\n  * 满足结合律\n\n![Alt text](assets/1605537829384.png)\n\n矩阵左乘列向量\n\n![Alt text](assets/1605541294606.png)\n\n矩阵右乘行向量\n\n![Alt text](assets/1605541332395.png)\n\n以上两种方式等价。\n\n```cpp\nstring s = String.Empty;\n\n```\n\n通常在变换定点时，使用右乘的方式，向量按照列矩阵来进行乘法。因为Unity提供的内置矩阵(如UNITY_MATRIX_MVP)都是按列存储的。\n\n### 矩阵存储\n\nUnity使用Cg语言的规定，内置矩阵按照列存储（向量是列向量），而填充方式（初始化方式）采用行优先。\n\nC#层的Matrix4x4类型采用列优先方式填充。\n\n### 矩阵的几何意义 - 变换\n\n> 变换（transform）：把一些数据，如点、向量甚至颜色等，通过某种方式进行转换的过程。\n\n#### 线性变换（linear transform）\n\n  * 可以保留矢量加和标量乘的变换\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605537132976.png)\n\n  * 保持网格平行且等距分布的变换\n\n> 3x3矩阵可以表示所有的对三维矢量的线性变换\n\n  1. 缩放 - scale\n\n  2. 错切 - shear\n\n  3. 镜像 - mirroring / reflection\n\n  4. 正交投影 - orthographic projection\n\n#### 仿射变换（affine transform）\n\n> **平移变换** \\- 不是线性变换，不满足标量乘法与矢量加法\n\n**仿射变换** \\- 合并线性变换和平移变换的变换类型\n可以用4x4的矩阵表示。\n\n需要把矢量扩展到四维空间下 - **齐次坐标空间（homogeneous coordinate space）**\n\n> 转齐次坐标：\n>  点 - 把w分量设置为1\n>  向量 - 把w分量设置为0\n\n仿射变换矩阵:\n\\- 表示旋转和缩放\n\\- 表示平移\n\n##### 平移\n\n平移点\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605538126941.png)\n\n平移向量\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605538133244.png)\n\n逆矩阵\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605538191724.png)\n\n##### 缩放\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605539845963.png)\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605539851349.png)\n\n统一缩放（uniform scale） -\n不会改变角度和比例信息\n\n非统一缩放（nonuniform scale） - 拉伸或挤压，改变模型相关角度和比例，影响到法线\n\n逆矩阵\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605539866622.png)\n\n##### 旋转\n\n绕x\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605540452731.png)\n\n绕y\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605540483949.png)\n\n绕z\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605540550815.png)\n\n旋转顺序：\n当给出\n这样的旋转角度时\n\n  * Unity旋转顺序为 - 绕固定坐标系，z->x->y\n\n  * 绕坐标系E下的z轴旋转θz, 在坐标系E下绕z轴旋转θz后的新坐标系E’下的y轴旋转θy，在坐标系E’下绕y轴旋转θy后的新坐标系E”下的x轴旋转θx，即在旋转时，把 坐标系一起转动。\n\n以上两种方式旋转结果相同。\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605537829384.png)\n\n##### 复合\n\n**矩阵乘法不满足交换律，变换结果依赖变换顺序**\n一般情况：缩放->旋转->平移\n\n## 矩阵与坐标空间变换\n\n### 坐标空间变换基础\n\n定义一个坐标空间，必须指名其原点位置和3个坐标轴的方向。数值上相对于另一个坐标空间。\n每个坐标空间都是另一个坐标空间的子空间，每个空间都有一个父坐标空间。对坐标空间的变换实质上就是在父空间和子空间之间对点和矢量进行变换。\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605541294606.png)\n\n已知点在子坐标空间c中点\n，求A在父空间p中的坐标：\nc的3个坐标轴在p空间中的坐标表示为\n![Alt text](assets/0007 - 【CG】3D数学基础__1605541332395.png)\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1605541534485.png)\n\n![Alt text](assets/0007 - 【CG】3D数学基础__SVG_4655d932b869cde4cdf4976bd6ce0f7a.png)\n\n平移变换对矢量没有影响，因此在Shader中可以通过变换矩阵的前3行和前3列来对法线方向和光照方向等进行空间变换。\n\n如果矩阵是正交矩阵，则求逆操作就是求转置操作：\n\n![Alt text](assets/0007 - 【CG】3D数学基础__SVG_5a63411fc213ac47e7e48572f7e42bf6.png)\n\n如果知道子坐标空间的x、y、z轴在父空间下的坐标表示（必须是正交的单位矢量），就可以把他们依次放在矩阵的每一行，就可以得到从父坐标空间到子空间的变换矩阵了。\n\n### 渲染管线中的坐标空间转换过程\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1606279331658.png)\n\n#### 模型空间（model space） | 对象空间（object space） | 局部空间（local space）\n\n自然方向：前(forward), 后(back), 左(left), 右(right), 上(up), 下(down)\nUnity模型空间使用左手坐标系：\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1606279370092.png)\n\n#### 世界空间(world space)\n\n我们所关心的最外层的空间\nUnity中，Transform.Position指的是相对于这个transform的父节点(parent)的模型坐标空间中原点的位置。如果一个Transform没有父节点，这个位置就是世界坐标系中的位置。\n\n**模型变换（Model transform）：模型空间- >世界空间**\n\n#### 观察空间(view space) | 摄像机空间(camera space)\n\n右手坐标系，+z轴指向摄像机后方，符合OpenGL传统。\n观察变换（view transform）：世界空间-> 观察空间\n\n#### （齐次）裁剪空间（clip space）\n\n**裁剪矩阵（clip matrix） | 投影矩阵（projection matrix）** 由视锥体（view frustum）决定\n投影矩阵的目的：\n\n  1. 为投影做准备。经过投影矩阵变换后，顶点的w分量将会具有特殊的意义。\n\n投影矩阵并不进行投影。真正地投影过程会在 **屏幕映射** 时发生，通过 **齐次除法（homogeneous division）** 得到二维坐标。\n\n  2. 对x、y、z分量进行缩放。\n\n##### 透视投影（perspective projection）\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1606279661653.png)\n\n本质是对x、y和z分量进行了不同程度的缩放，z分量还做了一个平移。\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1606279452094.png)\n\n该矩阵会视锥体变换为中心在相机空间原点、边长为2的正方体。\nw分量为z的绝对值，表示到相机的距离，表示缩放值。\n转换为三维空间坐标(x/w, y/w, z/w)。\n顶点在视锥体内，要求\n即，若一个顶点在视锥体内，必须满足\n如何理解四维坐标，如何理解w分量？\n本质问题是，将一个frustum(截头锥体)压缩成一个正方体，求frustum中的点的坐标到正方体空间中点的坐标的一个映射关系。并用矩阵、线性代数的语言描述这一变换，使得所有的点的变换可以用同一个矩阵乘法进行描述，从而可以让计算机对所有顶点批量处理这一变换。\n\n关键点：这个变换不是线性变换，无法用三维矩阵乘法描述。这个变换对所有点不是统一的，还与点到摄像机的距离有关系，不能对所有的点进行统一的变换，意味着对每个点增加一个属性，来描述点到摄像机的距离属性，从而使得这个变换与距离有关，这个属性就是点的w分量。\n\n引入w分量之后，点的坐标扩充到四维，变换矩阵是4x4的矩阵。使用四维矩阵进行投影变换本质上是使用四维空间下的线性变换描述三维空间下的非线性变换（将frustum“捏”成正方体的变换）。\n引入w分量后，实际上将一个点映射成了无数个点。我们定义了三维空间中点(x, y, z)对应的齐次坐标为(wx, wy, wz, w),(w!=0)。\n\n之前“捏”frustum的操作，用三维空间线性变换是无法描述的，用3x3矩阵乘法进行变换是无法达到要求的。我们发现，当扩充一个维度之后，看待这个问题，之前的一些”无理要求”是可以满足的。\n\n按照把frustum“捏”成正方体的条件，建立方程，在齐次空间下求这个映射函数，求出了满足要求的变换矩阵。变换之后，点的坐标是下图右边这个样子：\n\n![Alt text](assets/0007 - 【CG】3D数学基础__1606279456390.png)\n\n再映射到三维空间的点就是这个样子：\n\n![Alt text](assets/0007 - 【CG】3D数学基础__SVG_84b3c3dcfa5c3c02d966703bf3f600be.png)\n\n这样一来，我们对所有的点都可以进行这个变换过程:\n\n  1. 映射到齐次坐标空间（增加一个w分量，变为四维坐标）\n\n  2. 按照我们对视锥体进行形变的要求，求得4x4变换矩阵。\n\n  3. 齐次空间下做统一的缩放、平移变换，这个变换过程中，点将到摄像机的距离体现在w分量上面。\n\n  4. 变换后，再将点映射到三维空间，发现原视锥体经变换后成功映射为正方体，其他所有点也经过了相同的映射，结果是合理的。\n\n##### 正交投影（orthographic projection）\n\n保留了物体的距离和角度，用于2D游戏或渲染小地图等其他HUD元素\n\n> HUD（Head-Up Display）来源于航空，在飞行器中，HUD 指投射到挡风玻璃上的读数，让飞行员可以不用低头就可以看到这些信息。\n>\n![Alt text](assets/0007 - 【CG】3D数学基础__1606279673503.png)\n\n#### 屏幕空间（screen space）\n\n##### 齐次除法（homogeneous division） | 透视除法（perspective division）\n\n用齐次坐标的w分量去除x、y、z分量，得到 **归一化的设备坐标（Normalized Device Coordinates, NDC）** 。\n经过透视投影变换后的裁剪空间，经过齐次除法后会变换到一个立方体内。\n\n> OpenGL传统（Unity），z分量的范围是[-1, 1]。DirectX中，z的范围是[0, 1]。\n\n#### 屏幕空间（screen space）\n\n##### 屏幕映射\n\n**屏幕坐标：** Unity中，屏幕左下角像素坐标是(0, 0)，右上角像素坐标是(pixelWidth, pixelHeight)。\nz分量用于深度缓冲。\nUnity中，裁剪空间->屏幕空间的过程是由底层帮我们完成的。\n\n**视口空间（viewport space）坐标：** 将屏幕空间坐标归一化，屏幕坐标除以分辨率，得到视口空间坐标。屏幕左下角是(0, 0)，右上角是(1, 1)。\n\n### 法线变换\n\n  * 法线（normal）| 法矢量（normal vector）\n\n  * 切线（tangent）|切矢量（tangent vector） - 通常与纹理空间对齐，与法线方向垂直\n\n原坐标空间下：\n得到\n* 变换只包括旋转变换 => 变换矩阵是正交矩阵 =>\n=> 直接用顶点变换矩阵来变换法线\n\n  * 包含旋转和统一缩放 =>\n* 包含非统一缩放 => 必须求解逆矩阵\n\n## 其他问题\n\n  1. 矩阵乘法中，参数的位置决定了对向量按照列矩阵还是行矩阵进行 乘法\n\n  2. Cg中float4x4矩阵是按行有限的方式进行填充的；Unity Matrix4x4矩阵采用列优先的方式存储。\n\n  3. 不能在顶点着色器当中进行齐次除法。顶点着色器中应当保留x、y、w分量。因为从顶点着色器到片元着色器过程中还有一个插值的过程，而插值往往是线性的。如果进行了齐次除法，得到的坐标空间不是线性的，不可以在投影空间中进行插值。片元函数中插值已经结束，得到归一化设备坐标的步骤应当在插值之后进行。\n\n## Ref\n\n《Unity Shader入门精要》 - 冯乐乐\n"
}
