-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, there was three subclasses of `Angle`: - `Degree` - `Radian` - `Hour` This was not a good approach for the universal notion of what an angle is. The same angle should not be represented by two different objects depending on their unit. Now, only `Angle` remains. An angle is always stored with a radian unit, as it is the unit of angle in the International System of Units. Converting an angle is not about changing its type anymore, but only converting its value from one unit to another. The value is nos accessible through the unit name: ```rb angle = Astronoby::Angle.as_degrees(180) angle.degrees # => 0.18e3 angle.radians # => 0.31415926... ``` Because angles in degrees and hours are immediately converted, some precision is immediately lost. However, the conversion is done with BigDecimal numbers with a precision of 14. I believe this is more than enough affordable precision loss for this project. The reader may notice some test values has changed. Because I took the opportunity to remove the `ceil` method on the angle initialization, precision has actually increased. This change is barely noticeable because it affects far digits of the arc second. In the future, I will conduct performance tests to figure out if ceiling angles increase the library overall performance and speed of calculations. Angles can still be initialized from different units with the following class methods: - `::as_degrees` - `::as_radians` - `::as_hours` String formatting has also changed and can be done immediately on the angle without the need to convert it to another unit before: ```rb angle = Astronoby::Angle.as_degrees(180) angle.str(:dms) ``` I will work on making `Angle` a better value object in the future, to make its use even more convenient and efficient. Thanks to @JoelQ for inspiring me into this work.
- Loading branch information
1 parent
6d5fd3a
commit f6748c1
Showing
39 changed files
with
326 additions
and
585 deletions.
There are no files selected for viewing
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.