zoukankan      html  css  js  c++  java
  • 正交投影矩阵

    正交投影

    正交投影是将世界空间的物体,映射到一个单位立方体上,然后缩放为单位立方体

    // 平移
    (left + right)/2 得到平移后的中心点位置,其他面类似
    A = 
      1 0 0 -(left + right)/2
      0 1 0 -(top + bottom)/2
      0 0 1 -(far + near)/2
      0 0 0 1
    
    // 缩放
    将平移后的立方体缩放为单位立方体(-1,1),2/r-l,使用右手坐标系,z方向为负,-2(f-n)
    
    B = 
      2/(right - left) 0 0 0
      0 2/(top - bottom) 0 0
      0 0 -2(far - near) 0 0
      0 0 0 1
    
    // 相乘
    C = B * A
    
    // 最后结果
    C = 
     2/(right - left) 0 0 0
     0 2/(top - bottom) 0  0 
     0 0 2/(near-far)   0
     (left+right)/(left-right)  (bottom+top)/(bottom-top)   (near+far)/(near-far)    1   
    
    
    var m4 = {
      orthographic: function(left, right, bottom, top, near, far) {
        return [
          2 / (right - left), 0, 0, 0,
          0, 2 / (top - bottom), 0, 0,
          0, 0, 2 / (near - far), 0,
     
          (left + right) / (left - right),
          (bottom + top) / (bottom - top),
          (near + far) / (near - far),
          1,
        ];
      }
  • 相关阅读:
    谈谈SpringFramework与IoC依赖查找
    监控微博、论坛的“棱镜计划”
    输出质数的方法改进
    参数解构
    直接插入排序
    理解迭代
    异常处理
    函数
    continue语句
    break语句
  • 原文地址:https://www.cnblogs.com/pluslius/p/13950248.html
Copyright © 2011-2022 走看看