simple 8 way direction finding algorithm?

Started by
9 comments, last by ifthen 11 years, 4 months ago
Remember that in programming, correctness comes first, readability afterwards and speed the last.

Once you write down a slow but correct algorithm in your function, you can always rewrite it for speed later. If you write a speedy one, yet it fails to handle corner cases, it is useless (and you will spend days trying to find the bug). C(++/other low level languages) is very tricky for beginners: they think that because it is advertised for speed, they have to write fast code with it – otherwise, why would they even bother not using Java?

That is a wrong approach. Code is not "slow" in general, only small segments are (copying large arrays, nested loop on one array...). C can, unlike high-level languages, sometimes speed up bottlenecks that cannot be solved by better algorithm. The other 99% of code are performance-wise unremarkable.

When a lumberjack gets a chainsaw instead of saw, he doesn't swing it so he can chop a tree even faster. He would just cut off his leg.

This topic is closed to new replies.

Advertisement