计算 3D 空间中单个三角形的法线 [英] Calculate normal of a single triangle in 3D space

查看:43
本文介绍了计算 3D 空间中单个三角形的法线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在上图形编程课,我正在做书面作业,而不是编程,所以我希望这适合本网站.我有这个问题:

I am in a graphics programming class and I am doing the written homework, not programming, so I hope this is appropriate for this site. I have this problem:

计算每个指定的三角形的单位法线以下顶点集(假设三角形背对起源):

Compute the unit normal for the triangles specified by each of the following vertex sets (assume the triangles are facing away from the origin):

一年多前我学了线性代数,然后我的老师说他不会教交叉乘积,因为只有班上的计算机科学人员需要它,并且在他们需要时会被覆盖(它不是因为他们假设线性代数老师做到了),我已经检查了两打解释,它们都让我无法理解.

I took linear algebra over a year ago, my teacher then said that he wouldn't teach cross products because only the Computer Science people in the class would need it and it would be covered when they needed it (it wasn't because they assumed the linear algebra teacher did it), and I have checked two dozen explanations and they are all way over my head.

这个问题包含三个不同的问题,所以如果有人能告诉我如何解决一个不涉及大量变量和希腊字母的问题,我将不胜感激.

This problem has three different problems within it, so if someone could walk me through how to solve a single one that didn't involve tons of variables and Greek letters it would be greatly appreciated.

这个问题的A部分有这三个坐标作为三角形的点:[1, 1, 1];[1, -1, 1];[1, 0, -1].我尝试将不同的公式和解释拼凑在一起,我得到法向量是 [4, 0, 0],但这似乎不对,因为我知道的足够多,知道这个三角形不在 y-z 平面上.我唯一的另一件事是公式:

Part A of this problem has these three coordinates as the points of the triangle: [1, 1, 1]; [1, -1, 1]; [1, 0, -1]. I tried cobbling together different formulas and explanations and I got that the normal vector is [4, 0, 0], but that doesn't seem right since I know enough to know that this triangle doesn't lie on the y-z plane. The only other thing I have is the formula:

(A x B) / | A x B |

我知道 A 和 B 是表示为向量的三角形的两个随机边,并通过减去 A 的 V2 和 V1 和 B 的 V3 和 V1 来计算,但我不明白它到底在告诉我什么做.

I know that A and B are two random sides of the triangle represented as a vector, and calculated by subtracting V2 and V1 for A and V3 and V1 for B, but I don't understand what exactly it is telling me to do.

推荐答案

引用自 https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal

三角形的表面法线可以通过取三角形的两条边的矢量叉积来计算.计算中使用的顶点的顺序将影响法线的方向(进入或离开面 w.r.t. 绕组).

A surface normal for a triangle can be calculated by taking the vector cross product of two edges of that triangle. The order of the vertices used in the calculation will affect the direction of the normal (in or out of the face w.r.t. winding).

所以对于三角形p1, p2, p3,如果向量A = p2 - p1 和向量B = p3 - p1那么正常的 N = A x B 可以通过以下方式计算:

So for a triangle p1, p2, p3, if the vector A = p2 - p1 and the vector B = p3 - p1 then the normal N = A x B and can be calculated by:

Nx = Ay * Bz - Az * By
Ny = Az * Bx - Ax * Bz
Nz = Ax * By - Ay * Bx

这篇关于计算 3D 空间中单个三角形的法线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆