convex_tissue.dart 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import 'dart:math' as math;
  2. import 'package:fis_measure/interfaces/date_types/point.dart';
  3. import 'package:fis_measure/interfaces/date_types/skew_transform.dart';
  4. import 'package:fis_measure/interfaces/process/physical_coordinates/physical_coordinate.dart';
  5. import 'package:flutter/foundation.dart';
  6. import 'package:vid/us/vid_us_visual_area_type.dart';
  7. class ConvexTissuePhysicalCoordinate implements ITissuePhysicalCoordinate {
  8. late final double _depthStart;
  9. late final double _depthEnd;
  10. late final double _width;
  11. late final double _beamPosition;
  12. late final double _zeroRadius;
  13. ConvexTissuePhysicalCoordinate(
  14. double depthStart,
  15. double depthEnd,
  16. double width,
  17. double beamPosition,
  18. double zeroRadius,
  19. ) {
  20. _depthStart = depthStart;
  21. _depthEnd = depthEnd;
  22. _width = width;
  23. _beamPosition = beamPosition;
  24. _zeroRadius = zeroRadius;
  25. }
  26. @override
  27. VidUsVisualAreaType get areaType => VidUsVisualAreaType.Tissue;
  28. @override
  29. double get depthEnd => _depthEnd;
  30. @override
  31. double get depthStart => _depthStart;
  32. @override
  33. double get width => _width;
  34. @override
  35. double get beamPosition => _beamPosition;
  36. /// 可见扇形边到圆点的距离
  37. double get zeroRadius => _zeroRadius;
  38. @override
  39. DPoint convert(DPoint pointInLogical) {
  40. double depth = math.sqrt(math.pow(pointInLogical.x, 2) +
  41. math.pow(pointInLogical.y + zeroRadius, 2)) -
  42. zeroRadius;
  43. double tilt =
  44. toDegrees(math.atan2(pointInLogical.x, pointInLogical.y + zeroRadius));
  45. return DPoint(tilt, depth);
  46. }
  47. @override
  48. DPoint convertBack(DPoint pointInPhysical) {
  49. int ratio = pointInPhysical.x >= 0 ? 1 : -1;
  50. var angle = pointInPhysical.x.abs();
  51. double radian = (math.pi / 180) * angle.abs();
  52. double x = ratio * math.sin(radian) * (pointInPhysical.y + zeroRadius);
  53. double y = math.cos(radian) * (pointInPhysical.y + zeroRadius) - zeroRadius;
  54. return DPoint(x, y);
  55. }
  56. @protected
  57. double toDegrees(double angle) {
  58. return angle / math.pi * 180;
  59. }
  60. }