English 中文(简体)
Connecting points in Mathematica
原标题:

I have a collection of points displayed in a graphic:

alt text http://img69.imageshack.us/img69/874/plc1k1lrqynuyshgrdegvfy.jpg

I d like to know if there is any command that will connect them automatically along the xx and yy axis. This can be better understood looking at the following picture: alt text http://img341.imageshack.us/img341/5926/tr53exnkpeofcuiw40koyks.jpg (I am not asking how to implement the algorithm myself!).

Thanks

最佳回答

Some of what you are looking for is in the ComputationalGeometry Package. In particular, ConvexHull will give you the outer points listed in counterclockwise direction. At which point you can use Line to connect them together. The inner paths are a bit trickier, and I don t think there is an exact match. But, a DelaunayTriangulation comes closest. It essentially breaks your list of points up into sets of triangles. I don t know of a built in function that would break it into rectangles, though.

问题回答

I suspect the answer is no, there s no such command. It would be interesting to write something to do that though, ie, given a list of points, output the corresponding lines. I guess that would just be a matter of:

For each unique x-coordinate get the list of y-coordinates for points with that x-coordinate and make a line from the min to the max y-coordinate. Then repeat for the y-coordinates.

If you do that, it would be interesting to post it here as a follow-up. Or if you want to make that the question, I m sure you ll get some nice solutions.

I vote for dreeves suggestion. It doesn t use a "built-in" function, but it s a one-liner using functional programming and level specifications. An implementation is:

gridify[pts : {{_?NumericQ, _?NumericQ} ...}] :=
  Map[Line, GatherBy[pts, #]& /@ {First, Last}, {2}]




相关问题
Solving vector equations in Mathematica

I m trying to figure out how to use Mathematica to solve systems of equations where some of the variables and coefficients are vectors. A simple example would be something like where I know A, V, and ...

Introspection of messages generated in Mathematica

Is there any way to get at the actual messages generated during the evaluation of an expression in Mathematica? Say I m numerically solving an ODE and it blows up, like so In[1] := sol = NDSolve[{x [...

Connecting points in Mathematica

I have a collection of points displayed in a graphic: alt text http://img69.imageshack.us/img69/874/plc1k1lrqynuyshgrdegvfy.jpg I d like to know if there is any command that will connect them ...

Mathematica, PDF Curves and Shading

I need to plot a normal distribution and then shade some specific region of it. Right now I m doing this by creating a plot of the distribution and overlaying it with a RegionPlot. This is pretty ...

Targeted Simplify in Mathematica

I generate very long and complex analytic expressions of the general form: (...something not so complex...)(...ditto...)(...ditto...)...lots... When I try to use Simplify, Mathematica grinds to a ...

热门标签