Skip to content

Commit

Permalink
Add Angle unit and remove unused code from Length unit
Browse files Browse the repository at this point in the history
  • Loading branch information
yeradis committed Oct 13, 2017
1 parent 858c211 commit f401dbe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
31 changes: 31 additions & 0 deletions lib/src/angle.dart
@@ -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);
}
5 changes: 0 additions & 5 deletions lib/src/length.dart
@@ -1,9 +1,4 @@
import 'dart:math';

class Length implements Comparable<Length> {
/// 1 meter
static const double _one_meter = 0.999999690624;

///meters to kilometers: meters * 10^-3
static const double _m_to_km = 0.001;
/// meters to miles: meters * 6.21371192 * 10^-4
Expand Down

0 comments on commit f401dbe

Please sign in to comment.