Calculation of normals and windings

For a convex polyhedron with defined vertices (x, y, z), which defines the faces of the polyhedron.

How can I calculate the normal surface level of each surface of a polyhedron?

I need a normal surface to calculate the normal vertex to perform the Gouraud shading . The only clue I could find on how to do this is the Newell method, but how can I make sure that normals are external normals, not internal ones? Thanks for any help.

+4
source share
2 answers

Calculate ordinary face

, , . ( ) . , .

x0, x1, x2 - ,

vector3 get_normal(vector3 x0, vector3 x1, vector3 x2)
{
    vector3 v0 = x0 - x2;
    vector3 v1 = x1 - x2;
    vector3 n = cross(v0, v1);

    return normalize(n);
}

, :

, ' u v , , u, , v u. (u, v).

/ , , , (CCW) (CW). ​​ .

, , x3 - , .

| x0.x  x0.y  x0.z  1 |
| x1.x  x1.y  x1.z  1 |
| x2.x  x2.y  x2.z  1 |
| x3.x  x3.y  x3.z  1 |
  • > 0: x3 + , CCW { x0, x1, x2 }
  • < 0: x3 - , CCW { x0, x1, x2 }
  • = 0: x3 { x0, x1, x2 }

( ) . , { x0, x1, x2 } , { x2, x0, x1 } { x1, x2, x0 }.

, , . , { x0, x1, x2 } { x1, x0, x2 }.

, : , . , .

+4

, (bary) C . , . , , V-C, V - ; , ( ) , .

+1

Source: https://habr.com/ru/post/1660015/


All Articles