// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'dart:math' as math;
import 'package:fis_measure/interfaces/date_types/point.dart';
import 'package:fis_measure/interfaces/date_types/skew_transform.dart';
import 'package:fis_measure/process/workspace/measure_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('Counter increments smoke test', (WidgetTester tester) async {
    // Build our app and trigger a frame.
  });

  test("linear_tissue", () {
    const steer = 3.0;
    const depthStart = 1.0;
    const depthEnd = 3.99999991059303;
    final back = DSkewTransform(steer, 0, 0, (depthEnd - depthStart) / 2);
    final inverse = back.inverse;
    final p1 = inverse.transform(DPoint(0.84, 0.24907692307692308));
    final p2 = inverse.transform(DPoint(0.84, 0.4989230769230769));
    final d = (p2 - p1).lengthSquared;
    print(p1);
    print(p2);
    print(d);
  });

  test("convex_tissue", () {
    const zeroRadius = 5.1225;
    final logicalPoint = DPoint(1, 1);
    double depth = math.sqrt(math.pow(logicalPoint.x, 2) +
            math.pow(logicalPoint.y + zeroRadius, 2)) -
        zeroRadius;
    double tilt =
        toDegrees(math.atan2(logicalPoint.x, logicalPoint.y + zeroRadius));
    final d = DPoint(tilt, depth);
    print(d);
  });
}

double toDegrees(double angle) {
  return angle / math.pi * 180;
}
