-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Use minor and major radii for Torus
primitive shape
#10643
Merged
alice-i-cecile
merged 12 commits into
bevyengine:main
from
Jondolf:torus-representation
Nov 21, 2023
Merged
Use minor and major radii for Torus
primitive shape
#10643
alice-i-cecile
merged 12 commits into
bevyengine:main
from
Jondolf:torus-representation
Nov 21, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jondolf
added
C-Feature
A new feature, making something new possible
A-Math
Fundamental domain-agnostic mathematical operations
labels
Nov 19, 2023
Jondolf
changed the title
Use minor and major radii for
Use minor and major radii for Nov 19, 2023
Torus
shape representationTorus
primitive shape representation
Jondolf
changed the title
Use minor and major radii for
Use minor and major radii for Nov 19, 2023
Torus
primitive shape representationTorus
primitive shape
Jondolf
commented
Nov 19, 2023
1 task
alice-i-cecile
added
C-Docs
An addition or correction to our documentation
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
and removed
C-Feature
A new feature, making something new possible
labels
Nov 19, 2023
alice-i-cecile
approved these changes
Nov 19, 2023
MrGVSV
reviewed
Nov 19, 2023
IQuick143
reviewed
Nov 19, 2023
@NiseVoid, could I get your review? |
MrGVSV
approved these changes
Nov 19, 2023
alice-i-cecile
approved these changes
Nov 19, 2023
IQuick143
approved these changes
Nov 20, 2023
alice-i-cecile
added
the
S-Ready-For-Final-Review
This PR has been approved by the community. It's ready for a maintainer to consider merging it
label
Nov 20, 2023
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Nov 21, 2023
rdrpenguin04
pushed a commit
to rdrpenguin04/bevy
that referenced
this pull request
Jan 9, 2024
# Objective First, some terminology: - **Minor radius**: The radius of the tube of a torus, i.e. the "half-thickness" - **Major radius**: The distance from the center of the tube to the center of the torus - **Inner radius**: The radius of the hole (if it exists), `major_radius - minor_radius` - **Outer radius**: The radius of the overall shape, `major_radius + minor_radius` - **Ring torus**: The familiar donut shape with a hole in the center, `major_radius > minor_radius` - **Horn torus**: A torus that doesn't have a hole but also isn't self-intersecting, `major_radius == minor_radius` - **Spindle torus**: A self-intersecting torus, `major_radius < minor_radius` Different tori from [Wikipedia](https://en.wikipedia.org/wiki/Torus), where *R* is the major radius and *r* is the minor radius: ![kuva](https://github.com/bevyengine/bevy/assets/57632562/53ead786-2402-43a7-ae8a-5720e6e54dcc) Currently, Bevy's torus is represented by a `radius` and `ring_radius`. I believe these correspond to the outer radius and minor radius, but they are rather confusing and inconsistent names, and they make the assumption that the torus always has a ring. I also couldn't find any other big engines using this representation; [Godot](https://docs.godotengine.org/en/stable/classes/class_torusmesh.html) and [Unity ProBuilder](https://docs.unity3d.com/Packages/com.unity.probuilder@4.0/manual/Torus.html) use the inner and outer radii, while [Unreal](https://docs.unrealengine.com/5.3/en-US/BlueprintAPI/GeometryScript/Primitives/AppendTorus/) uses the minor and major radii. [Blender](https://docs.blender.org/manual/en/latest/modeling/meshes/primitives.html#torus) supports both, but defaults to minor/major. Bevy's `Torus` primitive should have an efficient, consistent, clear and flexible representation, and the current `radius` and `ring_radius` properties are not ideal for that. ## Solution Change `Torus` to be represented by a `minor_radius` and `major_radius`. - Mathematically correct and consistent - Flexible, not restricted to ring tori - Computations and conversions are efficient - `inner_radius = major_radius - minor_radius` - `outer_radius = major_radius + minor_radius` - Mathematical formulae for things like area and volume rely on the minor and major radii, no conversion needed Perhaps the primary issue with this representation is that "minor radius" and "major radius" are rather mathematical, and an inner/outer radius can be more intuitive in some cases. However, this can be mitigated with constructors and helpers.
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-Docs
An addition or correction to our documentation
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
S-Ready-For-Final-Review
This PR has been approved by the community. It's ready for a maintainer to consider merging it
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
First, some terminology:
major_radius - minor_radius
major_radius + minor_radius
major_radius > minor_radius
major_radius == minor_radius
major_radius < minor_radius
Different tori from Wikipedia, where R is the major radius and r is the minor radius:
Currently, Bevy's torus is represented by a
radius
andring_radius
. I believe these correspond to the outer radius and minor radius, but they are rather confusing and inconsistent names, and they make the assumption that the torus always has a ring.I also couldn't find any other big engines using this representation; Godot and Unity ProBuilder use the inner and outer radii, while Unreal uses the minor and major radii. Blender supports both, but defaults to minor/major.
Bevy's
Torus
primitive should have an efficient, consistent, clear and flexible representation, and the currentradius
andring_radius
properties are not ideal for that.Solution
Change
Torus
to be represented by aminor_radius
andmajor_radius
.inner_radius = major_radius - minor_radius
outer_radius = major_radius + minor_radius
Perhaps the primary issue with this representation is that "minor radius" and "major radius" are rather mathematical, and an inner/outer radius can be more intuitive in some cases. However, this can be mitigated with constructors and helpers.