glotzerlab / glotzerlab/coxeter

Some properties and methods are missing from `ConvexSpheroPolygon` and `ConvexSpheroPolyhedron`, but they are shown in the docs

Open
#268 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
25
Forks
5
Avg merge
9m
Merged PRs (30d)
3

Description

Description

The getters and setters for centroid are missing from ConvexSpheroPolygon and ConvexSpheroPolyhedron, but the docs show that they are there:

Additionally, the is_inside() method is shown for both of the above classes, but it is only implemented for ConvexSpheroPolyhedron:

The ConvexSpheroPolyhedron.is_inside() implementation ultimately uses the centroid of the underlying polyhedron, so perhaps implementing centroid for this class could be as simple as

class ConvexSpheroPolyhedron(Shape3D):
    ...
    @property
    def centroid(self):
        return self._polyhedron.centroid
    
    @centroid.setter
    def centroid(self, value):
        self._polyhedron.centroid = value

If it is that easy, perhaps this same approach could be used for ConvexSpheroPolygon?

To reproduce

To see that centroid is missing from ConvexSpheroPolyhedron:

verts = [
    [1, 1, 1], [1, -1, 1], [1, 1, -1], [1, -1, -1],
    [-1, 1, 1], [-1, -1, 1], [-1, 1, -1], [-1, -1, -1]
]
spherocube = coxeter.shapes.ConvexSpheropolyhedron(verts, radius=0.5)
print(spherocube.centroid)
spherocube.centroid = [1,1,1]
print(spherocube.centroid)

and from ConvexSpheroPolygon:

verts = [[-1, 0], [0, 1], [1, 0]]
rounded_tri = coxeter.shapes.ConvexSpheropolygon(verts, radius=.1)
print(rounded_tri.centroid)
rounded_tri.centroid = [1,1]
print(rounded_tri.centroid)

To see that is_inside() is missing from ConvexSpheroPolygon:

verts = [[-1, 0], [0, 1], [1, 0]]
rounded_tri = coxeter.shapes.ConvexSpheropolygon(verts, radius=.1)
print(rounded_tri.is_inside([1,1]))
Error output

Each code block given above throws a NotImplementedError originating from the base class Shape2D or Shape3D. I assume that these classes are why the methods show up in the documentation in the first place.

System configuration

Please complete the following information:

  • Operating System: Windows 10
  • Version of Python: 3.13.3
  • Version of coxeter: 0.10.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting Shape2D, Shape3D, ConvexSpheroPolygon, and ConvexSpheroPolyhedron, then run the reproduction snippets in the issue. Compare the documented centroid and is_inside behavior with the base-class failures; done means both classes expose the documented centroid accessors and is_inside behavior without raising NotImplementedError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.