确定 SAT 分离轴定理中的边缘法线

发布于 2024-09-26 17:34:39 字数 356 浏览 2 评论 0原文

SAT 算法要​​求您找到每个形状的每个边缘的法线(本质上是垂直于边缘向量的向量)以用作分离轴。这可以非常简单地完成...

(x,y) => (-y,x)

(x,y)=> (y,-x)

SAT 算法中应该使用哪个?这本质上是一个应该使用左手法线还是右手法线的问题。使用哪个会有所不同吗?应该只使用正常的左手还是右手?是否应该根据不同的情况而改变?

请参阅http://www.codezealot.org/archives/55#sat-axes

The SAT algorithm requires you to find the normal of each edge of each shape (essentially a vector perpendicular to the edge vector) to be used as the separating axes. This can be done very simply...

(x,y) => (-y,x)

OR

(x,y) => (y,-x)

Which should be used in the SAT algorithm? This is essentially a question of whether the left hand normal or the right hand normal should be used. Will it make a difference which is used? Should only the left or right hand normal be used? Should this change with different situations?

See http://www.codezealot.org/archives/55#sat-axes

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

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

发布评论

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

评论(2

泡沫很甜 2024-10-03 17:34:39

只要对每个面使用相同的约定就没关系,因为法线用于计算投影并比较它们:

  Projection p1 = shape1.project(axis);
  Projection p2 = shape2.project(axis);
  // do the projections overlap?
  if (!p1.overlap(p2)) {

(!p1.overlap(p2)) 的结果将两个公式相同。

华泰

It doesn't matter as long as you use the same convention for every face, because the normals are used to calculate projections, and comparing them:

  Projection p1 = shape1.project(axis);
  Projection p2 = shape2.project(axis);
  // do the projections overlap?
  if (!p1.overlap(p2)) {

The result of (!p1.overlap(p2)) will be the same with both formulas.

HTH

嘿咻 2024-10-03 17:34:39

法线应始终从边缘指向。只有两种可能的解决方案,您已经想到了。其中一个是对的,另一个是错误的。

哪一种是正确的取决于两件事:

  • 你的边缘是顺时针还是逆时针。
  • 你的协调系统。

The normal should always point out from the edge. There are only two possible solutions, which you figured out. One of them is right and the other is wrong.

Which one is correct depends on two things:

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