There is no Plot routine to draw a straight line, because any straight line in physical coordinates can potentially turn into a curve in graphical coordinates. We therefore start by considering how to draw geodesic curves. These are curves which trace the path of shortest distance between two points in physical coordinates and are the basic drawing element in a Plot.
In many instances, the geodesic will, in fact, be a straight line, but this depends on the Plot's current Frame. If this represents a celestial coordinate system, for instance, it will be a great circle (corresponding with the behaviour of the astDistance function which defines the metric of the physical coordinate space). The geodesic will, of course, be transformed into graphics coordinates before being plotted. A geodesic curve is plotted using astCurve as follows:
double start[ NCOORD ], finish[ NCOORD ]; ... astCurve( plot, start, finish );
Here, ``start'' and ``finish'' are arrays containing the starting and
finishing coordinates of the curve. The astOffset and astDistance
functions can often be useful for computing these
().
If you need to draw a series of curves end-to-end (when drawing a contour line, for example), then a more efficient alternative is to use astPolyCurve. This has the same effect as a sequence of invocations of astCurve, but allows you to supply a whole set of points at one time. astPolyCurve then joins them, in sequence, using geodesic curves:
#define NPOINT 100 double coords[ NCOORD ][ NPOINT ]; ... astPolyCurve( plot, NPOINT, NCOORD, NPOINT, coords );
Here, NPOINT specifies how many points are to be joined and NCOORD
specifies how many coordinates are being supplied for each point. The
array ``coords'' supplies the coordinates of the points in the Plot's
physical coordinate system.
AST A Library for Handling World Coordinate Systems in Astronomy