On 12/13/08 8:04 AM, "Han-Wen Nienhuys" <hanw...@gmail.com> wrote:
> On Sat, Dec 13, 2008 at 11:48 AM, Reinhold Kainhofer
> <reinh...@kainhofer.com> wrote:
>
>> - -) What's the best way to convert an angle/length pair of polar coordinates
>> (angle given in degree) to cartesian coordinates in scheme / guile? I
>> don't want it as a complex number, but as a pair of reals...
>
> Well, both are equivalent, so I think using complex numbers is
> actually the quickest.
>
But complex numbers need angles in radians, not degrees, so you at least
need to do some conversion.
Here's a new version that uses complex numbers.
(define (polar->rectangular polar-pair)
"Convert @code{polar-pair}, a pair containing (magnitude .
angle-in-degrees)
to (x-length . y-length)"
(let* ((conversion-constant (/ (atan 1 1) 45))
(complex (make-polar
(car polar-pair)
(* conversion-constant (cdr polar-pair)))))
(cons
(real-part complex)
(imag-part complex))))
Carl
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel