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 nonholonomic 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 userdefined 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]
 TIME
 [double precision]
 PAR
 [double precision]
 NPAR
 [integer]
 DFLAG
 [integer]
 IFLAG
 [logical]
Output
 RESULT
 [double precision]
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