rotatePoint method

CustomPoint<num> rotatePoint(
  1. CustomPoint<num> mapCenter,
  2. CustomPoint<num> point, {
  3. bool counterRotation = true,
})

Implementation

CustomPoint<num> rotatePoint(
    CustomPoint<num> mapCenter, CustomPoint<num> point,
    {bool counterRotation = true}) {
  final counterRotationFactor = counterRotation ? -1 : 1;

  final m = Matrix4.identity()
    ..translate(mapCenter.x.toDouble(), mapCenter.y.toDouble())
    ..rotateZ(rotationRad * counterRotationFactor)
    ..translate(-mapCenter.x.toDouble(), -mapCenter.y.toDouble());

  final tp = MatrixUtils.transformPoint(
      m, Offset(point.x.toDouble(), point.y.toDouble()));

  return CustomPoint(tp.dx, tp.dy);
}