rotatePoint method

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

Implementation

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

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

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

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