Minor optimization in reusing `cosD` and `sinD`.