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

Method compute_triangle_normal

src/Attributes/FaceNormalAttribute.cpp:41–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41Vector3F FaceNormalAttribute::compute_triangle_normal(Mesh& mesh, size_t i) {
42 const size_t dim = mesh.get_dim();
43 VectorI face = mesh.get_face(i);
44 assert(face.size() == 3);
45
46 Vector3F v[3] = {
47 Vector3F::Zero(),
48 Vector3F::Zero(),
49 Vector3F::Zero()
50 };
51
52 v[0].segment(0, dim) = mesh.get_vertex(face[0]);
53 v[1].segment(0, dim) = mesh.get_vertex(face[1]);
54 v[2].segment(0, dim) = mesh.get_vertex(face[2]);
55
56 Vector3F normal = (v[1] - v[0]).cross(v[2] - v[0]);
57 normal.normalize();
58 return normal;
59}
60
61Vector3F FaceNormalAttribute::compute_quad_normal(Mesh& mesh, size_t i) {
62 const size_t dim = mesh.get_dim();

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