MAL.Orientation |
ref_arr_out = MAL.Orientation( BYREF arr_out AS ARRAY, BYREF TM_in AS ARRAY, [BYVAL nUnits AS INTEGER=ML_DEGREES] ) AS REFERENCE
ref_arr_out = MAL.Orientation( BYREF arr_out AS ARRAY, BYREF point1 AS ARRAY, BYREF point2 AS ARRAY, BYREF point3 AS ARRAY, [BYVAL nAxis1 AS INTEGER=ML_AXIS_X], [BYVAL nAxis2 AS INTEGER=ML_AXIS_Y], [BYVAL nUnits AS INTEGER=ML_DEGREES], [BYVAL nPoint AS INTEGER=1], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
ref_arr_out = MAL.Orientation( BYREF arr_out AS ARRAY, BYREF arr_in AS ARRAY, BYVAL point1 AS INTEGER, BYVAL point2 AS INTEGER, BYVAL point3 AS INTEGER, [BYVAL nAxis1 AS INTEGER=ML_AXIS_X], [BYVAL nAxis2 AS INTEGER=ML_AXIS_Y], [BYVAL nUnits AS INTEGER=ML_DEGREES], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
Calculates the orientation angles of a 3x3 rotation matrix or by using 3 points and the 2 coordinate axis they define. The output is a 3D array with the rotation around X axis in first dimension, rotation around Y axis in second and rotation around Z in third.
Example:
OPTION EXPLICIT ON OPTION REDIM 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 and DisplayVersion DECLARE SUB PrintArray
' Declare variables and arrays DIM nPoints AS INTEGER DIM nFrames AS INTEGER DIM hFile AS INTEGER
' Open the Test File hFile = C3DFile.Open( "e:\Rot3.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 ) )
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Testing CreateTM and Orientation ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' DIM TM( nFrames, 3, 3 ) AS REAL
MAL.CreateTM( TM, Position, 1, 2, 3 )
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Get the Orientation in Radians ' CALL PrintArray( MAL.Orientation( NULL, TM, ML_RADIANS ) )
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Test Second Syntax ' DIM rot( nFrames, 1, 3 ) AS REAL
MAL.Orientation( rot, V3D( Position, 1 ),_ V3D( Position, 2 ),_ V3D( Position, 3 ) ) CALL PrintArray( REF( rot ) )
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Test Third Syntax using as reference as output ' DIM r AS REFERENCE
r = MAL.Orientation( NULL, Position, 1, 2, 3 ) ) CALL PrintArray( r ) UNREF r
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' 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
|