(no title)
0xfaded | 1 month ago
As a curiosity, it looks like r and q are only ever used as r/q, and therefore a sqrt could be saved by computing rq = sqrt((rxrx + ryry) / (qxqx + qyqy)). The if q < 1e-10 is also perhaps not necessary, since this would imply that the ellipse is degenerate. My method won't work in that case anyway.
For the other sqrt, maybe try std::hypot
Finally, for your test set, could you had some highly eccentric cases such as a=1 and b=100
Thanks for the investigation:)
Edit: BTW, the sin/cos renormalize trick is the same as what tx,ty are doing. It was pointed out to me by another SO member. My original implementation used trig functions
achille|1 month ago
https://gist.github.com/achille/23680e9100db87565a8e67038797...
0xfaded|1 month ago