为什么使用矩阵?

问题描述 投票:0回答:2

为什么我们使用矩阵而不是数组?

[如果我创建3D模型的顶点数组,并且想将每个顶点很好地向左移动

   ArrayList<Vertex> vertex = fillVertecis();
   for(Vertex vertex: vertices){
      vertex.x += 2;
   }

   //or avoiding creating all those objects

   float[] vertices = fillVertecis();

   //asumming we arrange the array like so [x1,y1,z1,x2,y2,z2....]
   int x = 0;
   int y = 1;
   int z = 2;

   for(int i = 0; i < vertices.lenght/3; i+= 3){
      vertices[i+x] += 1;
   } 


确保我遍历所有顶点,但是我们不必使用矩阵做同样的事情吗?

我们使用矩阵而不是数组有什么优势?

java matrix 3d
2个回答
0
投票

我们使用矩阵而不是数组有什么优势?

  • 目的明确。

  • 易于操纵。

  • 实现的抽象。

  • ...


0
投票

尝试对顶点应用旋转或缩放,您将看到4x4矩阵和homogeneous transformations优于数组的好处。

© www.soinside.com 2019 - 2024. All rights reserved.