如何计算中轴?
有谁知道如何计算两条给定曲线的中轴?
中轴: http://en.wikipedia.org/wiki/Medial_axis
这是形状我需要计算它:
我自己画了中轴,即深黑线,但我需要能够动态计算它。
这是我迄今为止所做的小程序和代码: http://www.prism.gatech.edu/~jstrauss6/3451/sample /
已知变量有: - 点A、B、C、D - 红色、绿色和黑色圆圈的半径 -pt Q 和 R(就在图片外面),黑色圆圈。
Does anyone know how to calculate the medial axis for two given curves?
Medial axis: http://en.wikipedia.org/wiki/Medial_axis
Here is the shape I need to calculate it for:
I drew in the medial axis myself, the dark black line, but I need to be able to calculate it dynamically.
Here is the applet and code of what I have done so far:
http://www.prism.gatech.edu/~jstrauss6/3451/sample/
The known variables are:
-pt A, B, C, D
-radii of red, green, and black circles
-pt Q and R (just outside the picture), the black circles.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
令
C1
和C2
为半径为r1
和r2
的圆心。由两个圆组成的图形的中轴(减去两个中心点)是满足的点M
的集合,这意味着
中轴是四次代数曲线。
假设
C1
和C2
在 y 轴上,并假设点 (0,0) 位于中轴上(因此C1 = ( 0, -r1 - x)
和C2 = (0, r2 + x)
对于某些x
,您可以根据数据计算)。这是你随时可以转变的东西。现在,您需要参数化中轴的曲线 y = f(x)。为此,选择您选择的
x
,并使用牛顿法求解y
中的方程(**)
,初始猜测为y = 0 。这是一个可以精确计算的多项式及其导数(在
y
中)。Let
C1
andC2
be centers of circles with radiir1
andr2
. The medial axis (minus the two center points) of the figure made of the two circles is the set of pointsM
satisfyingwhich implies
so the medial axis is a fourth degree algebraic curve.
Let us say that
C1
andC2
are on the y axis, and suppose that the point (0,0) lies on the medial axis (soC1 = (0, -r1 - x)
andC2 = (0, r2 + x)
for somex
you can compute from your data). This is something you can always transform into.Now, you want the curve
y = f(x)
which parametrizes the median axis. For this, pick thex
of your choice, and solve equation(**)
iny
with Newton's method, with initial guessy = 0
. This is a polynomial you can compute exactly, as well as its derivative (iny
).在这种情况下,中轴是双曲线。
有关详细信息,请参阅本文,特别是以下摘录:
因此,考虑到焦点和顶点距离,问题就简化为绘制双曲线。
The medial axis is in this case a hyberbola.
For more information see this article, particularly the following excerpt:
So the problem reduces to drawing a hyperbola, given its foci and vertex distance.
如果将圆圈嵌入到矩形网格上(想想图像),那么您可以使用该图像的距离变换来计算中轴。请参阅此链接。
存在多种 O(nlogn) 算法用于计算图像网格上的距离图。
If you embed the circles on a rectangular grid (think image), then you can use the distance transform of this image to compute your medial axis. See this link.
Several O(nlogn) algorithms exist for computing the distance map on an image grid.