法线方向
目前,我有一个程序可以围绕 x 轴旋转一个简单的 2d 多边形来创建 3D 形状。问题是,为了确保曲面的法线正确对齐,我需要找到一个点并确保法线背向该点。我一直使用 2D 多边形的 x 和 y 坐标的平均值来查找参考点。然而,有时这个参考点会产生误导。如果我尝试使用尖锐的凹形形状,参考点完全位于形状之外,这将导致一些侧面具有向内的法线。是否有一种准确的方法来对齐多边形的法线,使它们始终背向多边形?
Currently, I have a program that will revolve a simple 2d polygon around the x-axis to create a 3D shape. The problem is that in order to make sure that the normals for the surfaces are aligned correctly, I need to find a point and make sure that the normal is facing away from that point. I have been using the mean values of the x and y coordinates of the 2D polygon to find the reference point. However, sometimes this reference point is misleading. If I try to use a sharp, concave shape, the reference point lies outside of the shape entirely, which will cause a few of the sides to have inwards-facing normals. Is there an accurate way to align the normals of a polygon so that they are always facing away from it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否希望在旋转之前为多边形的每个面提供 2D 向外法线?在 xy 平面中多边形的右手坐标系中,一条边的向外法线与沿该边指向逆时针方向的向量的叉积将具有正 z 分量。向内法线将具有负 z 分量。 (叉积应该是
正态 × 边
。)Is it right that you want the 2D outward normal for each face of the polygon before the rotation? In a right-handed coordinate system with the polygon in the x-y plane, the cross product of the outward normal of a side with the vector along the side pointing in the counter-clockwise direction will have a positive z component. The inward normal will have a negative z component. (The cross product should be
normal × side
.)