GAMES101-04空间变换 Cont.

04空间变换 Cont.

  • 一、3D transformations
  • 二、Viewing (观测) transformation
    • 1.View(视图)/ Camera transformation
    • 2.Projection (投影) transformation


一、3D transformations

//在数学上,如果一个矩阵的逆等于它的转置,则叫做正交矩阵
GAMES101-04空间变换 Cont._第1张图片
GAMES101-04空间变换 Cont._第2张图片
万向锁
GAMES101-04空间变换 Cont._第3张图片
Rodrigues’ Rotation Formula
罗德里格斯旋转公式
GAMES101-04空间变换 Cont._第4张图片
定义了一个旋转轴和一个旋转角度(默认原点起点)

找到四元数并做矩阵变换

二、Viewing (观测) transformation

1.View(视图)/ Camera transformation

. Think about how to take a photo

  • Find a good place and arrange people ( m odel transformation)
    • Find a good “angle” to put the camera ( v iew transformation)
    • Cheese! ( p rojection transformation)
      模型-识别-投影变换(MVP变换)

首先定义相机的放置位置,朝向,角度(顶朝向)
GAMES101-04空间变换 Cont._第5张图片
原本相机可以在任意位置,但为了简化,可以将相机放在标准位置(0,0)。
GAMES101-04空间变换 Cont._第6张图片
先平移,再旋转
Translate e to origin
在这里插入图片描述
Rotate g to -Z, t to Y,(g x t) To x
反过来写,再求逆
Consider its inverse rotation: × to (g x t),Y to t,Z to -g

Summary

  • Transform objects together with the camera
  • Until camera’s at the origin, up at Y, look at -Z
    ModelView Transformation模型+视图变换

2.Projection (投影) transformation

GAMES101-04空间变换 Cont._第7张图片

  • Orthographic (正交) projection
    不会带来近大远小的视觉误差
    (道理我都懂,但是鸽子为什么这莫大?)
    we want to map a cuboid [1,r]x [b, t]x [f,n] to the "canonical (正则、规范、标准)"cube [-1,1]3
    正则立方体
    GAMES101-04空间变换 Cont._第8张图片
    先将x,y,z方向移动到以原点中心
    再将立方体正则化
    Translate (center to origin) first,then scale (length/width/height to 2)


Caveat

  • Looking at / along -Z is making near and far not intuitive (n > f)

  • FYl: that’s why OpenGL (a Graphics APl) uses left hand coords.

  • Perspective(透视)projection
    Most common in Computer Graphics, art, visual system
    Further objects are smaller
    Parallel lines not parallel; converge to single point

透视投影到别的平面上后,平行线会不平行。

Recall:
property of homogeneous coordinates

  • (x,y,z,1),(kx, ky,kz,k != O), (xz, yz,z2,z !=0)all represent the same point (x, y, z) in 3D
  • e.g.(1,0,0,1) and (2,0,0,2) both represent (1,0, 0)
    透视投影的平面大小会改变,而正交投影是一样的。

规定:
近平面永远不变。
在平面内向里收缩,远平面不变位置。
Frustum to Cuboid
相似三角形
GAMES101-04空间变换 Cont._第9张图片
ln order to find a transformation

  • Find the relationship between transformed points (x’,y’,z’)and the original points (x, y,z)
    In homogeneous coordinates

    继续推导得:
    GAMES101-04空间变换 Cont._第10张图片
    Observation: the third row is responsible for z’
  • Any point on the near plane will not change
  • Any point’s z on the far plane will not change

GAMES101-04空间变换 Cont._第11张图片

GAMES101-04空间变换 Cont._第12张图片

Solve for A and B
An+B = 2→4A =n+ f
Af + B = f2
B=—n f
Finally, every entry in Mpersp->ortho is known!What’s next?

  • Do orthographic projection(Mortho) to finish-Mpersp = Mortho Mpersp→ortho

你可能感兴趣的:(3d,计算机视觉,线性代数,webgl)