|
From: | BB |
Subject: | Re: How to get X/Y-extent of a bezier-curve? |
Date: | Tue, 6 Oct 2015 15:15:48 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
I do not really understand what you desire to get. May be my
response is not helpful but silly. #(define pts-list '((12 . 8) (5 . 8) (2 . 2) (15 . 2)))In your List you have the start point defined with ay (x.y)= (2,2) and the end point (15,2) - that is the last pair of coordinates. Looks like I need to calculate the actual X/Y-extents of the resulting bezier-curve.The x extent of your curve therefore is 15-2 = 13. The y extent is harder to calculate as it depends on the parameters of the bezier definition. A good description is here: http://www.math.ucla.edu/~baker/149.1.02w/handouts/bb_bezier.pdf The line override does nothing? \override #'(box-padding . 0)If you set (0,0) instead of (2.2) the starting point is at (0.0) and this is the rotation center. (You rotate in your example around this point.) Then you have to change the last corrdinate pair to (13,0) for to get the seme base length and to stay in the box. The first coordinate pair of the definition in #(define pts-listcontrols the steepness of the start and end of the curve and the form, please see the link above for details. May be I missed the point? Regards On 06.10.2015 13:37, Thomas Morley
wrote:
Hi all, I'm going to write a generic bow-stencil. Below you'll find a boiled down example. The main problem: how to determine the correct extents. Looks like I need to calculate the actual X/Y-extents of the resulting bezier-curve. Though, obviously my maths-skills are not sufficient. Any hints? \version "2.18.2" %% `overlay' is in the source for 2.19.28 %% for lower versions use: #(define-markup-command (overlay layout props args) (markup-list?) (apply ly:stencil-add (interpret-markup-list layout props args))) #(define (make-simple-bezier-stencil coords) (let* ((command-list `(moveto ,(car (list-ref coords 3)) ,(cdr (list-ref coords 3)) curveto ,(car (list-ref coords 0)) ,(cdr (list-ref coords 0)) ,(car (list-ref coords 1)) ,(cdr (list-ref coords 1)) ,(car (list-ref coords 2)) ,(cdr (list-ref coords 2)) ))) (ly:make-stencil `(path 0.1 `(,@' ,command-list) 'round 'round #f) ;;;; TODO ;;;; How to get correct extents? ;; xext: (cons (car (list-ref coords 2)) (car (list-ref coords 3))) ;;yext: (cons (cdr (list-ref coords 2)) (cdr (list-ref coords 1))) ))) %%%%%%%%%%%%%%%%% %% EXAMPLE %%%%%%%%%%%%%%%%% #(define pts-list '((12 . 8) (5 . 8) (2 . 2) (15 . 2))) #(define (rotated-pts-list degree) (map (lambda (c) ;;;; TODO ;; coord-rotate rotates around '(0 . 0) ;; make it generic (coord-rotate c (degrees->radians degree))) pts-list)) \markup \column { \vspace #3 \fill-line { \overlay { \circle \null %% representing point '(0 . 0) \override #'(box-padding . 0) \box \with-color #red { \stencil #(make-simple-bezier-stencil pts-list) \stencil #(make-simple-bezier-stencil (rotated-pts-list 90)) \stencil #(make-simple-bezier-stencil (rotated-pts-list 60)) } } } } Cheers, Harm _______________________________________________ lilypond-user mailing list address@hidden https://lists.gnu.org/mailman/listinfo/lilypond-user |
[Prev in Thread] | Current Thread | [Next in Thread] |