MAL.Distance |
ref_arr_out = MAL.Distance( [BYREF arr_out AS ARRAY], BYREF arr_in AS ARRAY, [BYVAL nPoint AS INTEGER=ML_ALL], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
Calculates the distance travelled between 2 consecutive points and stores it in the output 1D array. The input array can be either 1D, 2D or 3D (first dimenson 1, 2, 3 or 5)
Example:
OPTION EXPLICIT ON OPTION BASE 1
' Include C3D Support $INCLUDE "MyBASIC2_C3DFile" $LIBRARY "MyBASIC2_C3DFileLib"
' Include the MaxMAL Library $INCLUDE "MyBASIC2_MaxMAL" $LIBRARY "MyBASIC2_MaxMALLib"
' Forward Declare PrintArray DECLARE SUB PrintArray
' Declare variables and arrays DIM nPoints AS INTEGER DIM nFrames AS INTEGER DIM hFile AS INTEGER DIM fid AS HANDLE
' Open the Test File hFile = C3DFile.Open( "e:\walk8.c3d" )
IF NOT hFile > 0 THEN PRINT "Error Opening File ";cFileName, STOP ENDIF
' Get the no of points and frames nFrames = C3DFile.GetNoOfFrames( hFile ) nPoints = C3DFile.GetNoOfPoints( hFile )
' Dimension the arrays DIM arrPoints(nFrames,nPoints,3) AS REAL
IF C3DFile.GetPoints( hFile, arrPoints ) <> nFrames THEN C3DFile.Close( hFile ) PRINT "Error Reading ";nPoints;" from file ";cFileName, STOP ENDIF
' Array to receive the calculated Vector Length DIM arrVLen(nFrames,nPoints,1) AS REAL
DIM i AS INTEGER
FOR i = 1 TO nPoints ' Calculate Distance travelled of the Points PRINT "Total Distance Travelled Point #";i;": "; MAL.Sum( MAL.Distance( arrVLen, arrPoints, i ) ) ENDFOR
' Close Test File C3DFile.Close( hFile )
END
|