English 中文(简体)
如何旋转 3 维数数组动作标注 3
原标题:How to spin 3 dimensions array actionscript 3

我有像这样的三维数组( 而不是 0 s 我有对象) :

var array:Array =
  [
    [
      [0,0],[0,0],[0,0]
    ],
    [
      [0,0],[0,0],[0,0]
    ],
    [
      [0,0],[0,0],[0,0]
    ],
    [
      [0,0],[0,0],[0,0]
    ]
  ];

每个阵列位置都包含一个放置在 3D 空间中的天体,而要定位它,您只需要: 数组 [zPos][yPos][xPos] 。

是有一个库还是一个函数 让我可以旋转Z、Y和/或X轴的90度数组?

注意: 记住数组可能是不正常的 。

编辑:

我不认为我已经说得很清楚了。我不想在 3D 空间移动物体, 我只想知道它们在那里。 我想用这些阵列来操作它们。

我找到了我的问题的局部解决方案, 但我相信它可以优化。 我开发了一个公式, 用 Z 轴旋转多个阵列。 这里的代码是 :

var arr1:Array = 
[
    [
        [  0,   1,   2,   3],
        [010, 011, 012, 013]
    ],
    [
        [100, 101, 102, 103],
        [110, 111, 112, 113]
    ],
    [
        [200, 201, 202, 203],
        [210, 211, 212, 213]
    ]
];
var arr2:Array = new Array;

for (var i:int = 0; i < arr1.length; i++) 
{
    arr2.push(new Array);
    for (var j:int = 0; j < arr1[i][0].length; j++) 
    {
        arr2[i].push(new Array);
        for (var k:int = 0; k < arr1[i].length; k++) 
        {
            arr2[i][j].push(0);
        }
    }
}

for (i = 0; i < arr1.length; i++) 
{
    for (j = 0; j < arr1[i].length; j++) 
    {
        for (k = 0; k < arr1[i][j].length; k++) 
        {
            arr2[i][k][arr1[i].length - j - 1] = arr1[i][j][k];
        }
    }
}

Do you know other formulas of libraries to rotate the multiple array by the axis Y or X? Thanks a lot and sorry for my english

问题回答

我认为你需要重新考虑设计。 将物体放入这样的阵列中, 并尝试旋转它们, 将是一个明确的性能杀手。

对于多维数组旋转、整数或数字,正确的方式是使用旋转矩阵。您会发现3D操作的函数,如在许多通用动作手动引擎中,如 optrativa3d, move3d, etal3d等。





相关问题
Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签