Chapter 3. MegaPOV Include files

Table of Contents

3.1. The 'mechsim.inc' include file
3.1.1. general aspects
3.1.2. The Vector_Function() macro
3.1.3. The Object generation macros
3.1.4. The topology generation macros

This part describes the mechsim.inc include file that comes with MegaPOV and contains various macros simplifying the use of the mechanics simulation features.

The mechsim.inc include file contains several macros so simplify the generation of simulation topologies as well as macros building POV-Ray™ objects representing the simulation data.

These macros generate POV-Ray™ objects from the simulation data. Currently there are macros for general topology visualization and specific macros for generating meshes from patch topologies created with the patch generation macros.

This macro generates POV-Ray™ shapes for all masses and connections or faces from a certain range of the simulation data.

Depending on the value of the Show_Faces parameter the macro will either generate a union of cylinders and spheres representing the masses and connections or a mesh with triangles representing the faces.

parameters:

  • Start_Mass_Index, Start_Connection_Index, Start_Face_Index - the starting indices of the range of simulation elements that should be displayed by the macro.

  • End_Mass_Index, End_Connection_Index, End_Face_Index - the end indices of the range of simulation elements that should be displayed by the macro. If one of this values is <0 all elements until the last one are displayed.

  • Connect_Rad - the radius to use for the connections. If this value is <0 the macro uses 0.4* the mass radius for this. If this value is 0 no cylinders are generated for the connections.

  • Show_Faces - if true only a mesh representing the faces is generated. If false connections are represented by cylinders and masses by spheres.

  • Stress_Fact - if >0 the connections are textured to visualize the stress. The fn_Stress_CM function is used for the colors. The extension from relaxed length is scaled with this factor. If this value is <0 the connections are textured with MSim_Tex_C.

  • File_Name - file name string. If its length is zero file writing is turned off, otherwise the geometry is written to a file with that name in addition.

This macro generates a mesh from the patch topology created with the MechSim_Generate_Patch() macro (see Section 3.1.4.6). The mesh is generated in form of the new mesh2 type and optionally includes uv- and normal data depending on the parameters.

parameters:

  • Start_Face_Index - the index of the first face that is part of the patch. This should be stored when the patch is generated. The other starting indices are calculated internally.

  • XSize, YSize - size of the patch, number of nodes in x- and y-direction.

  • Smooth - if true normal vectors are generated so the mesh is smoothed.

  • UV - if true uv-coordinates are generated ranging from 0 to 1 in x-Direction (range in y-Direction depends on the ratio of XSize to YSize).

  • Stress_Fact - if >0 the triangles of the mesh are textured on per vertex basis to visualize the stress. The fn_Stress_CM function is used for the colors. The connection's extension from relaxed length is scaled with this factor. If this value is <0 the whole mesh is textured with MSim_Tex_Mesh.

  • File_Name - file name string. If its length is zero file writing is turned off, otherwise the geometry is written to a file with that name in addition.

Here a comparison between the different methods and variations:

These macros are supposed to be placed in the topology{} block of the mechsim{} section. They generate the masses, connections and faces for certain geometries.

This macro generates 3D rectangular grid of masses with connections and optionally faces on the outside. The density of the masses as well as the stiffness and damping of the connections can be varied with functions.

The generated box starts at the origin and extends in positive x, y and z-direction.

parameters:

  • Velocity - vector defining the starting velocity of all masses.

  • Radius - radius of all masses.

  • fn_Density - user defined function controlling the density of the masses. x, y and z are evaluated in [0..1] range.

  • fn_Stiffness - user defined function controlling the stiffness of the connections.

  • fn_Damping - user defined function controlling the damping of the connections.

  • Faces - if true faces are generated on the outside shape.

  • Cube_Scale - 3D vector controlling the distances in the grid. It defines the size of an elementary cell.

  • Grid_Size - 3D vector containing the number of masses in all three directions.

  • Transf - Transform to be applied to all mass positions.

  • Connect_Arr - Array containing weights for connection stiffness and damping. Meaning of the array fields is described below.

meaning of the 'Connect_Arr' entries:

See also Section 3.1.4.1. If the first entry is 0 no connections are generated. The individual entries are used for the following connections. Only connections up to the size of the array are generated.

  • 0 - axis-parallel connections.
  • 1 - the first diagonal connection in each grid rectangle.
  • 2 - the second diagonal connection in each grid rectangle.
  • 3 - the 3d diagonal connections.

The following pictures illustrate the different sizes of the array:

This macro generates 3D rectangular grid of masses with connections and optionally faces on the outside. In contrast to the MechSim_Generate_Grid_Fn() macro (see Section 3.1.4.2) the density stiffness and damping values are fixed.

parameters:

  • Velocity - vector defining the starting velocity of all masses.

  • Radius - radius of all masses.

  • Density - density of the masses.

  • Stiffness - stiffness of the connections.

  • Damping - damping of the connections.

  • Faces - if true faces are generated on the outside shape.

  • Cube_Scale - 3D vector controlling the distances in the grid. It defines the size of an elementary cell.

  • Grid_Size - 3D vector containing the number of masses in all three directions.

  • Transf - Transform to be applied to all mass positions.

  • Connect_Arr - Array containing weights for connection stiffness and damping. Meaning of the array fields in described in Section 3.1.4.2.

This macro generates 3D rectangular grid of masses with connections and optionally faces on the outside. In contrast to the MechSim_Generate_Grid() macro (see Section 3.1.4.3) all connections all have the same stiffness and damping.

parameters:

  • Velocity - vector defining the starting velocity of all masses.

  • Radius - radius of all masses.

  • Density - density of the masses.

  • Stiffness - stiffness of the connections.

  • Damping - damping of the connections.

  • Faces - if true faces are generated on the outside shape.

  • Cube_Scale - 3D vector controlling the distances in the grid. It defines the size of an elementary cell.

  • Grid_Size - 3D vector containing the number of masses in all three directions.

  • Transf - Transform to be applied to all mass positions.

  • Diagonal - A number controlling which diagonal connections are generated in the grid It corresponds to the array size in the MechSim_Generate_Grid() macro (see Section 3.1.4.3).

Variation of the MechSim_Generate_Grid_Std() macro (see Section 3.1.4.4) where instead of the density of the individual masses the mass of the whole grid is given.

parameters:

  • Velocity - vector defining the starting velocity of all masses.

  • Radius - radius of all masses.

  • Mass - mass of the whole grid.

  • Stiffness - stiffness of the connections.

  • Damping - damping of the connections.

  • Faces - if true faces are generated on the outside shape.

  • Cube_Scale - 3D vector controlling the distances in the grid. It defines the size of an elementary cell.

  • Grid_Size - 3D vector containing the number of masses in all three directions.

  • Transf - Transform to be applied to all mass positions.

  • Diagonal - A number controlling which diagonal connections are generated in the grid It corresponds to the array size in the MechSim_Generate_Grid() macro (see Section 3.1.4.3).

This macro generates a rectangular patch of masses with connections and optionally faces forming the surface. The masses can be fixed with help of a function

parameters:

  • Velocity - vector defining the starting velocity of all masses.

  • Radius - radius of all masses.

  • Density - density of the masses.

  • Stiffness - stiffness of the connections.

  • Damping - damping of the connections.

  • Faces - if true faces are generated for the surface of the patch.

  • Rect_Scale - 2D vector controlling the distances in the grid. It defines the size of an elementary rectangle.

  • Grid_Size - 2D vector containing the number of masses in x and y direction.

  • Transf - Transform to be applied to all mass positions.

  • fn_Fixed - user defined function controlling whether the masses are fixed or not. The function is evaluated in the x-y-plane between 0 and 1. If the function value at a mass position is >0 the mass is fixed.

  • Connect_Arr - Array containing weights for connection stiffness and damping. Meaning of the array fields in described below.

meaning of the 'Connect_Arr' entries:

See also Section 3.1.4.1. The following picture shows which entries in the array weight which connections. Only connections up to the size of the array are generated.

This macro generates a rectangular patch of masses with connections and optionally faces forming the surface. In contrast to the MechSim_Generate_Patch() macro (see Section 3.1.4.6) all connections all have the same stiffness and damping. Also none of the masses is fixed.

parameters:

  • Velocity - vector defining the starting velocity of all masses.

  • Radius - radius of all masses.

  • Density - density of the masses.

  • Stiffness - stiffness of the connections.

  • Damping - damping of the connections.

  • Faces - if true faces are generated for the surface of the patch.

  • Rect_Scale - 2D vector controlling the distances in the grid. It defines the size of an elementary rectangle.

  • Grid_Size - 2D vector containing the number of masses in x and y direction.

  • Transf - Transform to be applied to all mass positions.

  • Connect - A number controlling which connections are generated in the grid It corresponds to the array size in the MechSim_Generate_Patch() macro (see Section 3.1.4.6).

This macro generates a line of connected masses and can be used for simulating things like ropes, chains, etc. The masses of the line can be fixed with help of a function

parameters:

  • Velocity - vector defining the starting velocity of all masses.

  • Radius - radius of all masses.

  • Density - density of the masses.

  • Stiffness - stiffness of the connections.

  • Damping - damping of the connections.

  • Spacing - distance between two neighboring masses.

  • Count - total number of masses.

  • Direction - 3D vector defining the direction of the line from the origin.

  • Transf - Transform to be applied to all mass positions.

  • fn_Fixed - user defined function controlling whether the masses are fixed or not. The function is evaluated in the x-direction between 0 and 1. If the function value at a mass position is >0 the mass is fixed.

  • Connect_Arr - Array containing weights for connection stiffness and damping. Meaning of the array fields in described below.

meaning of the 'Connect_Arr' entries:

See also Section 3.1.4.1. The first element of the array weights the direct connections between two neighboring masses. Further values in the array weight the more distant connections that introduce bending stiffness to the line. Only connections up to the size of the array are generated.

This macro generates a line of connected masses and can be used for simulating things like ropes, chains, etc.. In contrast to the MechSim_Generate_Line() macro (see Section 3.1.4.8) only shortest distance connections are generated. Also none of the masses is fixed.

parameters:

  • Velocity - vector defining the starting velocity of all masses.

  • Radius - radius of all masses.

  • Density - density of the masses.

  • Stiffness - stiffness of the connections.

  • Damping - damping of the connections.

  • Spacing - distance between two neighboring masses.

  • Count - total number of masses.

  • Direction - 3D vector defining the direction of the line from the origin.

  • Transf - Transform to be applied to all mass positions.