help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Euclidean geometry in octave


From: Ted Harding
Subject: RE: Euclidean geometry in octave
Date: Wed, 07 Oct 1998 10:10:49 +0100 (BST)

On 07-Oct-98 Dirk Laurie wrote:
> I often need drawings for Euclidean geometry problems in 
> documents.  I don't like any of the software I've seen, so
> I would like to do it in Octave.
> 
>   1. Am I re-inventing the wheel?  In other words, does there
>      exist a perfectly reasonable Octave package which already 
>      does this?
>   2. I've tried a few simple things, and have immediately come
>      up against a plotting problem: I can't find a plotting
>      command that forces the scales on the two axes to be the
>      same.  For example, what looked like perfectly good circles
>      and squares on my X11 screen come out as ellipses and 
>      parallelograms on Postscript output. So:
>        How does one force a 2D plot to have equal scales
>        on both axes?

It depends what sort of objects you want to draw. If it's straight lines
and circular arcs in plane geometry you don't need to use octave at all,
though of course you can use it. If it's pictures of surfaces then octave
could be a useful tool. If it's plane curves with awkward equations then
octave again could help. But see below.

Regarding Point 2: This used to be an old bugbear with gnuplot. However,
the developers now seem to have addressed it adequately, though I wouldn't
trust it 100 per cent. You should try (in octave):

  gset size ratio -1

According to gnuplot 'help set size' (which see for more detail):

  Syntax:
        set size {{no}square | ratio <r> | noratio} {<xscale>,<yscale>}

  The meaning of a negative value for <r> is different. If <r>=-1, gnuplot
  tries  to set the scales so that the unit has the same length on x and y
  axis  (suitable for geographical data, for instance). If <r>=-2, the
  unit on y has  twice the length of the unit on x, and so on.

The operative word is "tries": It seems to work OK in the gnuplot X11
terminal and in PostScript, but may fail for other displays/printers.

If it won't work for you, then there are other ways. One of my favourite
approaches to drawing geometrical figures in documents uses the "pic"
resources of the "groff" (or "troff" if you're on standard UNIX) document
formatting package. This essentially allows you to draw any plane figure
"by numbers", i.e. you specify the coordinates of the marks you want.
For simple figures (e.g. a series of straight lines, some full, some
dashed, such as you might use to illustrate a proof of Pythagoras's
theorem) you can just type in what you want between ".PS" and ".PE" lines
in your document. For more complex things, you may want to get the
coordinates generated by software, and here octave could be useful.

One of the current shortcomings of octave is that there are some tasks,
contouring and surface plotting in particular, where octave does none of
the computation itself but delegates it to gnuplot. More precisely,
if you want a contour plot of a function the only way octave will do it
is to generate the values of F(x,y) at a grid of (x,y) values and pass
these to gnuplot which will then do the contouring itself by
interpolation. If you want a surface, it is similar: octave passes the
gridded F(x,y) values to gnuplot which then looks after deciding which
lines will appear on the drawing, and which will be hidden, in order
to display the surface from the chosen aspect.

In the past, gnuplot had serious bugs in both of these areas (contour
lines veering drunkenly off the graph, undersides of surfaces bleeding
through to the top, etc), but now seems to have improved a lot (though
again I would not trust it 100 per cent).

The implication of this for the case where you want to use pic/groff for
your document is that octave itself will not know the coordinates used
for the lines in the plot: only gnuplot knows these and does not talk
back to octave. You can find out what gnuplot thinks they are by using
the gnuplot terminal "table" ('gset term table' in octave; see "help set
term table" in gnuplot). By setting gnuplot output to a file you can save
these values and try to read them back into octave from the file (see
"help set output" in gnuplot).

Sorry about the length of this -- it's a bit of a hobbyhorse of mine!

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 07-Oct-98                                       Time: 10:10:49
--------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]