3D - >一维数组索引 [英] 3d -> 1D array indexing
本文介绍了3D - >一维数组索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C ++中,什么是一个W * H * D分度值大小的3D阵列?
in C++, what is the indexing value for a W * H * D sized 3D array?
对于特定的I,J,K这是正确的索引:
for a particular i, j, k is this the correct indexing:
我* W * H + J * W + K
i*W*H+j*W+k
推荐答案
你写什么就相当于指针运算,这将做到:
What you have written is equivalent to the pointer arithmetic that this would do:
T x[D][H][W];
x[i][j][k]; // Pointer arithmetic done here
显然,这取决于你如何顺序 D
, ^ h
和是W
(或 I
,Ĵ
, K
),计算将有所不同。
Obviously, depending on how you order D
, H
and W
(or i
, j
, k
), the calculation will differ.
这篇关于3D - >一维数组索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文