Zymplectic project

Documentation

Summary of built-in functions, essential features and limitations.

Documentation is currently incomplete

Built-in functions

Zymplectic contains a range of built-in functions and variables. The functions are found in the Z struct and the draw struct. Zymplectic's built-in functions provide only little safety, so memory access violations may cause the application to shut down without notification.

Z-functions are functions used to specify the system functions, such as the differential equations and energies as well as event functions such as OnDraw and OnIter event specifying what should be drawn in OpenGL or what should happen on each iteration
  • Z-functions are only accessible from main()
  • Z-functions generally provide warnings/errors notifcations for invalid settings as opposed to draw functions
Z-functions (use only in main function) Comment
Z.H(double *E, void *dE, int a)
Z.H(double *E, void *dE, int a , int b)

Z.H cannot be used in the same code as Z.V and Z.T
Declares a Hamiltonian system associated with object a (and b)

E is an energy function of type double E(void) that returns the energy. nullptr can be passed as argument to ignore the energy.

dE is the gradient function of type void dE(void) defining the differential equations

If system only depends on a single variable, b can be omitted
Z.V(double *V, void *dV, int a)
Z.V(double *V, void *dV, int a , int b)
Z.T(double *T, void *dT, int a)
Z.T(double *T, void *dT, int a , int b)

Z.V and Z.T cannot be used in the same code as Z.H
Declares V (potential energy) or T (kinetic energy) of a system associated with object a (and b)

V and T are energy functions of type double V(void) and T(void) that returns the energy. nullptr can be passed as argument to ignore the energy.

dV and dT are gradient functions of type void dV(void) and dT(void) defining the differential equations

If system only depends on a single variable, b can be omitted
Z-variables are struct variables that defines initial settings of the system, which are transferred to the GUI when the code is initially loaded/reloaded
  • Z-variables are only accessible from main()
  • All GUI variables can be set from code using Z.name where name is an identifier specified when hovering GUI objects with mouse
Z-variables Comment
draw is a struct that contains practical functions for creating geometric shapes, particle trajectories and other graphics by the OpenGL API
  • draw functions can not be used in main() where they are not initialized
  • draw functions listed in blue (shapes) and purple (options) are intended to be used in OnDraw event
  • draw functions listed in red are intended be used in OnIter event
  • draw functions can be used in both 2D and 3D display but may offer different visual results
draw-functions Comment

draw.track_add(double x, double y)

add value at pixel position x,y

draw.track_set(double x, double y, int a)

set value to a at position x,y

draw.trail(double x, double y)
draw.trail(double x, double y, double z)

make trail point at position x,y,(z).
If trail disabled, has no effect

draw.sphere(double x, double y, double z, double r)

draw a sphere at x,y,z with radius r
If 2D, draws a filled circle ignoring depth

draw.lines(double* X, double* Y, int a)
draw.lines(double* X, double* Y, double* Z, int a)

draw lines based on coordinate arrays X,Y,(Z) each with specified length a. The number of lines drawn is a/2

draw.points(double* X, double* Y, int a)
draw.points(double* X, double* Y, double* Z, int a)

draw points based on coordinate arrays X,Y,(Z) each with specified length a. The number of points drawn is a

draw.line_strip(double* X, double* Y, int a)
draw.line_strip(double* X, double* Y, double* Z, int a)

draw lines between each coordinate based on coordinate arrays X,Y,(Z) each with specified length a. The number of lines drawn is a-1

draw.quads(double* X, double* Y, int a)
draw.quads(double* X, double* Y, double* Z, int a)

draw filled quads between every four coordinates based on coordinate arrays X,Y,(Z) each with specified length a. The number of quads drawn is a/4

draw.polygon(double* X, double* Y, int a)
draw.polygon(double* X, double* Y, double* Z, int a)

draw filled polygon based on coordinate arrays X,Y,(Z) each with specified length a

draw.triangles(double* X, double* Y, int a)
draw.triangles(double* X, double* Y, double* Z, int a)

draw filled triangles based on coordinate arrays X,Y,(Z) each with specified length a. The number of triangles drawn is a/3

draw.spring(double x1, double y1, double x2, double y2, double r)
draw.spring(double x1, double y1, double z1, double x2, double y2, double z2, double r)

draw a spring between x1,y1,(z1) and x2,y2,(z2) with radius r

draw.rod(double x1, double y1, double z1, double x2, double y2, double z2, double r)
draw.rod(double x1, double y1, double z1, double x2, double y2, double z2, double r, double a, int n)

draw a cylinder between x1,y1,z1 and x2,y2,z2 with radius r, optional rotation in radian a (default 0) and edge count n (default 32)
If n > 16 the edges are drawn with smooth normals
If 2D, draw a cylinder ignoring depth

draw.hrod(double x1, double y1, double z1, double x2, double y2, double z2, double r, double ri)
draw.hrod(double x1, double y1, double z1, double x2, double y2, double z2, double r, double ri, double a, int n)

draw a hollow cylinder between x1,y1,z1 and x2,y2,z2 with radius r, inside radius ri, optional rotation in radian a (default 0) and edge count n (default 32)
If n > 16 the edges are drawn with smooth normals
If 2D, draw a hollow cylinder ignoring depth

draw.text(double x,double y,char* A, int a)
draw.text(double x,double y, double z, char* A, int a)

write text at position x,y,(z) specified by text array A with array length a

draw.textscreen(double x,double y,char* A, int a)

write text at screen pixel coordinates specified by text array A with array length a. Note that coordinate 0,0 is center and default resolution is 768x768 (range -384 to 384)

draw.rgb(double r, double g, double b)
draw.rgb(double r, double g, double b, double a)

assign color red r, green g, blue b and optionally alpha a (default 1) for drawn objects to ranging from 0 to 1

draw.shine(double a, double b)

assign specular a and shininess b for drawn objects ranging from 0 to 1
If 2D, has no effect

draw.light(double x, double y, double z, double p)

set light position or direction x,y,z. If p is 0, light is directional rather than point source.
If not set, light source is at camera
If 2D, has no effect

Built-in natives and reserved variables