to draw a circle, polygons
The parametric expression of a circle is
x=sin(t)
y=cos(t)
and the circle can be drawn if one changes the t parameter
from 0 to 2pi. The graph is "squared" here, and the t range
is given by an option of plot command.
gnuplot> set parametric
dummy variable is t for curves, u/v for surfaces
gnuplot> set size square
gnuplot> set xrange [-1:1]
gnuplot> set yrange [-1:1]
gnuplot> plot [0:2*pi] sin(t),cos(t)
|
The parameter t is not changing continuously, and actually
this is controlled by the value which is set by the set
samples command. The default value is 100. In the case of
set samples 8 , gnuplot generates eight t values
from zero to 2*pi, and the graph becomes a regular heptagon. If
you need a regular N-gon, just type set samples
N+1.
The 2-dim. parametric representation is convenient to draw a
function which is in a polar coordinate.
The 2-dim. polar coordinate has two variables which are radius
r and angle theta. The gnuplot parameter t is
for the theta, and the radius r is expressed by a
function of angle, namely r(t). A (x,y) coordinate is given
by
x=r(t)*cos(t)
y=r(t)*sin(t)
The circle is a special case of which r(t)=const. When the radius of
circle is proportional to t, you get a spiral.
gnuplot> set xrange [-10*pi:10*pi]
gnuplot> set yrange [-10*pi:10*pi]
gnuplot> plot [0:10*pi] t*sin(t),t*cos(t)
|
The following example shows r(t)=const*(1+cos(t)), which is called
Cardioid.
gnuplot> set parametric
dummy variable is t for curves, u/v for surfaces
gnuplot> r(t) = 1+cos(t)
gnuplot> plot [0:2*pi] r(t)*cos(t),r(t)*sin(t)
|