Title: skew bug with help lines Post by: claude on April 10, 2017, 10:31:06 PM Seems there is a bad bug with Skew. Selecting "help lines" and clicking lots of times without moving the mouse sometimes makes Kalles Fraktaler use all my memory, eventually crashing...
Tested with WINE, both my GMP fork and Karl's 2.11.1 (64bit) have the problem... Meanwile the operation of skew help lines when it does work seems inefficient - I think it could be done with a bit of maths in one pass instead of iteratively... will try to figure it out tonight and report back here... EDIT here's the formula I worked out for the skew, for two lines AB and CD: skew% = 100% / sqrt( - ((ay-by)(cy-dy)) / ((ax-bx)(cx-dx)) ) derivation: skew by lambda is (x, y) -> (x +lambda x, y) = ((1 + lambda) x, y) dot product is 0 at right angles, so: (1 + lambda)^2 (ax-bx) (cx-dx) + (ay-by)(cy-dy) = 0 solve the quadratic gives lamda = -1 +/- sqrt( - ((ay-by)(cy-dy)) / ((ax-bx) (cx-dx)) ) investigating the gui mapping, set alpha = 1 + lambda, then skew% = 100% / alpha = the formula above Not 100% sure the formula is correct, as it seems deceptively simple... Title: Re: skew bug with help lines Post by: Kalles Fraktaler on April 11, 2017, 06:03:40 PM Claude, I am in no doubt that you are able to find a mathematical solution for this, as you did with inflection :)
I was only able to come up with a trial and error function... So it would be awesome if you would be able to succeed with this! Title: Re: skew bug with help lines Post by: claude on April 12, 2017, 03:50:39 PM It's not the whole story as I just noticed the help-lines function adjusts the rotation too (which makes it possible to solve in more cases I think - just adjusting skew means two lines sloping the same way can never be skewed to 90deg, as witnessed by a negative within the sqrt in the formula).
One way to solve it would be to automatically rotate so that the lines form a symmetric V shape first (which should be quite easy) before skewing. I think the symmetry will also give the minimal skew amount needed, but I need to check this. Might give more rotation than desired. I guess for full generality it needs another parameter (rotation before skew, skew amount, and also rotation after skew). Title: Re: skew bug with help lines Post by: Kalles Fraktaler on April 12, 2017, 07:40:12 PM It's not the whole story as I just noticed the help-lines function adjusts the rotation too (which makes it possible to solve in more cases I think - just adjusting skew means two lines sloping the same way can never be skewed to 90deg, as witnessed by a negative within the sqrt in the formula). Yes, the thing I call "skewing" is two parts, stretch and rotation. One way to solve it would be to automatically rotate so that the lines form a symmetric V shape first (which should be quite easy) before skewing. I think the symmetry will also give the minimal skew amount needed, but I need to check this. Might give more rotation than desired. I guess for full generality it needs another parameter (rotation before skew, skew amount, and also rotation after skew). There may be an easier way to skew in one go. A big disadvantage with my method is that the rotation options are then consumed, so the program cannot rotate a cool skewed pattern in e.g. the burning ship fractal, as you can without skewing in e.g. standard Mandelbrot. The reason is that all of rotation and stretching needs to be done before the pixels are rendered, in order to preserve quality. One way could perhaps be to add a second rotation, after all of the current skewing. Or, preferable, do the skewing in a better mathematical way first, and then the rotation? Title: Re: skew bug with help lines Post by: claude on April 13, 2017, 09:07:53 PM One way could perhaps be to add a second rotation, after all of the current skewing. Or, preferable, do the skewing in a better mathematical way first, and then the rotation? I think the skew method is fine as it is from a mathematical point of view. Adding a second rotation after the current transform would be the way to go I think, shouldn't be hard to implement. |