turf icon indicating copy to clipboard operation
turf copied to clipboard

rhumbBearing returns NaN for certain coordinates

Open jellyedwards opened this issue 1 year ago • 1 comments

Hi, it seems rhumbBearing returns NaN for certain coordinates. I'm not calling this directly but just trying to rotate a polygon & stepped through while debugging. bearing works but transformRotate uses rhumbBearing.

repro code:

const pivot = [0, 91];
const pointCoords = [0, 0];
console.log(turf.rhumbBearing(pivot, pointCoords)); // NaN

Thanks!

jellyedwards avatar Jan 15 '24 10:01 jellyedwards

I found that there is a problem in the calculateRhumbBearing function: when I try to apply rotation with arguments from (pivot) [325, 212.5] and to (pointCoords) [375.5, 313], then phi1 becomes 3.7 and phi2 becomes 5.5, then the logarithm argument in the expression deltaPsi is equal -0.75, i.e. less than zero!

NSUSpray avatar Feb 27 '24 08:02 NSUSpray