lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What to do wanting a 4th order Bézier?


From: Urs Liska
Subject: Re: What to do wanting a 4th order Bézier?
Date: Mon, 19 Sep 2016 15:41:08 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

One further iteration. Please let me know what you think of the interface:

-\compoundSlur \with {
  % offsets against the automatic control points
  offsets =       
  #'((0 . -1.5)   ; left starting point
      (-2 . -1)   ; second control point
      (2 . -5)    ; second-to-last control point
      (0 . 0))    % right end point

  inflection-ratio =
  #'(0.6 . 0.65)  % X/Y ratio of the inflection point
                  % calculated between the actual end points of the slur
                  % defaults to the center

  % Slope of the line around the inflection point
  % defaults to 1/1
  inflection-slope = 5/3

  % length of the "handles" around the inflection
  % given as a ratio to the left or right baseline
  % (distance between inflection point and slur's end point).
  % If not given they default to the length of the respective handle
  % on the left or right side
  inflection-ratio-right = 0.5
  inflection-ratio-left = 0.25
  
  % Display control points
  ann = ##t         
}

Of course one could use a list of unnamed arguments or an alist instead of the \with {} clause (I just happen to like them). I have spiced up the "annotation" even more compared to the last version (prints the original slur and its control points in light gray in the background), and I have the impression this approach to defining the inflection point is quite natural, but I'm open to discussion.

One thing that is still missing from my personal wish list is a flag to make the center symmetric again.

Urs


Am 19.09.2016 um 11:00 schrieb Urs Liska:



Am 19.09.2016 um 00:32 schrieb David Kastrup:
Urs Liska <address@hidden> writes:

Am 18.09.2016 um 20:54 schrieb David Kastrup:
Do you know how to split a bezier at a given ratio into equivalent
beziers?  It's a comparatively simple operation and I think it's already
somewhere in the C++ code though without access from Scheme.
No, but I should be able to figure it out (if noone sends a pointer
before I manage to do so).
Well, METAFONT uses the notation

a[z1, z2]

for z1 + a*[z2-z1], mapping a range of 0..1 for a linearly between z1
and z2.

If we have points z1, z2, z3, z4 defining a Bezier, then the two split
beziers are defined with the points

z1, a[z1, z2], a[a[z1, z2], a[z2, z3]], a[a[a[z1, z2], a[z2, z3]],
                                          a[a[z2, z3], a[z3, z4]]

and

a[a[a[z1, z2], a[z2, z3]], a[a[z2, z3], a[z3, z4]]],
a[a[z2, z3], a[z3, z4]], a[z3, z4], z4

Basically, calculation of a point a on an n-grade Bezier is done using a
recursive formula to depth n, and keeping the intermediate results will
give you the control points for the Bezier curves split at that point.


I think before diving into that I share what I currently have, so we may discuss which approach should actually be continued.

The attached solution does the following:
  • Apply offsets for the start/end points and to the second and second-to-last control-points, based on the original points of the non-compound slur
  • Add an inflection point, which is specified as a point between the (actual) end points of the slur, given X and Y ratios (as a pair of numbers between 0 and 1
  • Determine the length and slope of the line going through the inflection point.
    • Currently this is done through specifying one point relative to the inflection point and mirroring it symmetrically
    • Instead I'd like to specify an angle and a length.
    • It would be nice to have the angle relative to the slope of the slur as a whole, but that may not be a good idea, as we have actually two separate lines with different slopes
    • Length should be given as a ratio, presumable relative to the length of the line between the inflection point and the respective end point.
    • There should be one optional argument to enforce symmetrical points here.

BTW I've spiced up the control points display a bit. I hope it's self-explanatory.

I would like to integrate this with Janek's \shapeII functions (https://github.com/openlilylib/snippets/tree/master/notation-snippets/shaping-bezier-curves) as I think there'll be quite some code (and interface?) that can be shared.

Opinions?

Urs



_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user

Attachment: compound-slur-relative.ly
Description: Text Data

Attachment: compound-slur-relative.preview.pdf
Description: Adobe PDF document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]