如何计算中轴?

发布于 2024-10-01 05:32:13 字数 509 浏览 1 评论 0原文

有谁知道如何计算两条给定曲线的中轴?

中轴: http://en.wikipedia.org/wiki/Medial_axis

这是形状我需要计算它: alt text

我自己画了中轴,即深黑线,但我需要能够动态计算它。

这是我迄今为止所做的小程序和代码: 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:
alt text

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空城之時有危險 2024-10-08 05:32:13

C1C2 为半径为r1r2 的圆心。由两个圆组成的图形的中轴(减去两个中心点)是满足的点M的集合

|M - C1| - r1 = |M - C2| - r2

,这意味着

|M - C1| - |M - C2| = r1 - r2
|M - C1|^2 + |M - C2|^2 - (r1 - r2)^2 = 2 * |M - C1||M - C2|
(|M - C1|^2 + |M - C2|^2 - (r1 - r2)^2)^2 = 4 * |M - C1|^2 |M - C2|^2  (**)

中轴是四次代数曲线。

假设 C1C2 在 y 轴上,并假设点 (0,0) 位于中轴上(因此 C1 = ( 0, -r1 - x)C2 = (0, r2 + x) 对于某些 x,您可以根据数据计算)。这是你随时可以转变的东西。

现在,您需要参数化中轴的曲线 y = f(x)。为此,选择您选择的 x,并使用牛顿法求解 y 中的方程 (**),初始猜测为 y = 0 。这是一个可以精确计算的多项式及其导数(在 y 中)。

Let C1 and C2 be centers of circles with radii r1 and r2. The medial axis (minus the two center points) of the figure made of the two circles is the set of points M satisfying

|M - C1| - r1 = |M - C2| - r2

which implies

|M - C1| - |M - C2| = r1 - r2
|M - C1|^2 + |M - C2|^2 - (r1 - r2)^2 = 2 * |M - C1||M - C2|
(|M - C1|^2 + |M - C2|^2 - (r1 - r2)^2)^2 = 4 * |M - C1|^2 |M - C2|^2  (**)

so the medial axis is a fourth degree algebraic curve.

Let us say that C1 and C2 are on the y axis, and suppose that the point (0,0) lies on the medial axis (so C1 = (0, -r1 - x) and C2 = (0, r2 + x) for some x 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 the x of your choice, and solve equation (**) in y with Newton's method, with initial guess y = 0. This is a polynomial you can compute exactly, as well as its derivative (in y).

堇色安年 2024-10-08 05:32:13

在这种情况下,中轴是双曲线。

有关详细信息,请参阅本文,特别是以下摘录:

与两个给定圆外切的任何圆的中心都位于双曲线上,其焦点是给定圆的中心,并且顶点距离 2a 等于两个圆的半径差。

因此,考虑到焦点和顶点距离,问题就简化为绘制双曲线。

The medial axis is in this case a hyberbola.

For more information see this article, particularly the following excerpt:

The center of any circles externally tangent to two given circles lies on a hyperbola, whose foci are the centers of the given circles and where the vertex distance 2a equals the difference in radii of the two circles.

So the problem reduces to drawing a hyperbola, given its foci and vertex distance.

韬韬不绝 2024-10-08 05:32:13

如果将圆圈嵌入到矩形网格上(想想图像),那么您可以使用该图像的距离变换来计算中轴。请参阅此链接
存在多种 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文