MAL.Extrapolate |
![]() ![]() |
ref_arr_out = MAL.Extrapolate( [BYREF arr_out AS ARRAY], BYREF arr_in AS ARRAY, [BYVAl nType AS INTEGER=ML_SPLINE], [BYVAL nInputs AS INTEGER=3], [BYVAL nParam AS INTEGER=0], [BYVAL nPoint AS INTEGER=ML_ALL], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
Extrapolates a sample based on n number of valid input samples. The extrapolated new sample will be output to nInputs + 1 index in the output array. This will leave the first nInput samples as invalid in the output array. The minimum length of the output array must be nInputs + 1 in order to generate at least one extrapolated value.
There are several different extrapolation methods available. The nType parameter selects the method. This can be one of the following:
' Extrapolation Type CONST ML_EP_LINEAR = 121 ' Linear Extrapolation CONST ML_EP_LSQ = 122 ' LSQ Quadratic Extrapolation CONST ML_EP_POLINT = 125 ' Polynomial Extrapolation CONST ML_EP_RATINT = 126 ' Rational Function Extrapolation CONST ML_EP_POLRAT = 127 ' Combo of ML_EP_POLINT and ML_EP_RATINT ' Note; You can also do a bitwise OR of ' ML_EP_POLINT and ML_EP_RATINT
The minimum and maximum number of inputs is 3 and 11 except for ML_EP_LINEAR where minimum is 2 and maximum 3.
The nParam parameter depends on the selected extrapolation method. For ML_EP_LINEAR, it is an acceleration factor to add to the prediction. Valid range is 0-200 where 0 is no acceleration factor and 200 is double the distance. Normal range for this is between 0 and 75. The less the velocity changes in the movement, the lower the acceleration factor.
For all the other methods, this is the next abscissa. The default here is nInputs + 1.
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 Extrapolated(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 ) )
' Extrapolate the data MAL.Extrapolate( Extrapolated, Position, ML_EP_LINEAR ) CALL PrintArray( REF( Extrapolated ) )
' 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
|