Add rad and deg conversion fn

This commit is contained in:
Ming Ming 2022-08-20 19:10:33 +08:00
parent 610bf688a0
commit 3c2d12d343
2 changed files with 20 additions and 0 deletions

5
app/lib/math_util.dart Normal file
View file

@ -0,0 +1,5 @@
import 'dart:math' as math;
double degToRad(num deg) => deg * (math.pi / 180);
double radToDeg(num rad) => rad * (180 / math.pi);

View file

@ -0,0 +1,15 @@
import 'dart:math' as math;
import 'package:nc_photos/math_util.dart' as math_util;
import 'package:test/test.dart';
void main() {
group("math_util", () {
test("degToRad", () {
expect(math_util.degToRad(90), closeTo(1.570796, 1e-6));
});
test("radToDeg", () {
expect(math_util.radToDeg(math.pi), 180);
});
});
}