MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / compute_quad_normal

Method compute_quad_normal

src/Attributes/FaceNormalAttribute.cpp:61–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61Vector3F FaceNormalAttribute::compute_quad_normal(Mesh& mesh, size_t i) {
62 const size_t dim = mesh.get_dim();
63 VectorI face = mesh.get_face(i);
64 assert(face.size() == 4);
65
66 Vector3F v[4] = {
67 Vector3F::Zero(),
68 Vector3F::Zero(),
69 Vector3F::Zero(),
70 Vector3F::Zero()
71 };
72
73 v[0].segment(0, dim) = mesh.get_vertex(face[0]);
74 v[1].segment(0, dim) = mesh.get_vertex(face[1]);
75 v[2].segment(0, dim) = mesh.get_vertex(face[2]);
76 v[3].segment(0, dim) = mesh.get_vertex(face[3]);
77
78 Vector3F normal = (v[2] - v[0]).cross(v[3] - v[1]);
79 normal.normalize();
80 return normal;
81}
82

Callers

nothing calls this directly

Calls 5

get_faceMethod · 0.80
normalizeMethod · 0.80
get_dimMethod · 0.45
sizeMethod · 0.45
get_vertexMethod · 0.45

Tested by

no test coverage detected