getPoint method
Vector?
getPoint(
- num t, [
- Vector? optionalTarget
])
override
Implementation
@override
Vector? getPoint(num t, [Vector? optionalTarget]) {
final point = optionalTarget ?? Vector2();
const twoPi = math.pi * 2;
num deltaAngle = aEndAngle - aStartAngle;
final samePoints = deltaAngle.abs() < MathUtils.epsilon;
// ensures that deltaAngle is 0 .. 2 PI
while (deltaAngle < 0) {
deltaAngle += twoPi;
}
while (deltaAngle > twoPi) {
deltaAngle -= twoPi;
}
if (deltaAngle < MathUtils.epsilon) {
if (samePoints) {
deltaAngle = 0;
} else {
deltaAngle = twoPi;
}
}
if (aClockwise == true && !samePoints) {
if (deltaAngle == twoPi) {
deltaAngle = -twoPi;
} else {
deltaAngle = deltaAngle - twoPi;
}
}
final angle = aStartAngle + t * deltaAngle;
double x = aX + xRadius * math.cos(angle);
double y = aY + yRadius * math.sin(angle);
if (aRotation != 0) {
final cos = math.cos(aRotation);
final sin = math.sin(aRotation);
final tx = x - aX;
final 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.setValues(x, y);
}