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

Allow creation of random Rotation2d #13684

Merged
merged 2 commits into from
Jun 5, 2024

Conversation

mweatherley
Copy link
Contributor

Objective

Fill the gap in this functionality by implementing it for Rotation2d. We have this already for Quat in addition to the direction types.

Solution

bevy_math::sampling now contains an implementation of Distribution<Rotation2d> for Standard, along with the associated convenience implementation Rotation2d: FromRng, which allows syntax like this for creating a random rotation:

// With `FromRng`:
let rotation = Rotation2d::from_rng(rng);
// With `rand::random`:
let another_rotation: Rotation2d = random();
// With `Rng::gen`:
let yet_another_rotation: Rotation2d = rng.gen();

I also cleaned up the documentation a little bit, seeding the Rngs instead of building them from entropy, along with adding a handful of inline directives.

@alice-i-cecile alice-i-cecile added this to the 0.14 milestone Jun 5, 2024
@mweatherley mweatherley added C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy A-Math Fundamental domain-agnostic mathematical operations X-Uncontroversial This work is generally agreed upon S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 5, 2024
Copy link
Contributor

@Olle-Lukowski Olle-Lukowski left a comment

Choose a reason for hiding this comment

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

Looks good!

@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 Jun 5, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 5, 2024
Merged via the queue into bevyengine:main with commit 38d3833 Jun 5, 2024
34 checks passed
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-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy 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.

4 participants