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

Regular polygon confusing alignment behavior #781

Closed
erooke opened this issue Nov 12, 2024 · 2 comments
Closed

Regular polygon confusing alignment behavior #781

erooke opened this issue Nov 12, 2024 · 2 comments

Comments

@erooke
Copy link
Contributor

erooke commented Nov 12, 2024

The alignment behavior for RegularPolygon seems to be different than for other objects. From what I can see most objects get aligned by bounding box. However if you ask for RegularPolygon to be centered it gets aligned according to the circumscribed circle.

The left image is what happens if you give align = Align.CENTER while the right is what would normally happen.
image

Is this intended? The docs do not mention this but there are tests enforcing this behavior:

def test_regular_polygon_matches_polar(self):
for side_count in range(3, 10):
with BuildSketch():
regular_poly = RegularPolygon(1, side_count)
poly_pts = [Vector(v) for v in regular_poly.vertices()]
polar_pts = [p.position for p in PolarLocations(1, side_count)]
for poly_pt, polar_pt in zip(poly_pts, polar_pts):
self.assertTupleAlmostEquals(poly_pt.to_tuple(), polar_pt.to_tuple(), 5)

edit: this test is enforcing this behavior as the default arg for align is (Align.CENTER, Align.CENTER)

@jdegenstein
Copy link
Collaborator

This is intentional behavior and we are unlikely to change it. This is documented on this page of the docs, including one example specifically for triangles. https://build123d.readthedocs.io/en/latest/center.html

As mentioned on that page, there is even an enum to control this: CenterOf.

@erooke
Copy link
Contributor Author

erooke commented Nov 13, 2024

Fair enough, dunno how I missed that page in the docs.

@erooke erooke closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants