-
Notifications
You must be signed in to change notification settings - Fork 147
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
Angle type #88
Comments
I've thought about this design in the past (and did an implementation back in Swift 2 that I never published); it would be as-well-as, rather than instead-of, but it's not actually a bad idea. You start to get into weird typing questions if you aggressively go down this path with the trig functions (by analogy, |
Random thought... Having |
I'm also in favor of the I'd be more than happy to help here if needed. Forgive me for asking, but what is the consensus: is the issue still relevant (PR/implementation needed) or is there more discussion required? |
No, not really.
I am not aware of any uses of Gradians, that’s probably the reason.
… On 29 May 2022, at 21:31, mgriebling ***@***.***> wrote:
Is there a reason to ignore Gradians (one hundredth of a right angle)?
—
Reply to this email directly, view it on GitHub <#88 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAHGFVAJWSVTH23OLT535WTVMPAZXANCNFSM4KACTVOQ>.
You are receiving this because you commented.
|
Gradians are a metric version of radians. Probably not used much but handheld calculators always had a "DRG" key which supported degrees, radians, and gradians. Noticed, that Apple's calculator does not support it. |
I wonder if we might rather define our trig functions in terms of an
Angle
type:Browsing SE-0246, this alternative design doesn't seem to have been considered, but I think it would help to make our functions more useful and self-documenting. Depending on what you're doing, it can be more natural to think in terms of degrees rather than radians. In C, people tend to bring these utility functions/macros by themselves, whereas other languages like Java include them as part of the standard library.
The design of the type given above means that creating and consuming an
Angle
in radians in essentially free.Clearly, we cannot make this change to the
ElementaryFunctions
protocol requirements, as we need the conforming type to provide those implementations. However, we can do this for the free functions - either in addition to, or in place of the regular functions which take a<T:ElementaryFunctions>
argument.The text was updated successfully, but these errors were encountered: