Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript

Home Page:https://turfjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rhumbBearing returns NaN for certain coordinates

jellyedwards opened this issue · 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!

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!