Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Path transformations
#9
I made another path transformation plugin. It is based on an idea of my own. But I cannot believe that no predecessors would exist. The idea is so simple.

The link to download the plugin (and all the previous ones) is in post #1. It is a .zip file but contains one big file only. The version is now 0.15.

Better to start with a picture:

   

The input paths in this picture are:

  1. The Path to be transformed (the letters ABCPQR with the frame)
  2. The Base, a path with 2 anchors
  3. The Target, a path with 2 anchors
  4. The Shaper, a curvy quadrilateral consisting of four Bezier arcs (closed, four anchors)
The Shaper is what defines the shape of the transformation. The Base and the Target determine from where to where the mapping goes. You see that the Transformed Path is the original Path but deformed in the shape of the Shaper and moved to the Target.

In the plugin I assumed that the Shaper is a simple curvy quadrilateral covering roughly a rectangular region. Anything else may work ok, or it may give weird results. I also assumed that the edges of the Shaper run roughly: horizontal-vertical-horizontal-vertical, but that is not so necessary to get good results.

The plugin is somewhat similar to the one in post #3. Main differences are:

  1. This transformation is not conformal.
  2. The Shaper is made of 4 Bezier arcs (rather than just 1).
  3. The plugin also allows Base and Target with 4 anchors.
The plugin is based on my own ideas, hence I want to record and share the formulas and a little of how the plugin works internally. I wrote the following pdf. (It is rather long. I hope you allow the old mathematics teacher this little joy of writing mathematics.) Note there especially formula (3). Natural isn't it! (In a mathematician's eyes at least it is.) I don't think that such obvious-looking formula could be new. So, this transformation (formula) may already have some proper name. If so, it would be nice to know it. Lacking a better name, I call it "a map shaped by a Bezier arc quadrilateral".


.pdf   transformation_by_16_bezier.pdf (Size: 247.04 KB / Downloads: 236)

My plugin transforms paths, but from the formulas somebody more skilled could write a tool for transforming images.

I admit that the results are not always so neat as in the few pictures in this post. The Bernstein polynomials are of degree 3, after all, and they tend to grow fast. So the outcomes are not easy to control, and one has just to go experimenting and trying to learn to use the plugin. I haven't much done that myself since this is quite new and I have a lot of other things to do. If the plugin goes too wild, one can curb the Shaper by the input 'strength'. Another good rule is to place the Base quite close to the Path.

There is another way to use the the plugin: Base and Target may have 4 anchors. This allows the user to have some particular four points mapped onto some other particular four points. A picture:

   

The Path is the text ABCPQR together with the frame. The Base is the slightly bigger square. The Target is the skew quadrilateral. The corner points of the Base are mapped onto the corner points of the Target. The Transformed Path (red) is distorted accordingly. (If I had put the Base exactly at the frame of the Path, the corners of the frame would have been mapped exactly at the corners of the Target. Now there is a little discrepancy.)

A word of warning: When one uses Base and Target with four anchors, the plugin may fail with message like "Hit an infinity". Namely, here the plugin uses projective transformations (I think it is almost the same as Gimp's Perspective transform), and infinities occur quite naturally. So, such failure is not necessarily a sign of a fault with the plugin. If that happens, make changes in the input paths and try again.

Now I explain the other inputs in the GUI of the plugin.

The three 'Permute' inputs you need not touch at all. If the input paths are reasonable, the results should be reasonable. But you can experiment.
  • Permute the Base anchors: If the result is not what you expected, you can try to use the Base with its anchors permuted with cyclic rotation and/or reversed. When the Base has 4 anchors, the meaning of the input number is: 0..3 are rotations (0 does nothing) and 4..7 are rotations followed by reversal. When the Base has 2 anchors, there are two alternatives: 0 (or any even number) does nothing, and 1 (or any odd number) causes reversal.
  • Permute the Target anchors: This is the same operation for the Target.
  • Permute the Shaper anchors: This is the same operation for the Shaper (with always 4 anchors).
  • Linearize any straight edges in Shaper: If the Shaper contains a straight edge, its handles may be of zero length, or they may be something else, without any visual difference. But different handle lengths result in different transformations. When the input 'Linearize' is Yes, the plugin internally sets the handles at points 1/3 and 2/3 of the straight edge. This tames a little the transformation which might otherwise be more distorting than desired. (Mathematically: the Bezier function coming from such an edge is made a linear function.)
  • Adjust the form of shaping: Experiment.
  • Strength of Shaper: Adjust the effect of the curviness of the Shaper. If strength=1, the Shaper is used as is. If strength=0, the Shaper is used with its edges straightened out. If 0<strength<1, the effect is something between.
  • Choose algorithm (integer 0..8): The plugin is very slow. By choosing a number >0 the user can make the plugin to use a worse but fast simple algorithm. The idea is to do experimenting with such fast algorithm, and when something good is found, finally draw it with the good but slow algorithm.
Another example to show what the plugin can make from a simple grid using default values but applying different Shapers: The Path is the blue grid. The red figures are the Path transformed by various Shapers. In each case, the Base is set precisely at the bottom edge of the grid (so, two anchors). The Target (not shown) is somewhere else and has two anchors.

   

Note in particular the two half circles: the outline is the same but the curved grids inside are different. The secret is that in each the Shaper was a half circle but the anchors on that half circle were placed differently. In other words, the subdivisions of the Shapers into four arcs were different. The same is true for the two circlular cases. And having said that much, I also have to show how the anchors in the Shapers were situated (the handles are not shown):

   


I hope you enjoy. Any feedback or questions are welcome!


Edit: Deleted one remark. Wrong idea.
Reply


Messages In This Thread
Path transformations - by Ottia Tuota - 04-22-2020, 10:34 AM
RE: Path transformations - by Ottia Tuota - 04-22-2020, 12:27 PM
RE: Path transformations - by Ottia Tuota - 04-24-2020, 10:28 AM
RE: Path transformations - by Zero01 - 04-24-2020, 09:25 PM
RE: Path transformations - by Ottia Tuota - 04-26-2020, 06:36 AM
RE: Path transformations - by Ottia Tuota - 05-04-2020, 10:01 AM
RE: Path transformations - by Ottia Tuota - 06-08-2020, 11:08 AM
RE: Path transformations - by Ottia Tuota - 06-09-2020, 05:08 PM
RE: Path transformations - by Ottia Tuota - 07-12-2020, 12:50 PM
RE: Path transformations - by Ofnuts - 07-12-2020, 11:33 PM
RE: Path transformations - by Ottia Tuota - 07-13-2020, 06:15 AM
RE: Path transformations - by Ottia Tuota - 07-13-2020, 05:15 PM
RE: Path transformations - by Ottia Tuota - 07-14-2020, 02:23 PM
RE: Path transformations - by Ofnuts - 07-14-2020, 04:02 PM
RE: Path transformations - by rich2005 - 07-15-2020, 09:20 AM
RE: Path transformations - by Ottia Tuota - 07-15-2020, 11:38 AM
RE: Path transformations - by Ottia Tuota - 07-16-2020, 11:42 AM
RE: Path transformations - by Ottia Tuota - 07-26-2020, 07:26 AM
RE: Path transformations - by Ottia Tuota - 08-05-2020, 06:13 PM
RE: Path transformations - by Ottia Tuota - 08-07-2020, 07:25 AM
RE: Path transformations - by Ottia Tuota - 08-11-2020, 08:39 AM
RE: Path transformations - by Ofnuts - 08-07-2020, 08:23 AM
RE: Path transformations - by Ottia Tuota - 08-07-2020, 12:06 PM
RE: Path transformations - by Ofnuts - 08-08-2020, 12:58 PM
RE: Path transformations - by Ottia Tuota - 08-08-2020, 01:33 PM
RE: Path transformations - by mahvin - 08-07-2020, 01:55 PM
RE: Path transformations - by Ottia Tuota - 08-07-2020, 07:26 PM
RE: Path transformations - by mahvin - 08-07-2020, 07:56 PM
RE: Path transformations - by Ottia Tuota - 08-07-2020, 08:15 PM
RE: Path transformations - by Ottia Tuota - 09-03-2020, 11:43 AM
RE: Path transformations - by Ottia Tuota - 09-04-2020, 11:29 AM
RE: Path transformations - by Ottia Tuota - 09-19-2020, 01:00 PM

Forum Jump: