-
Notifications
You must be signed in to change notification settings - Fork 158
Closed
Description
If you try to project angles outside the range [–3π, 3π], it can result in wonky artifacts from resampling:
Here is the current code for forwardRotationLambda
https://github.com/d3/d3-geo/blob/v3.0.1/src/rotation.js#L17-L21
function forwardRotationLambda(deltaLambda) {
return function(lambda, phi) {
return lambda += deltaLambda, [lambda > pi ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
};
}
My proposed alternative is:
function forwardRotationLambda(deltaLambda) {
return function(lambda, phi) {
lambda += deltaLambda;
while (lambda > pi) lambda -= tau;
while (lambda < -pi) lambda += tau;
return [lambda, phi];
};
}
This should run at the same speed, and in my opinion is also a bit more legible.
Metadata
Metadata
Assignees
Labels
No labels