Skip to content

Commit

Permalink
Merge bfe70a2 into 1e1c3a7
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Sep 16, 2021
2 parents 1e1c3a7 + bfe70a2 commit aafcd4a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ladybug_geometry/geometry3d/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,14 @@ def _quad_centroid(verts):
_tri_c = [Mesh3D._tri_centroid(tri) for tri in _tri_verts]
_tri_a = [Mesh3D._get_tri_area(tri) for tri in _tri_verts]
_tot_a = sum(_tri_a)
_cent_x = (_tri_c[0].x * _tri_a[0] + _tri_c[1].x * _tri_a[1]) / _tot_a
_cent_y = (_tri_c[0].y * _tri_a[0] + _tri_c[1].y * _tri_a[1]) / _tot_a
_cent_z = (_tri_c[0].z * _tri_a[0] + _tri_c[1].z * _tri_a[1]) / _tot_a
try:
_cent_x = (_tri_c[0].x * _tri_a[0] + _tri_c[1].x * _tri_a[1]) / _tot_a
_cent_y = (_tri_c[0].y * _tri_a[0] + _tri_c[1].y * _tri_a[1]) / _tot_a
_cent_z = (_tri_c[0].z * _tri_a[0] + _tri_c[1].z * _tri_a[1]) / _tot_a
except ZeroDivisionError:
_cent_x = sum([v.x for v in verts]) / 4
_cent_y = sum([v.y for v in verts]) / 4
_cent_z = sum([v.z for v in verts]) / 4
return Point3D(_cent_x, _cent_y, _cent_z)

@staticmethod
Expand Down

0 comments on commit aafcd4a

Please sign in to comment.