llnl / llnl/PolyClipper

Wrong computation of first (centroid) moment of Polyhedron

Open
#10 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27
Forks
3
PR merge metrics
No merged PRs in 30d

Description

**For the following Polyhedron, the `centroid` is at `(1.5, 1.5, 1.5)` but instead `PolyClipper` gives `(1.500000, 1.125000, 1.125000)`:**

```
import PolyClipper as pc

dummy_vertex_list = [[0.0, 0.0, 0.0], [3.0, 0.0, 0.0], [0.0, 3.0, 0.0], [3.0, 3.0, 0.0], [0.0, 0.0, 3.0], [3.0, 0.0, 3.0], [0.0, 3.0, 3.0], [3.0, 3.0, 3.0]]
dummy_all_vertex_neighbor_list = [[1, 2, 4], [0, 3, 5], [0, 3, 6], [1, 2, 7], [0, 5, 6], [1, 4, 7], [2, 4, 7], [3, 5, 6]]

polyhedron_vertices = [pc.Vector3d(*coords) for coords in dummy_vertex_list]
poly = pc.Polyhedron()
pc.initializePolyhedron(poly, polyhedron_vertices, dummy_all_vertex_neighbor_list)
print("poly:", poly)
print("moments: ", pc.moments(poly))
```

The output obtained is:
```
('poly:', Polyhedron[Vertex3d[ ( 0 0 0) [1 2 4 ] 1 -1], Vertex3d[ ( 3 0 0) [0 3 5 ] 1 -1], Vertex3d[ ( 0 3 0) [0 3 6 ] 1 -1], Vertex3d[ ( 3 3 0) [1 2 7 ] 1 -1], Vertex3d[ ( 0 0 3) [0 5 6 ] 1 -1], Vertex3d[ ( 3 0 3) [1 4 7 ] 1 -1], Vertex3d[ ( 0 3 3) [2 4 7 ] 1 -1], Vertex3d[ ( 3 3 3) [3 5 6 ] 1 -1]])
('moments: ', (9.0, (1.500000, 1.125000, 1.125000)))
```

**Where am I going wrong? Please help!!**

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the supplied Python reproduction, focusing on initializePolyhedron and pc.moments for the cube vertices and neighbor lists. Compare the returned volume and centroid with the expected cube values; done means the reported centroid is (1.5, 1.5, 1.5) for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.