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 11:00:17 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0



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

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]