Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matrix 三维复杂矩阵迭代与数据处理_Matrix_Pascal - Fatal编程技术网

Matrix 三维复杂矩阵迭代与数据处理

Matrix 三维复杂矩阵迭代与数据处理,matrix,pascal,Matrix,Pascal,我已经达到了预期的效果,但我正试图找到一个更优雅的解决方案。现在,它有点硬编码,这不是好的做法 注意:这是一种古老的机器人语言,类似于PASCAL 问题:我有一个3D结构矩阵。4 X 4 X 9,但我只关注前4 X 4。结构有我需要操作的数据成员 GlobalTub[i,j,k].calcPos----该成员是一种具有6个实数的职位(XYZWPR) 通过矩阵初始化是没有问题的。只是一个简单的嵌套FOR循环 --Matrix Size --numOfTubs = (X_CNT * Y_CNT *

我已经达到了预期的效果,但我正试图找到一个更优雅的解决方案。现在,它有点硬编码,这不是好的做法

注意:这是一种古老的机器人语言,类似于PASCAL

问题:我有一个3D结构矩阵。4 X 4 X 9,但我只关注前4 X 4。结构有我需要操作的数据成员

GlobalTub[i,j,k].calcPos----该成员是一种具有6个实数的职位(XYZWPR)

通过矩阵初始化是没有问题的。只是一个简单的嵌套FOR循环

--Matrix Size
--numOfTubs = (X_CNT * Y_CNT * Z_CNT)
fCnt = 0        
--Init Matrix
FOR i = 1 TO X_CNT DO       
    FOR j = 1 TO Y_CNT DO
        FOR k = 1 TO Z_CNT DO
            InitPos(GlobalTub[i, j, k].foundPos, 0, 0, 1, 0, 1, 1)
            InitPos(GlobalTub[i, j, k].nextPos, 0, 0, 1, 0, 1, 1)
            InitPos(GlobalTub[i, j, k].calcPos, 0, 0, 1, 0, 1, 1)                       
            GlobalTub[i, j, k].inPlace = FALSE              
            --Assing Tub Number Colmun Major
            fCnt = fCnt + 1
            GlobalTub[i, j, k].tubNum = fCnt
        ENDFOR
    ENDFOR      
ENDFOR
现在我必须“堆垛”这个结构矩阵。现在我只是使用一个硬编码流来迭代X中的4个结构,在Y中转换,然后继续到下一个4

    --Used for Testing
--1 to 4
FOR i = 1 to 4 DO
    TubPos[i] = tempXYZ
    tempXYZ.X = tempXYZ.X + (xPitch + xTolerance)
ENDFOR

tempXYZ = TubPos[1]
tempXYZ.Y = tempXYZ.Y + (yPitch + yTolerance)

-- 5 to 8
FOR i = 1 to 4 DO
    TubPos[i + 4] = tempXYZ
    tempXYZ.X = tempXYZ.X + (xPitch + xTolerance)
ENDFOR

一个嵌套的FOR循环如何实现这一点呢?

我回答了自己的问题……只是把它敲定了

--Init Loop Counter 
fCnt = 1
FOR j = 1 TO Y_CNT DO
    --Place 4 positions in X 
    FOR i = 1 to X_CNT DO
        TubPos[fCnt] = tempXYZ
        tempXYZ.X = tempXYZ.X + (xPitch + xTolerance)
        fCnt = fCnt + 1
    ENDFOR
    --Shift Y position for next 4 Rows
    tempXYZ = TubPos[fCnt-1]
    tempXYZ.X = tempXYZ.X - ((xPitch + xTolerance) * (X_CNT - 1))
    tempXYZ.Y = tempXYZ.Y + (yPitch + yTolerance)
ENDFOR
这是我的输出