|
Arrays |
|
|
MyBASIC2 Arrays
The Motion Analysis Library uses MyBASIC2 arrays of REAL to store and process the data. A MyBASIC2 array can have up to 4 dimensions. To dimension an array, use the DIM statement. The Motion Analysis Library uses 3 of the 4 dimensions. The 4 MyBASIC2 dimensions are numbered as:
( dim1, dim2, dim3, dim4 )
The dimensions are used as the following in the Motion Analysis Library:
dim1 Not Used by MAL dim2 No of Frames dim3 No of Points or Channels dim4 Data Dimension (1, 2, 3 or 5 for C3D with Residual and Camera Mask)
DIM data( Frames, Points, DataDimension ) AS REAL
If one or more dimensions only have one element, then you can omit them from right to left. For instance, an array with 1D data can be dimensioned as
DIM data( Frames, Points ) AS REAL
This is the same as
DIM data( Frames, Points, 1 ) AS REAL
Subsequently, data with only 1 dimension such as analog data and only one point or channel can be specified as
DIM data( Frames ) AS REAL
This is the same as declaring the array as
DIM data( Frames, 1, 1 ) AS REAL
Arrays with 2D/3D data and only one point may be declared and used as
DIM data( Frames, 2 ) AS REAL DIM data( Frames, 3 ) AS REAL
When single point output arrays are dynamically created, it will use this alternate format. These can then be used as input arrays in function call that require 2D or 3D data as input.
To initialize or assign array values using MyBASIC2, please see LET statement. You can also use the MAL.Set function to assign an array a value or using another array. The advantage of using MAL.Set is that it returns a reference that can be used as a parameter in another function call. It can also also assign ranges of frames and/or points/channels.
To specify a subscript of an array in MyBASIC2 you use indexes (indices). The indexes are numbered from right to left as opposed to the dimensions. To access an element of an array with 3 dimensions, index 1 will specify the data index, index 2 specifies point/channel and index 3 is the frame number. Index 4 is currently not being used. Note that indexes are all based on current OPTION BASE setting.
Indexes are specified as Array( ix4, ix3, ix2, ix1 ) and is the same as Array( NotUsed, Frame, Point, DataDimension ).
ix4 - Not Used by MAL ix3 - Frames ix2 - Points or Channels. ix1 - Data Dimension (1D, 2D or 3D).
Frame Offsets and Points or Channels
Most functions in the MaxMAL Library accepts a Point or Channel number. These are always specified with 1 being the first point/channel. You can also specify a range of points/channels by using PTS( from, to ) where PTS( 1, 4 ) specifies point/channel 1 through 4. To specify all points/channels, use the ML_ALL constant.
Frame Offsets are always specified starting at 0, i.e. no offset. You can specify a range of frames using FRS( frame_offset, no_of_frames ).
Vector Index Arrays
A Vector Index Array (VIXA) is an INTEGER that contains compressed indexes into an array. Only index 1, 2 and 3 are being represented. The VIXA is formatted as:
ix3 - Frames ix2 - Points or Channels. Default 1 ix1 - Data Dimension (1D, 2D or 3D). Default 1D
Functions that accepts a VIXA are functions that can use/specify a data dimension as well as points/channels and frame number. You can use the VIX function to create a VIXA. The VIX function uses the current OPTION BASE setting while VIXAs are always specified as base 0. For example, VIXA 0 is will always specify first data dimension (X), first point/channel and the first frame. Please see VIX function for more information.
|