| Let's do a full circle. It all began with replacing frequent occurrence of 2π in calls of sin and cos functions with τ. This post suggests an optimisation by getting rid of τ by getting rid of radians. That way one can get rid of frequent and adjacent radians to degrees conversions and back. I say, let's get rid of sin and cos itself ! Of course I am being over the top here. However, if you represent angle not as a scalar in degrees, radians or turns but as a tuple (sin, cos), one can usually dramatically reduce the number of calls to trigonometric functions. Rational polynomials and square root suffices. Recall rotation is a linear transformation with a matrix whose entries are in terms of sin and cosine. As an API it might not be convenient but consider converting angles internally into a tuple of sin and cosine and keep it that way if your code frequently calls trigonometric functions. (Aside: Sometimes I prefer keeping the tuple in terms of half angles. Tan half theta is nice to have. And I am embarrassed by the number of comments I have made on this post) |