Creates a Tween for animating Points along a circular arc.
The begin
and end
points are required, cannot be null, and are
immutable.
Source
MaterialPointArcTween({ @required Point begin, @required Point end }) : super(begin: begin, end: end) { assert(begin != null); assert(end != null); // An explanation with a diagram can be found at https://goo.gl/vMSdRg final Offset delta = end - begin; final double deltaX = delta.dx.abs(); final double deltaY = delta.dy.abs(); final double distanceFromAtoB = delta.distance; final Point c = new Point(end.x, begin.y); double sweepAngle() => 2.0 * math.asin(distanceFromAtoB / (2.0 * _radius)); if (deltaX > _kOnAxisDelta && deltaY > _kOnAxisDelta) { if (deltaX < deltaY) { _radius = distanceFromAtoB * distanceFromAtoB / (c - begin).distance / 2.0; _center = new Point(end.x + _radius * (begin.x - end.x).sign, end.y); if (begin.x < end.x) { _beginAngle = sweepAngle() * (begin.y - end.y).sign; _endAngle = 0.0; } else { _beginAngle = math.PI + sweepAngle() * (end.y - begin.y).sign; _endAngle = math.PI; } } else { _radius = distanceFromAtoB * distanceFromAtoB / (c - end).distance / 2.0; _center = new Point(begin.x, begin.y + (end.y - begin.y).sign * _radius); if (begin.y < end.y) { _beginAngle = -math.PI / 2.0; _endAngle = _beginAngle + sweepAngle() * (end.x - begin.x).sign; } else { _beginAngle = math.PI / 2.0; _endAngle = _beginAngle + sweepAngle() * (begin.x - end.x).sign; } } } }