LEFT | RIGHT |
(no file at all) | |
1 ;;;; This file is part of LilyPond, the GNU music typesetter. | 1 ;;;; This file is part of LilyPond, the GNU music typesetter. |
2 ;;;; | 2 ;;;; |
3 ;;;; Copyright (C) 2003--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 3 ;;;; Copyright (C) 2003--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
4 ;;;; | 4 ;;;; |
5 ;;;; LilyPond is free software: you can redistribute it and/or modify | 5 ;;;; LilyPond is free software: you can redistribute it and/or modify |
6 ;;;; it under the terms of the GNU General Public License as published by | 6 ;;;; it under the terms of the GNU General Public License as published by |
7 ;;;; the Free Software Foundation, either version 3 of the License, or | 7 ;;;; the Free Software Foundation, either version 3 of the License, or |
8 ;;;; (at your option) any later version. | 8 ;;;; (at your option) any later version. |
9 ;;;; | 9 ;;;; |
10 ;;;; LilyPond is distributed in the hope that it will be useful, | 10 ;;;; LilyPond is distributed in the hope that it will be useful, |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 start-angle | 317 start-angle |
318 end-angle | 318 end-angle |
319 thick | 319 thick |
320 connect | 320 connect |
321 fill) | 321 fill) |
322 (cons (min-max-crawler min cadr possible-extrema) | 322 (cons (min-max-crawler min cadr possible-extrema) |
323 (min-max-crawler max cadr possible-extrema)) | 323 (min-max-crawler max cadr possible-extrema)) |
324 (cons (min-max-crawler min cddr possible-extrema) | 324 (cons (min-max-crawler min cddr possible-extrema) |
325 (min-max-crawler max cddr possible-extrema))))) | 325 (min-max-crawler max cddr possible-extrema))))) |
326 | 326 |
| 327 (define (line-part-min-max x1 x2) |
| 328 (list (min x1 x2) (max x1 x2))) |
| 329 |
| 330 (define (bezier-part-min-max x1 x2 x3 x4) |
| 331 ((lambda (x) (list (reduce min 10000 x) (reduce max -10000 x))) |
| 332 (map |
| 333 (lambda (x) |
| 334 (+ (* x1 (expt (- 1 x) 3)) |
| 335 (+ (* 3 (* x2 (* (expt (- 1 x) 2) x))) |
| 336 (+ (* 3 (* x3 (* (- 1 x) (expt x 2)))) |
| 337 (* x4 (expt x 3)))))) |
| 338 (if (< (+ (expt x2 2) (+ (expt x3 2) (* x1 x4))) |
| 339 (+ (* x1 x3) (+ (* x2 x4) (* x2 x3)))) |
| 340 (list 0.0 1.0) |
| 341 (filter |
| 342 (lambda (x) (and (>= x 0) (<= x 1))) |
| 343 (append |
| 344 (list 0.0 1.0) |
| 345 (map (lambda (op) |
| 346 (if (not (eqv? 0.0 |
| 347 (exact->inexact (- (+ x1 (* 3 x3)) (+ x4 (*
3 x2)))))) |
| 348 ;; Zeros of the bezier curve |
| 349 (/ (+ (- x1 (* 2 x2)) |
| 350 (op x3 |
| 351 (sqrt (- (+ (expt x2 2) |
| 352 (+ (expt x3 2) (* x1 x4))) |
| 353 (+ (* x1 x3) |
| 354 (+ (* x2 x4) (* x2 x3))))))) |
| 355 (- (+ x1 (* 3 x3)) (+ x4 (* 3 x2)))) |
| 356 ;; Apply L'hopital's rule to get the zeros if 0/0 |
| 357 (* (op 0 1) |
| 358 (/ (/ (- x4 x3) 2) |
| 359 (sqrt (- (+ (* x2 x2) |
| 360 (+ (* x3 x3) (* x1 x4))) |
| 361 (+ (* x1 x3) |
| 362 (+ (* x2 x4) (* x2 x3))))))))) |
| 363 (list + -)))))))) |
| 364 |
| 365 (define (bezier-min-max x1 y1 x2 y2 x3 y3 x4 y4) |
| 366 (map (lambda (x) |
| 367 (apply bezier-part-min-max x)) |
| 368 `((,x1 ,x2 ,x3 ,x4) (,y1 ,y2 ,y3 ,y4)))) |
| 369 |
| 370 (define (line-min-max x1 y1 x2 y2) |
| 371 (map (lambda (x) |
| 372 (apply line-part-min-max x)) |
| 373 `((,x1 ,x2) (,y1 ,y2)))) |
| 374 |
327 (define (path-min-max origin pointlist) | 375 (define (path-min-max origin pointlist) |
328 | |
329 (define (line-part-min-max x1 x2) | |
330 (list (min x1 x2) (max x1 x2))) | |
331 | |
332 (define (bezier-part-min-max x1 x2 x3 x4) | |
333 ((lambda (x) (list (reduce min 10000 x) (reduce max -10000 x))) | |
334 (map | |
335 (lambda (x) | |
336 (+ (* x1 (expt (- 1 x) 3)) | |
337 (+ (* 3 (* x2 (* (expt (- 1 x) 2) x))) | |
338 (+ (* 3 (* x3 (* (- 1 x) (expt x 2)))) | |
339 (* x4 (expt x 3)))))) | |
340 (if (< (+ (expt x2 2) (+ (expt x3 2) (* x1 x4))) | |
341 (+ (* x1 x3) (+ (* x2 x4) (* x2 x3)))) | |
342 (list 0.0 1.0) | |
343 (filter | |
344 (lambda (x) (and (>= x 0) (<= x 1))) | |
345 (append | |
346 (list 0.0 1.0) | |
347 (map (lambda (op) | |
348 (if (not (eqv? 0.0 | |
349 (- (+ x1 (* 3 x3)) (+ x4 (* 3 x2))))) | |
350 ;; Zeros of the bezier curve | |
351 (/ (+ (- x1 (* 2 x2)) | |
352 (op x3 | |
353 (sqrt (- (+ (expt x2 2) | |
354 (+ (expt x3 2) (* x1 x4))) | |
355 (+ (* x1 x3) | |
356 (+ (* x2 x4) (* x2 x3))))))) | |
357 (- (+ x1 (* 3 x3)) (+ x4 (* 3 x2)))) | |
358 ;; Apply L'hopital's rule to get the zeros if 0/0 | |
359 (* (op 0 1) | |
360 (/ (/ (- x4 x3) 2) | |
361 (sqrt (- (+ (* x2 x2) | |
362 (+ (* x3 x3) (* x1 x4))) | |
363 (+ (* x1 x3) | |
364 (+ (* x2 x4) (* x2 x3))))))))) | |
365 (list + -)))))))) | |
366 | |
367 (define (bezier-min-max x1 y1 x2 y2 x3 y3 x4 y4) | |
368 (map (lambda (x) | |
369 (apply bezier-part-min-max x)) | |
370 `((,x1 ,x2 ,x3 ,x4) (,y1 ,y2 ,y3 ,y4)))) | |
371 | |
372 (define (line-min-max x1 y1 x2 y2) | |
373 (map (lambda (x) | |
374 (apply line-part-min-max x)) | |
375 `((,x1 ,x2) (,y1 ,y2)))) | |
376 | 376 |
377 ((lambda (x) | 377 ((lambda (x) |
378 (list | 378 (list |
379 (reduce min +inf.0 (map caar x)) | 379 (reduce min +inf.0 (map caar x)) |
380 (reduce max -inf.0 (map cadar x)) | 380 (reduce max -inf.0 (map cadar x)) |
381 (reduce min +inf.0 (map caadr x)) | 381 (reduce min +inf.0 (map caadr x)) |
382 (reduce max -inf.0 (map cadadr x)))) | 382 (reduce max -inf.0 (map cadadr x)))) |
383 (map (lambda (x) | 383 (map (lambda (x) |
384 (if (eq? (length x) 8) | 384 (if (eq? (length x) 8) |
385 (apply bezier-min-max x) | 385 (apply bezier-min-max x) |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 (begin | 889 (begin |
890 (display (simple-format #f "# Output signature\n# Generated by LilyPond
~a\n" (lilypond-version)) | 890 (display (simple-format #f "# Output signature\n# Generated by LilyPond
~a\n" (lilypond-version)) |
891 output) | 891 output) |
892 (interpret-for-signature found-grob (lambda (x) #f) | 892 (interpret-for-signature found-grob (lambda (x) #f) |
893 (ly:stencil-expr | 893 (ly:stencil-expr |
894 (paper-system-stencil paper-system))))) | 894 (paper-system-stencil paper-system))))) |
895 | 895 |
896 ;; should be superfluous, but leaking "too many open files"? | 896 ;; should be superfluous, but leaking "too many open files"? |
897 (close-port output)) | 897 (close-port output)) |
898 | 898 |
LEFT | RIGHT |