[Maxima] [draw2d] How to selectively connect an arbitrary number of points
ferriste at gmail.com
Tue May 22 08:29:47 CDT 2012
I'm trying to plot some 2-d geometric figures, composed by points
selectively joined by lines. I'd like to write a code able to deal with a
variable numbers of points and lines (which represent particular
connections), but I'm having some difficulties.
Points are defined in a matrix with as many rows as the number of points,
and two columns (two coordinates for each point). In general, it is an
input of my plot script and it has a variable number of rows.
Here is an example:
NodeCoord : matrix([0,0],[0,1],[2,3],[4,5]);
The i-th point corresponds to the i-th line of this matrix.
I have another matrix, which defines how points are connected. For example,
point 1 is connected to point 2, 3 to 4. I have called this matrix
ConnectMatrix : matrix([1,2],[3,4]);
Each row of ConnectMatrix defines a line connecting the two points in the
An example of the plot routine is the following:
draw2d( point_type = dot,
color = blue,
points_joined = true,
The key is how to automatically generate the line
"points([0,0],[1,0]),points([3,4],[5,6])", considering that the numbers of
these elements can be variable. I have to specify a
points([[node1],[node2]]) separately for each line, because points can be
defined in a sparse order, and only ConnectMatrix establishes how
connections are made.
I have written a routine capable to generate the points([[node1],[node2]])
for each row of ConnectMatrix, but I'm having troubles with joining them
and make draw2d work.
For example, I've tried to create a string "points([[node1],node2]]),
points([[node1,node2]]" and convert it with flatten, but it remains an
atomic expression and draw2d complains about it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Maxima