lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get X/Y-extent of a bezier-curve?


From: David Kastrup
Subject: Re: How to get X/Y-extent of a bezier-curve?
Date: Fri, 09 Oct 2015 08:20:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> 2015-10-07 14:08 GMT+02:00 Thomas Morley <address@hidden>:
>
>> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]