剪耳有困难
我遇到的问题是因为我无法识别三角形中凹陷的耳朵和实际上应该被砍掉的耳朵。
如何区分凸三角形和凹三角形?
The problem I have is coming up because I can't identify a a caved in triangle vs an ear that should actually be chopped off.
How can I tell the difference between a convex and a concave triangle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
三角形不能是凹的。你的意思是你的网格是凹的吗?
我没有意识到你在谈论一种特定的技术。经过一些研究后,我想我足以理解你的问题,可以尝试给出答案。
假设您以逆时针顺序遍历多边形的顶点。如果我们按照这个顺序遍历它们,多边形的主体将始终位于左侧。我们正在考虑三个顶点:A、B 和 C。想象一下,我们从 A 穿过 B 射出一条光线。如果C位于该射线的左侧,则这是一个格式良好的三角形,是多边形的一部分。如果C位于该射线的右侧,则它代表负空间。
好的,让我们创建向量 v(即 A → B)和 w(即 B→C)。另外,让我们构造 v',它是 v 但逆时针旋转 90 度。 v' = < -v[y],v[x]>
为了确定C是在v的左边还是右边,我们只需要测量v'和之间的角度>w。如果它在 (0, 90) 或 (270, 360) 范围内,则它在左侧。如果它在 (90, 270) 之内,则它在右侧。这很方便,因为这恰好对应于 cos(θ) > 的位置。 0 且其中 cos(θ) <分别为 0。因此,如果 cos(θ) > 0,则 C 位于左侧,且若 cos(θ) < 0,则C在右边。
我们可以使用点积来帮助我们确定 cos(θ)。请记住 cos(θ) = (v' • w) / (mag(v') ⋅ mag(w em>))。然而,我们实际上并不需要cos(θ),我们只需要sign(cos(θ))。由于 mag(v') 和 mag(w) 必须均为正数,因此我们可以忽略它们。因此,如果v' • w > > 0,则 C 位于左侧,这三个点对应于属于多边形一部分的三角形。另一方面,如果 v' • w v' w v' 0,则C在右边,这三个点对应多边形外的负空间。
除了简单的测试之外,我实际上还没有尝试过这个,但我相信它(或接近它的东西)会起作用。
哦,对于其他人(比如我)从未听说过这种技术,您可以阅读它 在这里。
Triangles can't be concave. Do you mean that your mesh is concave?
I hadn't realized that you were talking about a particular technique. After doing a little research, I think I understand your problem enough to attempt an answer.
Suppose you are traversing your polygon's vertices in a counterclockwise order. If we traverse them in this order, the polygon's body will always be on the left. We are considering three vertices: A, B, and C. Imagine that we shoot a ray out from A through B. If C is to the left of that ray, then this is a well-formed triangle that is part of the polygon. If C is to the right of that ray, then it represents negative space.
OK, so let's create vectors v (which is A → B) and w (which is B → C). Also, let's construct v', which is v but rotated 90 degrees CCW. v' = < -v[y], v[x] >
In order to find out whether C is to the left or right of v, we simply need to measure the angle between v' and w. If it's within (0, 90) or (270, 360), then it's to the left. If it's within (90, 270), then it's to the right. This is handy because this corresponds exactly to where cos(Θ) > 0 and where cos(Θ) < 0, respectively. So, if cos(Θ) > 0, then C is to the left, and if cos(Θ) < 0, then C is to the right.
We can use dot products to help us determine cos(Θ). Remember that cos(Θ) = (v' • w) / (mag(v') ⋅ mag(w)). However, we don't actually need cos(Θ), we only need sign(cos(Θ)). Since mag(v') and mag(w) must both be positive, we can ignore them. Therefore, if v' • w > 0, then C is to the left and the three points correspond to a triangle that is part of the polygon. On the other hand, if v' • w < 0, then C is to the right and the three points correspond to negative space outside the polygon.
I haven't actually tried this beyond simple tests, but I believe that it (or something close to it) will work.
Oh, and for others who (like me) had never heard of this technique, you can read about it here.