mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 08:20:36 +00:00
feat: Add serial compass support #0
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
36
test/widgets/compass_math_test.dart
Normal file
36
test/widgets/compass_math_test.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_sar_app/widgets/map/compass/compass_math.dart';
|
||||
|
||||
void main() {
|
||||
group('compass dial math', () {
|
||||
test('rotates the rose opposite the heading', () {
|
||||
expect(compassRoseRotationRadians(0), closeTo(0, 1e-10));
|
||||
expect(compassRoseRotationRadians(90), closeTo(-pi / 2, 1e-10));
|
||||
expect(compassRoseRotationRadians(450), closeTo(-pi / 2, 1e-10));
|
||||
});
|
||||
|
||||
test('places east at the top when heading east', () {
|
||||
expect(
|
||||
compassDialAngleRadians(markerDegrees: 90, headingDegrees: 90),
|
||||
closeTo(-pi / 2, 1e-10),
|
||||
);
|
||||
expect(
|
||||
compassDialAngleRadians(markerDegrees: 270, headingDegrees: 90),
|
||||
closeTo(pi / 2, 1e-10),
|
||||
);
|
||||
});
|
||||
|
||||
test('places west at the top when heading west', () {
|
||||
expect(
|
||||
compassDialAngleRadians(markerDegrees: 270, headingDegrees: 270),
|
||||
closeTo(-pi / 2, 1e-10),
|
||||
);
|
||||
expect(
|
||||
compassDialAngleRadians(markerDegrees: 90, headingDegrees: 270),
|
||||
closeTo(pi / 2, 1e-10),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user