Thomas Morley <[email protected]> writes: > 2015-10-07 14:08 GMT+02:00 Thomas Morley <[email protected]>: > >> The code in my initial mail uses coord-rotate (not >> ly:stencil-rotate-absolute as in Jans suggestion) >> What do you think about this method? >> >> Ofcourse it was heavily simplified, maybe best to put up a patch to >> have the full code for more detailed discussion. > > I have to postpone uploading the patch, there are some glitches ... > > And one thing which has driven me crazy, before I found the culprit: > `coord-rotate' has a problem which can be demonstrated with: > > (display (coord-rotate '(10 . 0) (/ PI 2))) > > Expected: (0 . 10) > Actually: (6.12323399573677e-16 . 10.0) > > What's the best method to get the zero?
coord-translate is written awfully (almost any intermediate use of atan is an indicator of unnecessary contortions) but that's not the problem here. The problem is that GUILE stores floating point number as double numbers (64 bits), and the MPU does its calculations, including trigonometry, using long double arithmetic (80 bits on x86). Consequently, there is no representation of PI in GUILE that would lead to the expected results. When angles are represented un GUILE, you are probably indeed best off using degrees rather than radians since small multiples of 45 are exactly representable at any number resolution available to GUILE. The code used in ly:stencil-rotate-absolute looks like it might work (though I'd write (a * (M_PI / 180.0)) rather than (a * M_PI / 180.0)). -- David Kastrup _______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
