rotate method

ExpressivePoint rotate(
  1. double degrees, {
  2. ExpressivePoint center = ExpressivePoint.zero,
})

This point turned by degrees about center.

Implementation

ExpressivePoint rotate(
  double degrees, {
  ExpressivePoint center = ExpressivePoint.zero,
}) {
  final radians = degrees * math.pi / 180;
  final off = this - center;
  final cos = math.cos(radians);
  final sin = math.sin(radians);
  return ExpressivePoint(
        off.x * cos - off.y * sin,
        off.x * sin + off.y * cos,
      ) +
      center;
}