-
Notifications
You must be signed in to change notification settings - Fork 207
Description
More of a query than an issue. Does the do...while loop here serve much purpose?
Lines 135 to 142 in 761587c
do { | |
const σi = Math.sinh(e*Math.atanh(e*τi/Math.sqrt(1+τi*τi))); | |
const τiʹ = τi * Math.sqrt(1+σi*σi) - σi * Math.sqrt(1+τi*τi); | |
δτi = (τʹ - τiʹ)/Math.sqrt(1+τiʹ*τiʹ) | |
* (1 + (1-e*e)*τi*τi) / ((1-e*e)*Math.sqrt(1+τi*τi)); | |
τi += δτi; | |
} while (Math.abs(δτi) > 1e-12); // using IEEE 754 δτi -> 0 after 2-3 iterations | |
// note relatively large convergence test as δτi toggles on ±1.12e-16 for eg 31 N 400000 5000000 |
The reason I ask is that I converted the code (UTM <--> Lat/Lon) to embedded C, which works fine apart from this loop. If I take out the loop then I get the correct answer anyways, it appears as though my loop condition is incorrect, and I don't understand enough about what it is doing to change it, I wrote as:
} while(fabs(delTaui) > 1e-12); // using IEEE 754 δτi -> 0 after 2-3 iterations
Where "delTaui" is of type double.
Would it be possible to explain to me the need for this loop? I'm not very mathematically minded but I appreciate things are done for a reason and me just running the loop once and getting the correct answer doesn't mean I always will... I guess it depends on the location?
Many thanks,
Ant