Skip to content

Instantly share code, notes, and snippets.

@Mason-McGough
Last active June 2, 2021 15:51
Show Gist options
  • Save Mason-McGough/58c1ab01b0ca999e3328a13f999d7f0c to your computer and use it in GitHub Desktop.
Save Mason-McGough/58c1ab01b0ca999e3328a13f999d7f0c to your computer and use it in GitHub Desktop.
MeshCNN: input features
# From models/layers/mesh_conv.py in https://github.com/ranahanocka/MeshCNN
def dihedral_angle(mesh, edge_points):
"""
Angle between two faces connected to edge.
"""
normals_a = get_normals(mesh, edge_points, 0)
normals_b = get_normals(mesh, edge_points, 3)
dot = np.sum(normals_a * normals_b, axis=1).clip(-1, 1)
angles = np.expand_dims(np.pi - np.arccos(dot), axis=0)
return angles
def symmetric_opposite_angles(mesh, edge_points):
"""
Angles of opposite corners across edge.
"""
angles_a = get_opposite_angles(mesh, edge_points, 0)
angles_b = get_opposite_angles(mesh, edge_points, 3)
angles = np.concatenate((np.expand_dims(angles_a, 0), np.expand_dims(angles_b, 0)), axis=0)
angles = np.sort(angles, axis=0)
return angles
def symmetric_ratios(mesh, edge_points):
"""
Height/base ratios of the triangles adjacent to edge.
"""
ratios_a = get_ratios(mesh, edge_points, 0)
ratios_b = get_ratios(mesh, edge_points, 3)
ratios = np.concatenate((np.expand_dims(ratios_a, 0), np.expand_dims(ratios_b, 0)), axis=0)
return np.sort(ratios, axis=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment