与尺度无关、可微分、共面测量

发布于 2024-10-16 02:22:40 字数 580 浏览 0 评论 0原文

我正在寻找一个(几乎无处不在)可微函数f(p1, p2, p3, p4),给定四个点将为我提供与尺度无关的共面性度量。如果四个点位于同一平面上,则为零,否则为正。与比例无关意味着,当我统一缩放所有点时,平面度测量将返回相同的值。

我想出了一些相当复杂且不容易优化的东西。定义u=p2-p1v=p3-p1w=p4-p1。那么平面度度量为:

[(u x v) * w]² / (|u x v|² |w|²)

其中 x 表示叉积,“*”表示点积。

分子只是由四个点定义的四面体体积(的平方),分母是一个归一化因子,使该度量变成简单的角度余弦。因为在统一比例下角度不会变化,所以这个函数满足了我的所有要求。

有人知道更简单的东西吗?

亚历克斯.

编辑:

我最终使用了增强拉格朗日方法来执行优化,所以我不需要它与规模无关。只需使用约束 (uxv) * w = 0 就足够了,因为优化过程会找到正确的拉格朗日乘子来补偿比例。

I am looking for an (almost everywhere) differentiable function f(p1, p2, p3, p4) that given four points will give me a scale-agnostic measure for co-planarity. It is zero if the four points lie on the same plane and positive otherwise. Scale-agnostic means that, when I uniformly scale all points the planarity measure will return the same.

I came up with something that is quite complex and not easy to optimize. Define u=p2-p1, v=p3-p1, w=p4-p1. Then the planarity measure is:

[(u x v) * w]² / (|u x v|² |w|²)

where x means cross product and '*' means dot product.

The numerator is simply (the square of) the volume of the tetrahedron defined by the four points, and the denominator is a normalizing factor that makes this measure become simply the cosine of an angle. Because angles do not changed under uniform scale, this function satisfies all my requirements.

Does anybody know of something simpler?

Alex.

Edit:

I eventually used an Augmented Lagrangian method to perform optimization, so I don't need it to be scale agnostic. Just using the constraint (u x v) * w = 0 is enough, as the optimization procedure finds the correct Lagrange multiplier to compensate for the scale.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

A君 2024-10-23 02:22:40

你的方法似乎没问题,我会做这样的事情来有效实现:

  • 像你一样将u,v,w
  • 标准化它们:存在各种技巧可以以你想要的任何精度有效地评估平方根倒数,例如 这颗宝石。大多数现代处理器都有用于此操作的内置函数。
  • 取 f = |det(u, v, w)| ( = (uxv) . w )。 3x3 矩阵有快速的直接实现;请参阅 @batty 对这个问题的回答。

这相当于你在没有方块的情况下所做的事情。它仍然是同质的并且几乎处处可微。如果你想要处处可微的东西,就取行列式的平方。

编辑:@phkahler 隐含地建议使用内接球体的半径与外接球体的半径之比作为平面度的度量。这是点的有界可微函数,通过缩放保持不变。然而,这至少和你(和我)建议的一样难以计算。特别是计算外接球的半径对舍入误差非常敏感。

Your methods seems ok, I'd do something like this for efficient implementation:

  • Take u, v, w as you did
  • Normalize them: various tricks exist to evaluate the inverse square root efficiently with whatever precision you want, like this jewel. Most modern processors have builtins for this operation.
  • Take f = |det(u, v, w)| ( = (u x v) . w ). There are fast direct implementations for 3x3 matrices; see @batty's answer to this question.

This amounts to what you do without the squares. It is still homogeneous and almost everywhere differentiable. Take the square of the determinant if you want something differentiable everywhere.

EDIT: @phkahler implicitly suggested using the ratio of the radius of the inscribed sphere to the radius of the circumscribed sphere as a measure of planarity. This is a bounded differentiable function of the points, invariant by scaling. However, this is at least as difficult to compute as what you (and I) suggest. Especially computing the radius of the circumscribed sphere is very sensitive to roundoff errors.

剪不断理还乱 2024-10-23 02:22:40

相对于点重新排序应该对称的度量是:

((u x v).w)^2/(|u||v||w||u-v||u-w||v-w|)

它与四面体体积的平方除以所有 6 个边长成正比。它并不比你的公式或 Alexandre C. 的公式简单,但也复杂不了多少。然而,当任意两点重合时,它确实会变得不必要的奇异。

一个性能更好、对顺序不敏感的公式是:

let a = u x v
    b = v x w
    c = w x u
(a.w)^2/(|a| + |b| + |c| + |a+b+c|)^3

这类似于四面体的体积除以表面积,但提高到适当的幂以使整个事物对比例不敏感。这也比您的公式复杂一点,但除非所有 4 个点共线,否则它会起作用。

A measure that should be symmetric with respect to point reorderings is:

((u x v).w)^2/(|u||v||w||u-v||u-w||v-w|)

which is proportional to the volume of the tetrahedron squared divided by all 6 edge lengths. It is not simpler than your formula or Alexandre C.'s, but it is not much more complicated. However, it does become unnecessarily singular when any two points coincide.

A better-behaved, order-insensitive formula is:

let a = u x v
    b = v x w
    c = w x u
(a.w)^2/(|a| + |b| + |c| + |a+b+c|)^3

which is something like the volume of the tetrahedron divided by the surface area, but raised to appropriate powers to make the whole thing scale-insensitive. This is also a bit more complex than your formula, but it works unless all 4 points are collinear.

差↓一点笑了 2024-10-23 02:22:40

怎么样

|(u x v) * w| / |u|^3

(如果您认为更简单,您可以将 |x| 更改为 (x)^2)。

How about

|(u x v) * w| / |u|^3

(and you can change |x| to (x)^2 if you think it's simpler).

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