Closed stonylohr closed 10 months ago
All of these changes sound like reasonable improvements to me. :+1:
Having done this change locally.
This will break 2 assertions within geodesics.rs #[test] fn test_std_geodesic_geodsolve84
I believe they are
Instead of the 0.0
they'll return a something like 0.5e-15
, which in practice doesn't change/break the results of the inverse/direct equations, but as it is a broken assertion I guess it should be noted.
I believe these are all covered by #61, but let me know if I'm wrong @stonylohr.
Some changes to consider for geomath::sincosd, starting with the ones that seem most solid.
Calculate "s" and "c" using sin_cos rather than sin and cos: let (s, c) = r.sin_cos();
It should be possible to declare "q" non-mut, and skip the later changes to it, because the initial calculation should already result in the desired value range.
Use native "%" operator instead of fmod.
Consider using "match" rather than "if/else if" when checking "q":
Contrary to what I said in #3, this is a place where I failed to find a clean way around shadowing or an equivalent. It should be possible to remove it if and when support for destructuring assignment is added. I also can't remember whether I confirmed that all my casts to usize are needed, or whether that's just paranoia on my part.
Remove the second round of shadowing for the "s" and "c" variables.
Consider replacing "90.0 q as f64" with "(90 q) as f64" to favor integer math where practical.
Review any possible difference between "(r / 90.0 + (0.5)).floor()" and "(r / 90.0).round()". I think that both are available in C++, and Charles Karney chose to use floor over round. Review should make sure to include both positive and negative boundary cases (like 0.5 and -0.5). Behavior would be my main concern, but also performance.
Review handling of NaN and infinite inputs, to make sure behavior is consistent with other versions of geographiclib.
Consider adding a comment about future use of remquo. The C++ version uses this when available, so I expect it allows some performance improvement. The nagisa crate currently has this on a todo list.
Putting it all together, it might look something like this...