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

Use static typing to distinguish between degrees and radians #263

Closed
hannobraun opened this issue Feb 28, 2022 · 2 comments
Closed

Use static typing to distinguish between degrees and radians #263

hannobraun opened this issue Feb 28, 2022 · 2 comments
Labels
good first issue Good for newcomers topic: core Issues relating to core geometry, operations, algorithms type: feature New features and improvements to existing features

Comments

@hannobraun
Copy link
Owner

Angles in the fj library are just represented as floating-point numbers in radians. This is error-prone, as users can assume those are degrees.

I think there should a an Angle type that uses radians internally, but provides constructors (from_deg, from_rad) and accessors (deg, rad) to make working with angles convenient and obvious. This type should also implement the common math operators.

Such a type will probably be useful in the CAD kernel too, so #122 is relevant.

@hannobraun hannobraun added type: feature New features and improvements to existing features topic: model topic: core Issues relating to core geometry, operations, algorithms labels Feb 28, 2022
@hannobraun
Copy link
Owner Author

This is a rather self-contained change that could be a good introduction to the fj crate, so I'm labeling it as https://github.com/hannobraun/Fornjot/labels/good%20first%20issue.

Here's what would need to happen to address this, basically:

  1. Create an Angle struct, basically a wrapper around f64, and add it to the fj crate. Not sure where the best place would be, but just adding it to the root module, or a new angle module would be perfectly acceptable. We can always adjust later.
  2. Add the aforementioned from_deg/from_rad/deg/rad methods. Implementing operators like std::ops::Add/Sub/... would be nice, but can be left for later.
  3. Review the whole API of fj, and use the new Angle type everywhere to represent angles.

Ideally, we'd add an Angle type to fj-math, and just re-export that from fj. But as long as we haven't figured out #122, that's not an option. And in the meantime, doing what I described here is certainly better than the current situation.

@hannobraun hannobraun added the good first issue Good for newcomers label May 11, 2022
@hannobraun
Copy link
Owner Author

Addressed in #619.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers topic: core Issues relating to core geometry, operations, algorithms type: feature New features and improvements to existing features
Projects
None yet
Development

No branches or pull requests

1 participant