Mathematica 中的连接点
我在图形中显示了一系列点:
alt text http://img69.imageshack .us/img69/874/plc1k1lrqynuyshgrdegvfy.jpg
我想知道是否有任何命令可以沿 xx 和 yy 轴自动连接它们。看下图可以更好地理解这一点: 替代文本 http://img341.imageshack.us/img341/5926/tr53exnkpeofcuiw40koyks.jpg< /a> (我不是在问如何自己实现该算法!)。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我怀疑答案是否定的,没有这样的命令。不过,编写一些东西来做到这一点会很有趣,即给定点列表,输出相应的行。我想这只是一个问题:
对于每个唯一的 x 坐标,获取具有该 x 坐标的点的 y 坐标列表,并从最小 y 坐标到最大 y 坐标画一条线。然后对 y 坐标重复此操作。
如果您这样做,将其作为后续内容发布在这里会很有趣。或者,如果您想提出这个问题,我相信您会得到一些不错的解决方案。
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.
我投票支持 dreeves 的建议。它不使用“内置”函数,但它是使用函数式编程和级别规范的单行代码。一个实现是:
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:
您要查找的一些内容位于
ComputationalGeometry
包。特别是,ConvexHull
将为您提供外部点按逆时针方向列出。此时您可以使用Line
将它们连接在一起。内部路径有点棘手,我认为没有完全匹配。但是,DelaunayTriangulation
最接近。它本质上是将您的点列表分解为三角形组。不过,我不知道有什么内置函数可以将其分成矩形。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 useLine
to connect them together. The inner paths are a bit trickier, and I don't think there is an exact match. But, aDelaunayTriangulation
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.