lilypond-user
[Top][All Lists]

How to calculate visible vertical beam-height

 From: Thomas Morley Subject: How to calculate visible vertical beam-height Date: Sun, 2 Jun 2019 13:30:30 +0200

```Hi,

here a problem which should be solveable, but the math escapes me,
although all values are known, afaict.

Please look at the attached image, the black polygons are created by
the beam-markup-command (slightly changed to make blot-diameter
settable with an override).
The red lines represent the vertical visible height of the beam.
Below the code for the attached image.

I'm interested in a formula how the length of the red line changes
with different blot-diameters.

Any hint is highly appreciated.

Thanks,
Harm

\version "2.19.82"

#(define-markup-command (beam layout props width slope thickness)
(number? number? number?)
#:properties ((blot #f))
(let* ((y (* slope width))
(yext (cons (min 0 y) (max 0 y)))
(half (/ thickness 2)))

(ly:make-stencil
`(polygon ',(list
0 (/ thickness -2)
width (+ (* width slope)  (/ thickness -2))
width (+ (* width slope)  (/ thickness 2))
0 (/ thickness 2))
,(or blot (ly:output-def-lookup layout 'blot-diameter))
#t)
(cons 0 width)
(cons (+ (- half) (car yext))
(+ half (cdr yext))))))

\markup {
\overlay {
\override #'(blot . 0) \beam #5 #1 #2
\translate #'(1 . 0) \with-color #red \draw-line #'(0 . 2)
}

\overlay {
\override #'(blot . 2) \beam #5 #1 #2
\translate #'(2.35 . 0) \with-color #red \draw-line #'(0 . 4.7)
}
}
```

visible-vertical-beam-thick.png
Description: PNG image