mcneel / rhinocommon

RhinoCommon is the .NET SDK for Rhino5 / Grasshopper
http://wiki.mcneel.com/developer/rhinocommon
242 stars 93 forks source link

Vertex Normals #145

Closed dbrandt7 closed 11 years ago

dbrandt7 commented 11 years ago

I was wondering why there are two vertex normals when a vertex is located ate the edge of an object:

image

The picture above shows the edge of a cylinder. I used RhinoCommons to display each vertex normal in the MeshVertexNormalList for the cylinder as a line. The orange normals are connected to vertex (5.137191, -1.861576, 2.310387). The normal facing to the right is (0.9751439, 0.2215725, 0). The normal facing up is (0,0,1). They are not stored consecutively in the array.

I would like to get the averaged normal, so I was thinking about storing all the normals using a hash table, the vertex being the index, and then taking the average of the normals. Is that a good way to do it, or is there a function that Rhino has that already does that for me?

Thanks, DB

dalefugier commented 11 years ago

Hi DB,

Your mesh is unwelded - it has coincident vertices.

If you get the mesh's topological vertices, you can quickly get the coincident vertices and their normal, and the calculate the average if you need.

-- Dale

dbrandt7 commented 11 years ago

Thanks! Great suggestion! I ended up using the MeshVertexIndices method in the MeshTopologyVertexList class. It was simple to grab the nornals and average them from there.