12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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/interfaces/process/physical_coordinates/physical_coordinate.dart';
- import 'package:flutter/foundation.dart';
- import 'package:vid/us/vid_us_physical_coordinate.dart';
- import 'package:vid/us/vid_us_visual_area_type.dart';
- class ConvexTissuePhysicalCoordinate implements ITissuePhysicalCoordinate {
- late final double _depthStart;
- late final double _depthEnd;
- late final double _width;
- late final double _beamPosition;
- late final double _zeroRadius;
- late final double _zeroY;
- ConvexTissuePhysicalCoordinate(
- VidUsConvexTissuePhysicalCoordinate vidData,
- ) {
- _depthStart = vidData.depthStart;
- _depthEnd = vidData.depthEnd;
- _width = vidData.width;
- _beamPosition = vidData.beamPosition;
- _zeroRadius = vidData.zeroRadius;
- _zeroY = -math.cos((_width / 2) / 180 * math.pi) * _zeroRadius;
- }
- @override
- VidUsVisualAreaType get areaType => VidUsVisualAreaType.Tissue;
- @override
- double get depthEnd => _depthEnd;
- @override
- double get depthStart => _depthStart;
- @override
- double get width => _width;
- @override
- double get beamPosition => _beamPosition;
- /// 可见扇形边到圆点的距离
- double get zeroRadius => _zeroRadius;
- /// 圆心点Y轴位置
- double get zeroY => _zeroY;
- @override
- DPoint convert(DPoint pointInLogical) {
- double depth = math.sqrt(math.pow(pointInLogical.x, 2) +
- math.pow(pointInLogical.y + zeroRadius, 2)) -
- zeroRadius;
- double tilt =
- toDegrees(math.atan2(pointInLogical.x, pointInLogical.y + zeroRadius));
- return DPoint(tilt, depth);
- }
- @override
- DPoint convertBack(DPoint pointInPhysical) {
- int ratio = pointInPhysical.x >= 0 ? 1 : -1;
- var angle = pointInPhysical.x.abs();
- double radian = (math.pi / 180) * angle.abs();
- double x = ratio * math.sin(radian) * (pointInPhysical.y + zeroRadius);
- double y = math.cos(radian) * (pointInPhysical.y + zeroRadius) - zeroRadius;
- return DPoint(x, y);
- }
- @protected
- double toDegrees(double angle) {
- return angle / math.pi * 180;
- }
- }
|