getPoint method

  1. @override
dynamic getPoint(
  1. num t,
  2. dynamic optionalTarget
)
override

Implementation

@override
getPoint(t, optionalTarget) {
  var point = optionalTarget ?? Vector2(null, null);

  var twoPi = Math.pi * 2;
  var deltaAngle = aEndAngle - aStartAngle;
  var samePoints = Math.abs(deltaAngle) < Math.epsilon;

  // ensures that deltaAngle is 0 .. 2 PI
  while (deltaAngle < 0) {
    deltaAngle += twoPi;
  }
  while (deltaAngle > twoPi) {
    deltaAngle -= twoPi;
  }

  if (deltaAngle < Math.epsilon) {
    if (samePoints) {
      deltaAngle = 0;
    } else {
      deltaAngle = twoPi;
    }
  }

  if (aClockwise == true && !samePoints) {
    if (deltaAngle == twoPi) {
      deltaAngle = -twoPi;
    } else {
      deltaAngle = deltaAngle - twoPi;
    }
  }

  var angle = aStartAngle + t * deltaAngle;
  var x = aX + xRadius * Math.cos(angle);
  var y = aY + yRadius * Math.sin(angle);

  if (aRotation != 0) {
    var cos = Math.cos(aRotation);
    var sin = Math.sin(aRotation);

    var tx = x - aX;
    var ty = y - aY;

    // Rotate the point about the center of the ellipse.
    x = tx * cos - ty * sin + aX;
    y = tx * sin + ty * cos + aY;
  }

  return point.set(x, y);
}