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

Annulus sampling #13471

Merged
merged 1 commit into from
May 22, 2024
Merged

Conversation

mweatherley
Copy link
Contributor

Objective

Add random sampling for the Annulus primitive. This is part of ongoing work to bring the various bevy_math primitives to feature parity.

Solution

Annulus implements ShapeSample. Boundary sampling is implemented in the obvious way, and interior sampling works exactly as in the implementation for Circle, using the fact that the square of the radius should be taken uniformly from between r^2 and R^2, where r and R are the inner and outer radii respectively.

Testing

I generated a bunch of random points and rendered them. Here's 1000 points on the interior of the default annulus:
Screenshot 2024-05-22 at 8 01 34 AM

This looks kind of weird around the edges, but I verified that they're all actually inside the annulus, so I assume it has to do with the fact that the rendered circles have some radius.

@alice-i-cecile alice-i-cecile added C-Usability A simple quality-of-life change that makes Bevy easier to use A-Math Fundamental domain-agnostic mathematical operations labels May 22, 2024
@alice-i-cecile alice-i-cecile added X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 22, 2024
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 22, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 22, 2024
Merged via the queue into bevyengine:main with commit 5dbd827 May 22, 2024
34 checks passed
@mweatherley mweatherley deleted the annulus-sampling branch May 22, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Usability A simple quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants