MAL.Angle

Previous  Next

 

ref_angle = MAL.Angle( BYREF angle        AS ARRAY,

                       BYREF arr_p1       AS ARRAY,

                       BYREF arr_p2       AS ARRAY,

                      [BYVAL hOptions     AS HANDLE=NULL],

                      [BYVAL nPoint       AS INTEGER=1],

                      [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE

 

ref_angle = MAL.Angle( BYREF angle        AS ARRAY,

                       BYREF arr_p1       AS ARRAY,

                       BYREF arr_p2       AS ARRAY,

                       BYREF arr_p3       AS ARRAY,

                      [BYVAL hOptions     AS HANDLE=NULL],

                      [BYVAL nPoint       AS INTEGER=1],

                      [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE

 

ref_angle = MAL.Angle( BYREF angle        AS ARRAY,

                       BYREF arr_p1       AS ARRAY,

                       BYREF arr_p2       AS ARRAY,

                       BYREF arr_p3       AS ARRAY,

                       BYREF arr_p4       AS ARRAY,

                      [BYVAL hOptions     AS HANDLE=NULL],

                      [BYVAL nPoint       AS INTEGER=1],

                      [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE

 

ref_angle = MAL.Angle( BYREF angle        AS ARRAY,

                       BYREF arr_points   AS ARRAY,

                       BYVAL nPoint1      AS INTEGER,

                       BYVAL nPoint2      AS INTEGER,

                      [BYVAL hOptions     AS HANDLE=NULL],

                      [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE

 

ref_angle = MAL.Angle( BYREF angle        AS ARRAY,

                       BYREF arr_points   AS ARRAY,

                       BYVAL nPoint1      AS INTEGER,

                       BYVAL nPoint2      AS INTEGER,

                       BYVAL nPoint3      AS INTEGER,

                      [BYVAL hOptions     AS HANDLE=NULL],

                      [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE

 

ref_angle = MAL.Angle( BYREF angle        AS ARRAY,

                       BYREF arr_points   AS ARRAY,

                       BYVAL nPoint1      AS INTEGER,

                       BYVAL nPoint2      AS INTEGER,

                       BYVAL nPoint3      AS INTEGER,

                       BYVAL nPoint4      AS INTEGER,

                      [BYVAL hOptions     AS HANDLE=NULL],

                      [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE

 


 

The angle function will calculate the 2D or 3D angle between 2 vectors or 1 vector and a plane or axis.  When doing 3D angular analysis you can create a 2D angle (a.k.a. "shadow angle") by projecting the 3D angle onto a specified plane.  To create the option mask, use the function MAL.AngleOptions.

 

The angle function accepts either 2, 3 or 4 arrays for each point as input or one array with all points and the point numbers.

 

The following type of angles can be calculated

o2D Angle between 2 vectors using 3 or 4 points (180/360 option is available)
o3D Angle between 2 vectors using 3 or 4 points
o3D data projected into a plane and then 2D angle is calculated.  Note; This is the same as (AN_2D | AN_3D)
oAngle between vector and a 2D or 3D plane;:
2D vector vs X or Y axis/plane
3D vector vs a plane.  Vector is project onto a plane to create 2nd vector

 

Example:

 

OPTION EXPLICIT ON

OPTION REDIM ON

OPTION BASE 1

 

' Need Graph Library

$INCLUDE "MyBASIC2_Win32"

$INCLUDE "MyBASIC2_Graph"

$LIBRARY "MyBASIC2_GraphLib"

 

' Include C3D Support

$INCLUDE "MyBASIC2_C3DFile"

$LIBRARY "MyBASIC2_C3DFileLib"

 

' Include the MaxMAL Library

$INCLUDE "MyBASIC2_MaxMAL"

$LIBRARY "MyBASIC2_MaxMALLib"

 

' Declare variables and arrays

DIM nPoints    AS INTEGER

DIM nFrames    AS INTEGER

DIM nDim       AS INTEGER

DIM nFrameRate AS INTEGER

DIM hFile      AS INTEGER

DIM nGraph     AS INTEGER

DIM hOptions   AS HANDLE

 

' Open the Test File

hFile = C3DFile.Open( "e:\Walk.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 )

nDim    = 3 - C3DFile.IsFile2D( hFile )

 

' Dimension the arrays

DIM Position( nFrames, nPoints, nDim ) 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

 

' Get the Frame Rate from C3D File

nFrameRate = C3DFile.GetFrameRate( hFile )

 

' Set the Frame Rate to use in the MaxMAL Library

MAL.FrameRate( nFrameRate )

 

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

' Calculate and Graph Angles

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

'

DIM Angle( nFrames, 1, 1 ) AS REAL

 

' Set the Angle Options

hOptions = MAL.AngleOptions( ML_DEGREES, ML_RANGE_360, ML_3D_SPACE )

 

' Calculate the Angle between points 1-2-3

MAL.Angle( Angle, Position, 1, 2, 3, hOptions )

 

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

' Create and Display the Graph

'nGraph = GRAPH.Create( MAL.AngleOptions( hOptions ), WS_VISIBLE+WS_CAPTION, -1024, 0, 0, 768 )

 

GRAPH.New( nGraph, NG_XT, MAL.AngleOptions( hOptions ) + " Between Points 1-2-3", nFrameRate )

 

GRAPH.Time( nGraph, TRUE )

GRAPH.Grid( nGraph, FALSE )

 

GRAPH.AddElement( nGraph, VARNAME( Angle ), Angle )

 

' Close the Graph after 30 seconds

GRAPH.Close( nGraph, 30 )

 

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

' Close File

'

C3DFile.Close( hFile )

 

END