5.7 Primitives

These functions draw some simple objects like line, point, sphere, drop, cone and so on. See Using primitives, for sample code and picture.

MGL command: ball x y ['col'='r.']
MGL command: ball x y z ['col'='r.']
Method on mglGraph: void Ball (mglPoint p, char col='r')
Method on mglGraph: void Mark (mglPoint p, const char *mark)
C function: void mgl_mark (HMGL gr, mreal x, mreal y, mreal z, const char *mark)

Draws a mark (point ‘.’ by default) at position p={x, y, z} with color col.

MGL command: errbox x y ex ey ['stl'='']
MGL command: errbox x y z ex ey ez ['stl'='']
Method on mglGraph: void Error (mglPoint p, mglPoint e, char *stl="")
C function: void mgl_error_box (HMGL gr, mreal x, mreal y, mreal z, mreal ex, mreal ey, mreal ez, char *stl)

Draws a 3d error box at position p={x, y, z} with sizes e={ex, ey, ez} and style stl. Use NAN for component of e to reduce number of drawn elements.

MGL command: line x1 y1 x2 y2 ['stl'='']
MGL command: line x1 y1 z1 x2 y2 z2 ['stl'='']
Method on mglGraph: void Line (mglPoint p1, mglPoint p2, char *stl="B", int num=2)
C function: void mgl_line (HMGL gr, mreal x1, mreal y1, mreal z1, mreal x2, mreal y2, mreal z2, char *stl, int num)

Draws a geodesic line (straight line in Cartesian coordinates) from point p1 to p2 using line style stl. Parameter num define the “quality” of the line. If num=2 then the straight line will be drawn in all coordinate system (independently on transformation formulas (see Curved coordinates). Contrary, for large values (for example, =100) the geodesic line will be drawn in corresponding coordinate system (straight line in Cartesian coordinates, circle in polar coordinates and so on). Line will be drawn even if it lies out of bounding box.

MGL command: curve x1 y1 dx1 dy1 x2 y2 dx2 dy2 ['stl'='']
MGL command: curve x1 y1 z1 dx1 dy1 dz1 x2 y2 z2 dx2 dy2 dz2 ['stl'='']
Method on mglGraph: void Curve (mglPoint p1, mglPoint d1, mglPoint p2, mglPoint d2, const char *stl="B", int num=100)
C function: void mgl_curve (HMGL gr, mreal x1, mreal y1, mreal z1, mreal dx1, mreal dy1, mreal dz1, mreal x2, mreal y2, mreal z2, mreal dx2, mreal dy2, mreal dz2, const char *stl, int num)

Draws Bezier-like curve from point p1 to p2 using line style stl. At this tangent is codirected with d1, d2 and proportional to its amplitude. Parameter num define the “quality” of the curve. If num=2 then the straight line will be drawn in all coordinate system (independently on transformation formulas, see Curved coordinates). Contrary, for large values (for example, =100) the spline like Bezier curve will be drawn in corresponding coordinate system. Curve will be drawn even if it lies out of bounding box.

MGL command: face x1 y1 x2 y2 x3 y3 x4 y4 ['stl'='']
MGL command: face x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4 ['stl'='']
Method on mglGraph: void Face (mglPoint p1, mglPoint p2, mglPoint p3, mglPoint p4, const char *stl="w")
C function: void mgl_face (HMGL gr, mreal x1, mreal y1, mreal z1, mreal x2, mreal y2, mreal z2, mreal x3, mreal y3, mreal z3, mreal x4, mreal y4, mreal z4, const char *stl)

Draws the solid quadrangle (face) with vertexes p1, p2, p3, p4 and with color(s) stl. At this colors can be the same for all vertexes or different if all 4 colors are specified for each vertex. Face will be drawn even if it lies out of bounding box. Argument stl can also contain mask specification (see Color scheme).

MGL command: rect x1 y1 x2 y2 ['stl'='']
MGL command: rect x1 y1 z1 x2 y2 z2 ['stl'='']

Draws the solid rectangle (face) with vertexes {x1, y1, z1} and {x2, y2, z2} with color stl. At this colors can be the same for all vertexes or separately if all 4 colors are specified for each vertex. Face will be drawn even if it lies out of bounding box. Argument stl can also contain mask specification (see Color scheme).

MGL command: facex x0 y0 z0 wy wz ['stl'='' d1=0 d2=0]
MGL command: facey x0 y0 z0 wx wz ['stl'='' d1=0 d2=0]
MGL command: facez x0 y0 z0 wx wy ['stl'='' d1=0 d2=0]
Method on mglGraph: void FaceX (mreal x0, mreal y0, mreal z0, mreal wy, mreal wz, const char *stl="w", mreal d1=0, mreal d2=0)
Method on mglGraph: void FaceY (mreal x0, mreal y0, mreal z0, mreal wx, mreal wz, const char *stl="w", mreal d1=0, mreal d2=0)
Method on mglGraph: void FaceZ (mreal x0, mreal y0, mreal z0, mreal wx, mreal wy, const char *stl="w", mreal d1=0, mreal d2=0)
C function: void mgl_facex (HMGL gr, mreal x0, mreal y0, mreal z0, mreal wy, mreal wz, const char *stl, mreal d1, mreal d2)
C function: void mgl_facey (HMGL gr, mreal x0, mreal y0, mreal z0, mreal wx, mreal wz, const char *stl, mreal d1, mreal d2)
C function: void mgl_facez (HMGL gr, mreal x0, mreal y0, mreal z0, mreal wx, mreal wy, const char *stl, mreal d1, mreal d2)

Draws the solid rectangle (face) perpendicular to [x,y,z]-axis correspondingly at position {x0, y0, z0} with color stl and with widths wx, wy, wz along corresponding directions. At this colors can be the same for all vertexes or separately if all 4 colors are specified for each vertex. Argument stl can also contain mask specification (see Color scheme). Parameters d1!=0, d2!=0 set additional shift of the last vertex (i.e. to draw quadrangle). Face will be drawn even if it lies out of bounding box.

MGL command: sphere x0 y0 r ['col'='r']
MGL command: sphere x0 y0 z0 r ['col'='r']
Method on mglGraph: void Sphere (mglPoint p, mreal r, const char *stl="r")
C function: void mgl_sphere (HMGL gr, mreal x0, mreal y0, mreal z0, mreal r, const char *stl)

Draw the sphere with radius r and center at point p={x0, y0, z0} and color stl.

MGL command: drop x0 y0 dx dy r ['col'='r' sh=1 asp=1]
MGL command: drop x0 y0 z0 dx dy dz r ['col'='r' sh=1 asp=1]
Method on mglGraph: void Drop (mglPoint p, mglPoint d, mreal r, const char *col="r", mreal shift=1, mreal ap=1)
C function: void mgl_drop (HMGL gr, mreal x0, mreal y0, mreal z0, mreal dx, mreal dy, mreal dz, mreal r, const char *col, mreal shift, mreal ap)

Draw the drop with radius r at point p elongated in direction d and with color col. Parameter shift set the degree of drop oblongness: ‘0’ is sphere, ‘1’ is maximally oblongness drop. Parameter ap set relative width of the drop (this is analogue of “ellipticity” for the sphere).

MGL command: cone x1 y1 z1 x2 y2 z2 r1 [r2=-1 'stl'='']
Method on mglGraph: void Cone (mglPoint p1, mglPoint p2, mreal r1, mreal r2=-1, const char *stl="B")
C function: void mgl_cone (HMGL gr, mreal x1, mreal y1, mreal z1, mreal x2, mreal y2, mreal z2, mreal r1, mreal r2, const char *stl)

Draw tube (or truncated cone if edge=false) between points p1, p2 with radius at the edges r1, r2. If r2<0 then it is supposed that r2=r1. The cone color is defined by string stl. Parameter stl can contain:

  • @’ for drawing edges;
  • #’ for wired cones;
  • t’ for drawing tubes/cylinder instead of cones/prisms;
  • 4’, ‘6’, ‘8’ for drawing square, hex- or octo-prism instead of cones.
MGL command: circle x0 y0 r ['col'='r']
MGL command: circle x0 y0 z0 r ['col'='r']
Method on mglGraph: void Circle (mglPoint p, mreal r, const char *stl="r")

Draw the circle with radius r and center at point p={x0, y0, z0}. Parameter col may contain

  • colors for filling and boundary (second one if style ‘@’ is used, black color is used by default);
  • #’ for wire figure (boundary only);
  • @’ for filling and boundary;
  • mask specification (see Color scheme).
MGL command: ellipse x1 y1 x2 y2 r ['col'='r']
MGL command: ellipse x1 y1 z1 x2 y2 z2 r ['col'='r']
Method on mglGraph: void Ellipse (mglPoint p1, mglPoint p2, mreal r, const char *col="r")
C function: void mgl_ellipse (HMGL gr, mreal x1, mreal y1, mreal z1, mreal x2, mreal y2, mreal z2, mreal r, const char *col)

Draw the ellipse with radius r and focal points p1, p2. Parameter col may contain

  • colors for filling and boundary (second one if style ‘@’ is used, black color is used by default);
  • #’ for wire figure (boundary only);
  • @’ for filling and boundary;
  • mask specification (see Color scheme).
MGL command: rhomb x1 y1 x2 y2 r ['col'='r']
MGL command: rhomb x1 y1 z1 x2 y2 z2 r ['col'='r']
Method on mglGraph: void Rhomb (mglPoint p1, mglPoint p2, mreal r, const char *col="r")
C function: void mgl_rhomb (HMGL gr, mreal x1, mreal y1, mreal z1, mreal x2, mreal y2, mreal z2, mreal r, const char *col)

Draw the rhombus with width r and edge points p1, p2. Parameter col may contain

  • colors for filling and boundary (second one if style ‘@’ is used, black color is used by default);
  • #’ for wire figure (boundary only);
  • @’ for filling and boundary;
  • mask specification (see Color scheme).
MGL command: arc x0 y0 x1 y1 a ['col'='r']
MGL command: arc x0 y0 z0 x1 y1 a ['col'='r']
MGL command: arc x0 y0 z0 xa ya za x1 y1 z1 a ['col'='r']
Method on mglGraph: void Arc (mglPoint p0, mglPoint p1, mreal a, const char *col="r")
Method on mglGraph: void Arc (mglPoint p0, mglPoint pa, mglPoint p1, mreal a, const char *col="r")
C function: void mgl_arc (HMGL gr, mreal x0, mreal y0, mreal x1, mreal y1, mreal a, const char *col)
C function: void mgl_arc_ext (HMGL gr, mreal x0, mreal y0, mreal z0, mreal xa, mreal ya, mreal za, mreal x1, mreal y1, mreal z1, mreal a, const char *col)

Draw the arc around axis pa (default is z-axis pa={0,0,1}) with center at p0 and starting from point p1. Parameter a set the angle of arc in degree. Parameter col may contain color of the arc and arrow style for arc edges.

MGL command: polygon x0 y0 x1 y1 num ['col'='r']
MGL command: polygon x0 y0 z0 x1 y1 z1 num ['col'='r']
Method on mglGraph: void Polygon (mglPoint p0, mglPoint p1, int num, const char *col="r")
C function: void mgl_polygon (HMGL gr, mreal x0, mreal y0, mreal z0, mreal x1, mreal y1, mreal z1, int num, const char *col)

Draw the polygon with num edges starting from p1. The center of polygon is located in p0. Parameter col may contain

  • colors for filling and boundary (second one if style ‘@’ is used, black color is used by default);
  • #’ for wire figure (boundary only);
  • @’ for filling and boundary;
  • mask specification (see Color scheme).
Method on mglGraph: void Logo (long w, long h, const unsigned char *rgba, bool smooth=false, const char *opt="")
C function: void mgl_logo_file (HMGL gr, const char *fname, bool smooth, const char *opt)

Draw bitmap (logo) along whole axis range, which can be changed by Command options. Bitmap can be loaded from file or specified as RGBA values for pixels. Parameter smooth set to draw bitmap without or with color interpolation.

MGL command: symbol x y 'id' ['fnt'='' size=-1]
MGL command: symbol x y z 'id' ['fnt'='' size=-1]
Method on mglGraph: void Symbol (mglPoint p, char id, const char *fnt="", mreal size=-1)
C function: void mgl_symbol (HMGL gr, mreal x, mreal y, mreal z, char id, const char *fnt, mreal size)

Draws user-defined symbol with name id at position p with style specifying by fnt. The size of font is set by size parameter (default is -1). The string fnt may contain color specification ended by ‘:’ symbol; styles ‘a’, ‘A’ to draw at absolute position {x, y} (supposed to be in range [0,1]) of picture (for ‘A’) or subplot/inplot (for ‘a’); and style ‘w’ to draw wired symbol.

MGL command: symbol x y dx dy 'id' ['fnt'=':L' size=-1]
MGL command: symbol x y z dx dy dz 'id' ['fnt'=':L' size=-1]
Method on mglGraph: void Symbol (mglPoint p, mglPoint d, char id, const char *fnt="", mreal size=-1)
C function: void mgl_symbol_dir (HMGL gr, mreal x, mreal y, mreal z, mreal dx, mreal dy, mreal dz, const char *text, const char *fnt, mreal size)

The same as previous but symbol will be drawn rotated along direction d.

MGL command: addsymbol 'id' xdat ydat
Method on mglGraph: void DefineSymbol (char id, const mglDataA &xdat, const mglDataA &ydat)
C function: void mgl_define_symbol (HMGL gr, HCDT xdat, HCDT ydat)

Add user-defined symbol with name id and contour {xdat, ydat}. You can use NAN values to set break (jump) of contour curve.