mono/xwt — pull request #188 by lytico (2013-04-08 15:19:55+00:00)
Title: correct calculation of quadrant angles

using matrix constants for 90,180,270 rotation:

see: http://en.wikipedia.org/wiki/Rotation_matrix
eg. 90 degree: Math.Cos(90 * Math.PI / 180) calculates 6,12303176911189E-17, but should be 0.

the background of the problem: (quoted from: http://docs.oracle.com/javase/6/docs/api/java/awt/geom/AffineTransform.html)
Since 90 degrees is represented as PI/2 in radians, and since PI is a transcendental (and therefore irrational) number, it is not possible to exactly represent a multiple of 90 degrees as an exact double precision value measured in radians. As a result it is theoretically impossible to describe quadrant rotations (90, 180, 270 or 360 degrees) using these values. Double precision floating point values can get very close to non-zero multiples of PI/2 but never close enough for the sine or cosine to be exactly 0.0, 1.0 or -1.0. The implementations of Math.sin() and Math.cos() correspondingly never return 0.0 for any case other than Math.sin(0.0). These same implementations do, however, return exactly 1.0 and -1.0 for some range of numbers around each multiple of 90 degrees since the correct answer is so close to 1.0 or -1.0 that the double precision significand cannot represent the difference as accurately as it can for numbers that are near 0.0.