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

Using degrees for sin(),cos() and tan() #33

Open
AmirHosein-Gharaati opened this issue Aug 30, 2020 · 4 comments
Open

Using degrees for sin(),cos() and tan() #33

AmirHosein-Gharaati opened this issue Aug 30, 2020 · 4 comments
Labels
documentation Indicates a need for improvements or additions to documentation enhancement Indicates new feature requests

Comments

@AmirHosein-Gharaati
Copy link

Is it possible to use degrees for sin,cos and tan ?

sin(90) = 1

I figured out we can just use radian...

@fkleon fkleon added documentation Indicates a need for improvements or additions to documentation question Indicates that an issue or pull request needs more information labels Aug 31, 2020
@fkleon
Copy link
Owner

fkleon commented Aug 31, 2020

Hi

Correct, as you figured out, it's currently only possible to use radians on all trigonometric functions. I'll update the documentation for the next version to state this explicitly.

Hence you'd have to do the conversion from degree to radians in your application.

While input in degrees could be supported directly in this library (either by introducing a specific degree notation that the parser understands, or a second set of function definitions), I'm not sure there is much value since the conversions are pretty trivial.

@AmirHosein-Gharaati
Copy link
Author

How can I change the parser, to use degrees entirely, instead of radian?

@fkleon
Copy link
Owner

fkleon commented Sep 3, 2020

Three options:

  • Convert the input values to from degrees radians in the parser when constructing trigonometric expression - somewhere around parser.dart#92
  • Convert the input values from degrees to radians in the expression constructors - for example functions.dart#L562
  • Change the trigonometric functions to operate on degrees - however the Dart-internal math functions operate on radians so this would still need conversion

I think the first option is most flexible and could be toggled via a configuration option for the parser.

@fkleon fkleon added enhancement Indicates new feature requests and removed question Indicates that an issue or pull request needs more information labels Sep 3, 2020
@danger-ahead
Copy link

I think the first option is most flexible and could be toggled via a configuration option for the parser.

Went through the codebase. Can you explain in detail how can I achieve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Indicates a need for improvements or additions to documentation enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants