简体   繁体   中英

Calculate normal of a single triangle in 3D space

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.

Part A of this problem has these three coordinates as the points of the triangle: [1, 1, 1]; [1, -1, 1]; [1, 0, -1] [1, 1, 1]; [1, -1, 1]; [1, 0, -1] [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 yz plane. The only other thing I have is the formula:

(A x B) / | A x B |

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.

Quoting from https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal

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 wrt winding).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM