Skip to content

Conversation

@revarbat
Copy link
Collaborator

The octagon style of spheroid() was malformed and asymmetrical due to the use of spherical_to_xyz(). This code fixes that.

@revarbat revarbat requested a review from Copilot August 23, 2025 01:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes asymmetry issues in the octagon-style spheroid generation by replacing the original implementation with a new approach that properly handles sphere geometry.

  • Introduces a new _make_octa_sphere() function that creates symmetrical octahedral spheroids
  • Removes the old octagon implementation that relied on spherical_to_xyz() and caused malformation
  • Restructures the spheroid function to handle the octa style separately from other styles
Comments suppressed due to low confidence (1)

shapes3d.scad:3424

  • The variable octa_steps is removed but was used to calculate subdivision levels. The new implementation uses a different calculation (quantup(segs(r),4)/4) which may produce different subdivision behavior, potentially affecting backward compatibility.
        vsides = max(2,ceil(hsides/2)),

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@adrianVmariano
Copy link
Collaborator

adrianVmariano commented Aug 23, 2025

Should we wait for the dust to settle on the OpenSCAD PR so that they match? I haven't been paying close attention to the discussion about the optimization of the sphere.

Also I wonder (haven't looked) how the "octa" sphere works with circum=true and whether it just calls the regular octasphere or also needs updating.

@revarbat
Copy link
Collaborator Author

The circum=true octa sphere basically does hull(_dual_vertices(spheroid(r=r, style="octa",circum=false))), so no update needed for that.

@revarbat
Copy link
Collaborator Author

As for waiting for the final builtin version, that could take years, and the existing implementation in BOSL2 is definitely a bug. This code fixes the asymmetries, even if it is not pixel perfect to the eventual design. We can correct it for an exact match if and when it actually becomes an available thing.

@revarbat
Copy link
Collaborator Author

Also, based on the statistics, this code is slightly better than the proposals so far.

@revarbat
Copy link
Collaborator Author

ECHO: "new octa:"
ECHO: " Face count: 128"
ECHO: " Radius: 1"
ECHO: " Face Area min: 0.0760653"
ECHO: " Face Area max: 0.110289"
ECHO: " Face Area avg: 0.0935639"
ECHO: " Face Area rms: 0.0119409"
ECHO: " Face Area cmc: 0.0129193"
ECHO: " Face Tension min: 0.0337573"
ECHO: " Face Tension max: 0.0436897"
ECHO: " Face Tension avg: 0.0384038"
ECHO: " Face Tension rms: 0.00356386"
ECHO: " Face Tension cmc: 0.0038193"
ECHO: " Edge Length min: 0.390181"
ECHO: " Edge Length max: 0.541196"
ECHO: " Edge Length avg: 0.472324"
ECHO: " Edge Length rms: 0.0535752"
ECHO: " Edge Length cmc: 0.0592344"
ECHO: " Vertex Radii min: 1"
ECHO: " Vertex Radii max: 1"
ECHO: " Vertex Radii avg: 1"
ECHO: " Vertex Radii rms: 4.05396e-17"
ECHO: " Vertex Radii cmc: 5.67183e-17"

@revarbat
Copy link
Collaborator Author

BTW, I've checked the icosa sphere, and it does not appear to have the same flaw.

@adrianVmariano
Copy link
Collaborator

I think that the PR will settle. If you have something better than what's being talked in the PR we should post it there, probably. I'm not saying wait for it to appear in OpenSCAD, but wait for the PR to solidify and then we should match the PR.

@revarbat revarbat merged commit e6a5fb4 into master Sep 1, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants