arraycoord
The arraycoord function returns a coordinate array for the linear index into a multi-dimensional array. All coordinates are returned as integral values. This is the inverse of arrayindex, which converts a coordinate array to a linear index.
Coord_Array = arraycoord( Axis_Array, nIndex )
where Axis_Array is a lua table (indexed array)
containing the array dimensions, starting from the most rapidly
varying index in element [1]
nIndex is
the linear index into the Axis_Array.
Coord_Array
is returned as an n-dimensional array containing coordinates, with
the most rapidly varying index in element [1].
On
failure, nil is
returned.
The following script returns a coordinate array based on the linear index and the axis lengths of the array.
|
-- array containing the axis lengths |
|
-- linear index into the array |
|
-- find the coordinate array x |
|
-- test the returned coordinate array |
|
-- for each element in the coordinate array |
|
-- list the coordinates |
|
-- result: 125, 40, 2, |
Mira Pro x64 Script User's Guide, v.8.77 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.