Good simple function. Any true programmer understands the importance of maintainability and code reuse from a software engineering perspective, espcially when the performance hit is infinitesimal.
5
19 Nov 2009
degrees and radians
Two helper functions, one converts degrees to radians, the other rads to deg.
Duane - yes you are probably correct, the original calculation however was done differently and was shorter. However, the benefit for me personally is two fold - 1) it makes it easier to troubleshoot the code because it's more readable and 2) repetitive calculations are generally best kept as functions which enable you to more easily find and replace them, and avoid mistakes in typing out duplicate code. But everyone has their own preferred way of doing things.
Comment only
21 Aug 2009
degrees and radians
Two helper functions, one converts degrees to radians, the other rads to deg.
How does this save time? Function calling overhead makes this computationally slower than direct multiplication. Typing the function call degrees(theta) is 14 keystrokes whereas 180/pi*theta is only 12 keystrokes. The same is true for typing radians(theta). So how does this save time?
Comment only
13 Aug 2009
degrees and radians
Two helper functions, one converts degrees to radians, the other rads to deg.
Comment only