Hi David, thank you for your suggestions, this is almost done!
I decided to pass an alist to the function instead of changing the amount of arguments based on the procedure name, mainly because if I write more angle functions in the future I want to be able to do so without having to temper with the stencil definition. That is however a useful idea that I would have never thought about, and I may find it useful in the future.
I have a few doubts if you don't mind.
1) At first I couldn't make the alist approach work because for some reason I can't define one in a let or let* block. Do you know why? I googled and I couldn't find an explanation.
2) Is there a way to define an alist different than a succession of acons? I thought I would be able to create it with a syntax like
'((k1 . v1) (k2 . v2) ... etc) but in the end I had to settle for
(acons k1 v1 (acons k2 v2 ... (acons kn vn '()))).
3) I made the following function to make it so that the upper line of the hairpin runs parallel with the staff lines. It does so by finding the angle that is formed between the "zero-point" of the hairpin (the point where it begins to open) and the ending point of the higher hairpin line, that is in (width, height). The function takes into account that the lines of hairpins that go through a system break have different starting and ending heights, this is called "adjusted height" here. With all this in mind, the function finds the angle of the upper line of the hairpin, and returns the negative of that angle, which ideally would result in that angle being 0 degrees, making it so that the upper line is parallel to the staff. But the end result is slightly off (see image). I don't know if the math is wrong or if this problem arises from rounding differences. If it is the later I may need to formulate another approach entirely. Any insight on this?
#(define hairpin-upper-with-staff
(lambda (prop-alist)
(let* ((starth (assq-ref prop-alist 'starth))
(endh (assq-ref prop-alist 'endh))
(width (assq-ref prop-alist 'width))
(adj-hgt (- endh starth))
(def-ang (ly:angle width adj-hgt)) )
(- def-ang))))
Thank you for all the help!!