|
MAL.Interpolate |
|
|
ref_arr_out = MAL.Interpolate( [BYREF arr_out AS ARRAY], BYREF arr_in AS ARRAY, [BYVAl nType AS INTEGER=ML_SPLINE], [BYVAL nMaxGaps AS INTEGER=60], [BYVAL nCutFrames AS INTEGER=0], [BYVAL nPoint AS INTEGER=ML_ALL], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
Interpolate a data set, i.e., any invalid points will be filled in by interpolation. You can select between Spline and Linear interpolation. the type parameter determines the type of interpolation. The nMaxGaps parameter limites the number of consecutive invalids that can be interpolated. The nCutFrames parameters specifies the number of extract frames that will be removed and marked invalid before and after a data "gap" before interpolating the "gap".
' Interpolation Types CONST ML_LINEAR = 41 ' Linear Interpolation CONST ML_SPLINE = 42 ' Spline Interpolation
Example:
OPTION EXPLICIT ON OPTION BASE 1
' Include C3D Support $INCLUDE "MyBASIC2_C3DFile" $LIBRARY "MyBASIC2_C3DFileLib"
' Needed to extract and Display Version $LIBRARY "MyBASIC2_ExtLib"
' Include the MaxMAL Library $INCLUDE "MyBASIC2_MaxMAL" $LIBRARY "MyBASIC2_MaxMALLib"
' Forward Declare PrintArray and DisplayVersion DECLARE SUB PrintArray DECLARE SUB DisplayVersion
' Declare variables and arrays DIM nPoints AS INTEGER DIM nFrames AS INTEGER DIM hFile AS INTEGER
' Test File CONST cFileName = "e:\walk8Invalids3.c3d"
CLS
' Display the current Library Version CALL DisplayVersion()
' Open the Test File hFile = C3DFile.Open( cFileName );
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 Position(nFrames,nPoints,3) AS REAL DIM Normalized(nFrames,nPoints,3) AS REAL DIM Interpolated(nFrames,nPoints,3) AS REAL DIM Filtered(nFrames,nPoints,3) AS REAL
' Get the Point Coordinates from C3D file IF C3DFile.GetPoints( hFile, Position ) <> nFrames THEN C3DFile.Close( hFile ) PRINT "Error Reading ";nPoints;" from file ";cFileName, STOP ENDIF
' Set the Frame Rate to use in the MaxMAL Library MAL.FrameRate( C3DFile.GetFrameRate( hFile ) )
' Display the Position Coordinates CALL PrintArray( REF( Position ) )
' Interpolate the data MAL.Interpolate( Interpolated, Position, ML_SPLINE, 60, 2 ) CALL PrintArray( REF( Interpolated ) )
' Smooth the data with moving average (Default) MAL.Filter( Filtered, Interpolated ) CALL PrintArray( REF( Filtered ) )
' Normalize the Data MAL.Normalize( Normalized, Filtered ) CALL PrintArray( REF( Normalized ) )
' Just Normalize Point #1 CALL PrintArray( MAL.Normalize( Filtered, 3, TRUE, 1 ) )
' Close File C3DFile.Close( hFile )
END
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Print an array with up to 3 dimensions. Array is passed as a reference ' SUB PrintArray( arr AS REFERENCE ) RUN( "ArrayPlot", arr, TRUE ) END SUB
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Display the MaxMAL Extension Library Version ' SUB DisplayVersion() DIM major AS INTEGER DIM minor AS INTEGER DIM build AS INTEGER DIM qfe AS INTEGER
major = BYTE.HI( WORD.HI( MAL.Version() ) ) minor = BYTE.LO( WORD.HI( MAL.Version() ) ) build = BYTE.HI( WORD.LO( MAL.Version() ) ) qfe = BYTE.LO( WORD.LO( MAL.Version() ) )
PRINT "Library Version: ";FORMAT( "%d, %d, %d, %d", major, minor, build, qfe ), PRINT "Option Flags: ";FORMAT( "0x%08X", MAL.Version( TRUE ) ), END SUB
|