rotate method

CustomPoint<double> rotate(
  1. num radians
)

Create new CustomPoint whose x and y values are rotated by radians in clockwise fashion

Implementation

CustomPoint<double> rotate(num radians) {
  if (radians != 0.0) {
    final cos = math.cos(radians);
    final sin = math.sin(radians);
    final nx = (cos * x) + (sin * y);
    final ny = (cos * y) - (sin * x);

    return CustomPoint<double>(nx, ny);
  }

  return CustomPoint(x.toDouble(), y.toDouble());
}