Back to main page
Back to draw contents
This section shows how to draw functions expressed in non cartesian coordinates.
Two functions defined in polar coordinates.
draw2d(terminal = eps,
grid = true,
nticks = 300,
line_type = solid,
key = "Rhodonea curve",
polar(5*sin(10*theta),theta,0,%pi*2),
line_type = dots,
key = "Fermat spiral", /* don't write "Fermat's" !! */
polar(sqrt(theta),theta,0,10*%pi),
key = "", /* we avoid two equal entries in legend */
polar(-sqrt(theta),theta,0,10*%pi) )$
Option grid = true makes reference to a rectangular grid on the plane. If we are plotting a function in polar coordinates, maybe we prefere a polar grid. In this case, option user_preamble will be of great help.
draw2d(terminal = png,
pic_width = 400,
pic_height = 400,
file_name = "polargrid",
user_preamble = "set grid polar",
nticks = 200,
xrange = [-5,5],
yrange = [-5,5],
color = red,
line_width = 3,
title = "Hyperbolic Spiral",
polar(10/theta,theta,1,10*%pi) )$
Function defined in spherical coordinates. In this example, variable a is the azimuth and variable z is the zenith. The expression is for the radius.
draw3d( surface_hide = true, axis_3d = false, color = salmon, spherical(sin(z)*cos(2*a),a,0,2*%pi,z,0,%pi))$
A geometrical model for genus Nautilus.
draw3d( color = green, surface_hide = true, axis_3d = false, xtics = none, ytics = none, ztics = none, spherical(a+z,a,0,3*%pi,z,0,%pi))$
Three geometric objects defined in cylindrical coordinates.
draw3d( surface_hide = true, axis_3d = false, xtics = none, ytics = none, ztics = none, color = blue, cylindrical(z,z,-2,2,a,0,2*%pi), /*cone*/ color = brown, cylindrical(3,z,-2,2,az,0,%pi), /*cylinder*/ color = green, cylindrical(sqrt(25-z^2),z,-5,5,a,0,%pi) /*sphere*/ )$
Back to main page
Back to draw contents