Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Angle unit and remove unused code from Length unit
- Loading branch information
Showing
2 changed files
with
31 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'dart:math'; | ||
|
||
class Angle implements Comparable<Angle> { | ||
/* | ||
* The value of this Angle object in degrees. | ||
*/ | ||
final double _angle; | ||
|
||
///degrees to radians | ||
static const double degree_to_rad = PI / 180.0; | ||
|
||
///radians to degrees | ||
static const double rad_to_degree = 180.0 / PI; | ||
|
||
Angle.fromDegrees({double value : 0.0}): _angle = value; | ||
Angle.fromRadians({double value: 0.0}): _angle = value * rad_to_degree; | ||
|
||
double get inDegrees => _angle; | ||
double get inRadians => _angle * degree_to_rad; | ||
|
||
/** | ||
* Compares this Angle to [other], returning zero if the values are equal. | ||
* | ||
* Returns a negative integer if this `Angle` is shorter than | ||
* [other], or a positive integer if it is longer. | ||
* | ||
* A negative `Angle` is always considered shorter than a positive one. | ||
* | ||
*/ | ||
int compareTo(Angle other) => _angle.compareTo(other._angle); | ||
} |
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