Skip to content
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

Dual Shapes for Convex Polyhedra #1

Open
bdice opened this issue Apr 11, 2017 · 3 comments
Open

Dual Shapes for Convex Polyhedra #1

bdice opened this issue Apr 11, 2017 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@bdice
Copy link
Member

bdice commented Apr 11, 2017

Original report by RoseCers (Bitbucket: RoseCers, ).


@b-butler
Copy link
Member

@bdice could you flesh this out potentially for the hackathon? I agree that this would be a good feature to have.

@b-butler b-butler added good first issue Good for newcomers enhancement New feature or request and removed minor task labels Nov 14, 2019
@bdice
Copy link
Member Author

bdice commented Nov 16, 2019

@b-butler Here's a starting point. This needs to be tested (with actual tests written) and visually inspected for a few known cases (tetrahedron ↔ tetrahedron, cube ↔ octahedron, dodecahedron ↔ icosahedron). I used the scipy.spatial.HalfspaceIntersection code (see here for docs).

Sample dual generator script

import numpy as np
import scipy.spatial

tetrahedron_vertices = [[0.5, 0.5, 0.5],
                        [-0.5, -0.5, 0.5],
                        [-0.5, 0.5, -0.5],
                        [0.5, -0.5, -0.5]]

hull = scipy.spatial.ConvexHull(tetrahedron_vertices)

print(f'Convex Hull Vertices:\n{hull.points}')
print(f'Convex Hull Volume: {hull.volume}')
print(f'Convex Hull Equations:\n{hull.equations}')

dual = scipy.spatial.HalfspaceIntersection(
    halfspaces=hull.equations, interior_point=np.zeros(3))

print(f'Dual Vertices:\n{dual.dual_points}')
print(f'Dual Surface Area: {dual.dual_area}')
print(f'Dual Volume: {dual.dual_volume}')
print(f'Dual Equations:\n{dual.dual_equations}')
print(f'Dual Facets: {dual.dual_facets}')

Sample dual output

Convex Hull Vertices:
[[ 0.5  0.5  0.5]
 [-0.5 -0.5  0.5]
 [-0.5  0.5 -0.5]
 [ 0.5 -0.5 -0.5]]
Convex Hull Volume: 0.3333333333333334
Convex Hull Equations:
[[-0.57735027  0.57735027  0.57735027 -0.28867513]
 [ 0.57735027 -0.57735027  0.57735027 -0.28867513]
 [-0.57735027 -0.57735027 -0.57735027 -0.28867513]
 [ 0.57735027  0.57735027 -0.57735027 -0.28867513]]
Dual Vertices:
[[-2.  2.  2.]
 [ 2. -2.  2.]
 [-2. -2. -2.]
 [ 2.  2. -2.]]
Dual Surface Area: 55.425625842204084
Dual Volume: 21.33333333333334
Dual Equations:
[[-0.57735027 -0.57735027  0.57735027 -1.15470054]
 [ 0.57735027  0.57735027  0.57735027 -1.15470054]
 [-0.57735027  0.57735027 -0.57735027 -1.15470054]
 [ 0.57735027 -0.57735027 -0.57735027 -1.15470054]]
Dual Facets: [[2, 1, 0], [3, 1, 0], [3, 2, 0], [3, 2, 1]]

Additional references:

@b-butler
Copy link
Member

@bdice thanks!

@janbridley janbridley self-assigned this Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants