Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>cos(270°) = 0 (parent)

I don't know of a language (but I don't know many) which trigonometric functions use degrees and not radians. In radians and finite precision, "cos(x) = 0" is false for all x (unless your cos is wrong), thanks to Pi being irrational (for example, cos(Pi_in_f64) is about 6.123233995736766E-17). You have "sin(0) = 0" though.

>angle = arctan(dy/dx) where dx=0.

If dy != 0, dy/0.0 is +-Infinity (if following IEEE754), so angle is +-Pi/2.

Coordinates/physics is among the things I see developers get wrong the most (even excluding units issues), along with threading/locks and instances_ownership/pooling.

Data races and deadlocks issues can be rare, and leaks get fixed by a restart, but these coordinates issues can introduce constant errors and biases often overlooked by tests (in addition to almost systematically unhandled cornercases like these).



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

Search: