This second video in the cleaner code series talks about magic numbers, and how to avoid them. It also covers naming conventions for function names and binary variables. Use of subfunctions is also shown.
I long ago got in the habit of eliminating sqrt’s from distance computations whenever possible, since the sqrt usually takes longer than computing the square of the distance. In this case, I would compare the sum of squares with r^2.
I long ago got in the habit of eliminating sqrt’s from distance computations whenever possible, since the sqrt usually takes longer than computing the square of the distance. In this case, I would compare the sum of squares with r^2.
Martin,
This is an excellent observation. I am thinking of adding another video in this series that might be able to fit in code optimizations like that.
Thank you,
Doug