MAL.DeterminantTM |
ref_arr_out = MAL.DeterminantTM( BYREF arr_out AS ARRAY, BYREF arr_TM AS ARRAY, [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
determinant = MAL.DeterminantTM( BYREF arr_TM AS ARRAY ) AS REAL
Calculates the Detrminant of a 3x3 Transformation Matrix. The determinant is a scalar value that is a function of the entries of a square matrix. It allows characterizing some properties of the matrix and the linear map represented by the matrix.
In the first syntax, the input is an array of a 3x3 matrix and should be declared as
DIM tm( nFrames, 3, 3 ) AS REAL
The output is a 1D array.
In the second syntax, the input matrix is a simepl 3x3 matrix declared as
DIM tm( 3, 3 ) AS REAL
The output is the determinant of the TM
Example:
OPTION EXPLICIT ON OPTION REDIM 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
' Open the Test File hFile = C3DFile.Open( "e:\Wander9.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 Position(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 ) )
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Init TM as a 1D array DIM tm( 9 ) AS REAL tm( 1 ) = 7 tm( 2 ) = 1 tm( 3 ) = 3 tm( 4 ) = 2 tm( 5 ) = 4 tm( 6 ) = 1 tm( 7 ) = 1 tm( 8 ) = 5 tm( 9 ) = 1
' Now redimension it to a 3x3 TM DIM tm( 3, 3 ) AS REAL
' Result should be 10 ! PRINT "Determinant: ";MAL.DeterminantTM( tm ),
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Init TM as a 1D array DIM tm( 4, 9 ) AS REAL tm( *, 1 ) = 7 tm( *, 2 ) = 1 tm( *, 3 ) = 3 tm( *, 4 ) = 2 tm( *, 5 ) = 4 tm( *, 6 ) = 1 tm( *, 7 ) = 1 tm( *, 8 ) = 5 tm( *, 9 ) = 1
' Now redimension it to a 3x3 TM DIM tm( 4, 3, 3 ) AS REAL CALL PrintArray( REF( tm ) )
DIM Determinant( 4, 1, 1 ) AS REAL CALL PrintArray( MAL.DeterminantTM( Determinant, tm ) )
' 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( "ArrayTable", arr, TRUE ) END SUB
|