MAL.ProjectPoint3D

Previous  Next

 

ref_point_out = MAL.ProjectPoint3D( BYREF point_out      AS ARRAY,

                                    BYREF point1         AS ARRAY,

                                    BYREF point2         AS ARRAY,

                                    BYREF point3         AS ARRAY,

                                    BYVAL rOffsetX       AS REAL,

                                    BYVAL rOffsetY       AS REAL,

                                    BYVAL rOffsetZ       AS REAL,

                                   [BYVAL nAxis1         AS INTEGER=ML_AXIS_X],

                                   [BYVAL nAxis2         AS INTEGER=ML_AXIS_Y],

                                   [BYVAL nPoint         AS INTEGER=1],

                                   [BYVAL nFrameOffset   AS INTEGER=0] ) AS REFERENCE

 

ref_point_out = MAL.ProjectPoint3D( BYREF point_out      AS ARRAY,

                                    BYREF points_in      AS ARRAY,

                                    BYVAL point1         AS INTEGER,

                                    BYVAL point2         AS INTEGER,

                                    BYVAL point3         AS INTEGER,

                                    BYVAL rOffsetX       AS REAL,

                                    BYVAL rOffsetY       AS REAL,

                                    BYVAL rOffsetZ       AS REAL,

                                   [BYVAL nAxis1         AS INTEGER=ML_AXIS_X],

                                   [BYVAL nAxis2         AS INTEGER=ML_AXIS_Y],

                                   [BYVAL nFrameOffset   AS INTEGER=0] ) AS REFERENCE

 


 

Calculates a projected point from 3 known points. Using 3 reference points, the first reference points specifies the Origin, the 2nd point defines Axis 1 and 3rd point Axis 2.

 

' 2D/3D Axis

CONST ML_AXIS_X         = 0   ' X Axis

CONST ML_AXIS_Y         = 1   ' Y Axis

CONST ML_AXIS_Z         = 2   ' Z Axis

 

This drawing shows a local coordinate system defined by Point 1 and 2 as Positive X and Point 1 and 3 as Positive Z.  Positive Y will be calculated using Cross Product.  The location of the projected point is then calculated by using the supplied ( X, Y, Z ) coordinates in this coordinate system.  The resulting coordinates are then returned in the global coordinate system.

 

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 ) )

 

' Display the Position Coordinates

CALL PrintArray( REF( Position ) )

 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Testing ProjPoint3D

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'

DIM Projected( nFrames, 1, 3 ) AS REAL

 

' Use X/Y/Z Offset with Syntax 1

MAL.ProjectPoint3D( Projected,_

                   V3D( Position, 1 ),_

                   V3D( Position, 2 ),_

                   V3D( Position, 3 ),_

                   250.0, 120.0, 0.0 )

CALL PrintArray( REF( Projected ) )

 

' Use X/Y/Z Offset with Syntax 2

MAL.ProjectPoint3D( Projected, Position, 1, 2, 3, 250.0, 120.0, 0.0 )

CALL PrintArray( REF( Projected ) )

 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' 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