Varkon documentation index

VARKON - Documentation

# The VECTOR datatype and geometric positions

VECTOR is a predefined datatype in the MBS language. It has three components, x, y and z which can be used to represent a position or a direction. VECTOR variables are declared as follows:

    VECTOR p1,p2; ! Two vector variables with name p1 and p2

You can access the components of a VECTOR using point notation as in the following example.

    FLOAT x,z;

    x:=p1.x;  ! The x component of p1
    z:=p1.z;  ! The z component of p2

MBS also includes a number of built in functions that return a VECTOR value. One example is the on() function which returns the coordinates of a position somewhere on a geometric entity.

    VECTOR p1,p2,p3;

    p1:=on(#7);         ! The position of #7.
    p2:=on(#2,0.5);     ! A position half way along #2.
    p3:=on(#5,0.5,0.7); ! A position on a surface.

In this example it is assumed that #7 is a point, coordinate system, text or dimension, ie. an entity without length or size. #2 is assumed to be a wireframe entity, ie. a line, arc or curve. Curves have parameter ranging from 0 to a number equal to the number of segments that make the curve. A curve with 5 segments will go from 0 to 5 in parameter. For curves the parameter is not relative to arclength as it is for lines and arcs. Instead it relates exactly to the internal parameter used in the parametric curve representation. If relative arclength parametrisation is wanted the arcl() and inv_arcl() functions can be used with on() as in the following example:

    VECTOR p1;

    ! A position half way along the curve #2
    p1:=on(#2,inv_arcl(#2,0.5*arcl(#2)));

A VECTOR can also be used to represent a direction. The norm() function for example, returns the direction of the normal vector for a given position on an arc, curve, b_plane or surface as a VECTOR value.

MBS supports addition, subtraction, multiplication and scalar product with VECTOR's in algebraic expressions. The standard library includes functions for vector product, vector length and normalization as well as the calculation of positions, tangents, normals, curvatures, arclengths, and intersects. There is also a low level eval routine for those who wish to know everything there is to know. Inverse functions calculate parameter values for given geometric values. See the MBS programmers manual for the full documentation of all MBS functions and procedures.

Varkon version 1.19C svn# 120