Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Fix face orientations of bar3d #12259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,11 +1733,14 @@ def _generate_normals(self, polygons):
Generate normals for polygons by using the first three points.
This normal of course might not make sense for polygons with
more than three points not lying in a plane.

Normals point towards the viewer for a face with its vertices in
counterclockwise order, following the right hand rule.
'''

normals = []
for verts in polygons:
v1 = np.array(verts[0]) - np.array(verts[1])
v1 = np.array(verts[1]) - np.array(verts[0])
v2 = np.array(verts[2]) - np.array(verts[0])
normals.append(np.cross(v1, v2))
return normals
Expand Down Expand Up @@ -2449,48 +2452,50 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None,
maxz = np.max(z + dz)

# shape (6, 4, 3)
# All faces are oriented facing outwards - when viewed from the
# outside, their vertices are in a counterclockwise ordering.
cuboid = np.array([
# -z
(
(0, 0, 0),
(1, 0, 0),
(0, 1, 0),
(1, 1, 0),
(0, 1, 0)
(1, 0, 0),
),
# +z
(
(0, 0, 1),
(1, 0, 1),
(1, 1, 1),
(0, 1, 1)
(0, 1, 1),
),
# -y
(
(0, 0, 0),
(1, 0, 0),
(1, 0, 1),
(0, 0, 1)
(0, 0, 1),
),
# +y
(
(0, 1, 0),
(1, 1, 0),
(0, 1, 1),
(1, 1, 1),
(0, 1, 1)
(1, 1, 0),
),
# -x
(
(0, 0, 0),
(0, 1, 0),
(0, 0, 1),
(0, 1, 1),
(0, 0, 1)
(0, 1, 0),
),
# +x
(
(1, 0, 0),
(1, 1, 0),
(1, 1, 1),
(1, 0, 1)
(1, 0, 1),
),
])

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.