Hacker News new | past | comments | ask | show | jobs | submit login

I am curious, what exactly "feq" is calculating?

> return !((x < y) | (x > y));

Is it supposed to avoid x == y. If yes, why?




Also, "length" may have better be implemented using: https://en.cppreference.com/w/c/numeric/math/hypot

It will be helpful, if you add comments discussing why certain functions are implemented in that way, and what algorithms (references) is used. For example, there are some magic numbers without explanation: if (cap < 1000) {

Have you looked at: https://github.com/davideberly/GeometricTools Each algorithm is well documented and explained. There is even a short pdf papers for some of the algorithms explainimg why some decisions are taken and what numerical issues may be expected.


It implements x==y, but it's also true when one of them is a NaN


I understand. You want to work with NaN-s for some reason.


Is the "Natural structure" described in some paper?


It’s a new structure I came up with as described in the docs/POLYGON_INDEXING.md document. https://github.com/tidwall/tg/blob/main/docs/POLYGON_INDEXIN...


I think this might handle NaN differently than == does, I believe the comparisons would always be false with NaN. I’m not sure if that is the intent though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: