GCOSUB

ModelingCalculates a constraint defined using a Constraint_General element. Such constraints are typically used in conjunction with defining a broad range of holonomic and non-holonomic constraints. A typical example is the so called "curve of pursuit" constraint, where one particle is chasing another particle.

Use

A Constraint_General element calling a GCOSUB for the calculation of a user-defined general constraint:

<Constraint_General
     id                  = "1"
     usrsub_param_string = "USER(5000000,1,30101020,30102020)"
     usrsub_dll_name     = "NULL"
     usrsub_fnc_name     = "GCOSUB"
  />

Format

Fortran Calling Syntax
SUBROUTINE GCOSUB (ID, TIME, PAR, NPAR, DFLAG,IFLAG, RESULT)
C/C++ Calling Syntax
void STDCALL GCOSUB (int *id, double *time, double *par, int *npar, int *dflag, int *iflag, double *result)
Python Calling Syntax
def GCOSUB(id, time, par, npar, dflag, iflag):
    return result
MATLAB Calling Syntax
function result = GCOSUB(id, time, par, npar, dflag, iflag)

Attributes

ID
[integer]
The Constraint_General element identifier.
TIME
[double precision]
The current simulation time.
PAR
[double precision]
An array that contains the constant arguments from the list provided in the user- defined statement
NPAR
[integer]
The number of entries in the PAR array.
DFLAG
[integer]
An array of control value integers that define the type of outputs. The first value controls the ARRAY output, the second value controls the SCALAR output, and the third value controls the MATRIX output.
IFLAG
[logical]
The initialization flag.

Output

RESULT
[double precision]
The value of the constraint.

Example

def GCOSUB(id, time, par, npar, dflag, iflag):

    [u1, errflg] = py_sysary("TDISP", [par[1],par[0]])
    [v1, errflg] = py_sysary("TDISP", [par[5],par[3]])
    [u2, errflg] = py_sysary("TDISP", [par[2],par[0]])
    [v2, errflg] = py_sysary("TDISP", [par[4],par[3]])
    result = u1[0]*v1[0]+u1[1]*v1[1]+u1[2]*v1[2]+u2[0]*v2[0]+u2[1]*v2[1]+u2[2]*v2[2]

    return result