Posts: 6,377
Threads: 277
Joined: Oct 2016
Reputation:
566
Operating system(s):
Gimp version: 3.00RC1
Interesting. Did you try to figure out what is t for which P(t)==K. From my dealings with Bézier curves over the past years, I would says that it is a bell curve very centered around t=0.5 (even if that specific curve has a cusp or a loop), so using this instead of trying to find the "best" point could save you some time. But of course it only works with single splines and not full strokes.
Also you can save some time by letting Gimp do as much computation for you as possible (since its done in C, somewhat faster than Python). For instance an accuracy criteria could just be the distance between your K=P(0.5) and the point in the middle of the stroke (using Gimp's getPointAtDist()).
Posts: 236
Threads: 26
Joined: Mar 2020
Reputation:
29
Operating system(s):
- Windows (Vista and later)
Gimp version: Don't know yet
(I am not quite sure if I understand your comments quite right.)
No I have not thought about P(t)=K. But I may some day. And yes there is that fact that the stroke consists of several small arcs, and we cannot tell even on which arc the most distant point K is.
I have the feeling that when searching for an approximate Bezier arc it is important to choose K somewhere close to the middle of the stroke, and I think that the most distant point works well. Also, the splitting is good to do at the same point so that the stroke will never be split anywhere close to either end point but somewhere in the middle. That is why the point K is computed rather carefully.
Finding K is not done by running along the stroke. It is (usually) done by solving the points where the tangent is parallel to the chord. That comes down to solving equations of degree 2. So it should be fast enough.
I did not know about getPointAtDist and I don't find how to call it. But I found now that a stroke has a method get_point_at_dist(). It is the same I suppose.
Yes that error measure is the trouble spot. It should be made faster before even thinking to try to make the code faster elsewhere. But we are measuring distance between something like a stroke and its candidate approximate Bezier arc. There is no guarantee that the curves are close to each other anywhere else but the three points p0,p3,K. The two curves may not run side by side, and the stroke can contain small and large bends. The measure must take into account the whole lengths of the curves somehow; one point is not enough. But anyhow, I am sure the code could be made better with some better idea. This version is working all right, and for an experimental plugin it will do so far.
As a small entertainment I mention that some years ago my Parametric curves plugin (some old version) used as the error measure the area between two curves. The area was computed by summing a large number of narrow triangles. Well, no sense in going back to that solution...
Posts: 1,049
Threads: 87
Joined: Aug 2018
Reputation:
83
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
(06-27-2021, 01:02 PM)Ottia Tuota Wrote: A bug fix. New version 0.10 is at the old place:
http://kmarkku.arkku.net/Path_modify_fil...aster.html
[...]
Even after the fixes this problem remains: Suppose we want to restrict the effect of the plugin to some anchors, and to that end we need to select some anchors outside of the canvas. That can be done only(?) with the workaround that Rich found here:
https://www.gimp-forum.net/Thread-Select...0#pid24250
- Extend the canvas temporarily (easily with the Crop tool with option "Allow growing").
- Make the selection.
- Call the plugin.
- Crop the canvas back (Image -> Crop to content).
This is an inconvenience but I suppose we just have to live with it.
It looks like the current version is
0.11 as I could see at
http://kmarkku.arkku.net/Path_modify_fil...aster.html <<<--- Simplify - current version 0.11
.....
Samj Portable - Gimp 2.10.28 - Win-10 /64.