Difference between revisions of "Talk:Link to BLine"

From Synfig Studio :: Documentation
Jump to: navigation, search
(Circular references problem: some thoughts)
(Creating loops: formula)
Line 66: Line 66:
 
# As the user invokes "Link to Bline" command for C2, we detected loop C2->B2->A2->C2. <br> http://zelgadis.profusehost.net/files/synfig/circular_references/cr02.jpg
 
# As the user invokes "Link to Bline" command for C2, we detected loop C2->B2->A2->C2. <br> http://zelgadis.profusehost.net/files/synfig/circular_references/cr02.jpg
 
# We must solve equation (or system of equations) to determine position of C2 when: a) it laying on Bline A; b) the shape of Bline A determined by position of C2;  
 
# We must solve equation (or system of equations) to determine position of C2 when: a) it laying on Bline A; b) the shape of Bline A determined by position of C2;  
## I don't know how to solve it!!!
+
## Which formula defines the bline shape? <math>(x,y) = (1-u)^3 \cdot (x_1,y_1) + 3 \cdot u(1-u)^2 \cdot (x_{t1},y_{t1}) + 3 \cdot u^2 (1-u) \cdot (x_{t2},y_{t2}) + u^3 (x_2,y_2)</math>, where u - amount on segment [0,1]
## Which formula defines the bline shape?
+
## [[Linking to Blines - Equations]]
 
# We placing C2 to determined position. So it definitely on Bline A.
 
# We placing C2 to determined position. So it definitely on Bline A.
 
# We linking C2 to Bline A. Position of C2 not changed while linking, so all blines not recalculated and Bline A keeps its shape.
 
# We linking C2 to Bline A. Position of C2 not changed while linking, so all blines not recalculated and Bline A keeps its shape.

Revision as of 18:23, 7 March 2008

In an IRC discussion it was suggested that it should to be possible to:

Provide an easy way for the user to attach a vertex of a bline to another bline

but without the need to create a new vertex over that bline. That allows the simplification of the animation of complex compositions due to the use of less vertices.

See Yoyobuae's example:

Sif icon.pngbline attached

In that example there are some vertices converted to "BLine Vertex" and some tangents converted to "BLine Tangent". Manipulating the exported parameter that represents the position of the vertex along the curve it is possible to easily modify the shape of the composition allowing a better morphing of the shapes created.

Currently it is done through various export/connect manipulations.

Suggestion: It's desired that this attachment be achieved visually, by using the mouse and context menus. The current method requires the use of exported values and parameter linking, which is less intuitive and also is slower.

Possible realization way:

  1. Select the duck you want to link to bline. It could be
    1. bline vertex duck
    2. bline tangent duck
    3. or real duck
  2. Right click on the bline (not the bline vertex!)
  3. Link
    1. Linking creating appropriate convert sequences.
    2. if selected vertex duck, it placed on bline at position where clicked
    3. if selected tangent duck, it links with bline tangent at click position
      1. Which one of two? Maybe both? --Zelgadis 12:27, 3 March 2008 (EST)
        1. Maybe we want to link our tangent to 90 degrees away from the bline's tangent at the clicked position. The "BLine Tangent" ValueNode can be extended to include an "Offset" parameter. -- dooglus 18:44, 5 March 2008 (EST)
      2. We need to scale tangents as in example above
        1. As of r1856 that is no longer necessary -- dooglus 18:44, 5 March 2008 (EST)
    4. if selected real duck, it links with bline width at click position
      1. currently width value at specific point of bline couldn't be easily retrieved via export/convert combinations --Zelgadis 12:27, 3 March 2008 (EST)
        1. Convert#BLine_Width -- dooglus 18:44, 5 March 2008 (EST)
  4. If was more than one duck selected for linking (i.e. bline vertex duck and bline tangent duck) then the Amount values (in "Bline Vertex"/"Bline Tangent" converts) must be linked to ensure that they retrieved from the same position on a bline (if changed).

Circular references problem

As of http://dooglus.rincevent.net/synfig/logs/2008/%23synfig-2008-03-06.log the circular references problem appeared.

In my (Zelgadis) opinion we have 3 problems:

  1. Detecting loops
  2. Creating loops (handling detected loop while creating)
  3. Dealing with loops (handling modifications of linked-to-bline vertices engaged inloops)

Detecting loops

00:22 < dooglus> it turns out that every node in the network has a 'time last modified' field, so checking that will allow us to detect loops


Creating loops

While creating loop we have a Circular references problem.

In example http://zelgadis.profusehost.net/files/synfig/circular_references/bline_link_loop_crash.sifz we have 3 blines A,B,C.

cr01.jpg

We want to link C2 to Bline A.

But if we do it, C2 will change it's position (it must lay on the Bline A). As result, the shape of Bline C will change and B2 (which linked to Bline C) will move. It will change the shape of Bline B -> A2 will move -> shape of Bline A changed -> C2 not on Bline A. Сontradiction.

We could move C2 to place it on Bline A again but then it'll end up not laying on Bline A again.

So, if we detected loop, we must do linking in special way.

  1. As the user invokes "Link to Bline" command for C2, we detected loop C2->B2->A2->C2.
    cr02.jpg
  2. We must solve equation (or system of equations) to determine position of C2 when: a) it laying on Bline A; b) the shape of Bline A determined by position of C2;
    1. Which formula defines the bline shape? Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle (x,y) = (1-u)^3 \cdot (x_1,y_1) + 3 \cdot u(1-u)^2 \cdot (x_{t1},y_{t1}) + 3 \cdot u^2 (1-u) \cdot (x_{t2},y_{t2}) + u^3 (x_2,y_2)} , where u - amount on segment [0,1]
    2. Linking to Blines - Equations
  3. We placing C2 to determined position. So it definitely on Bline A.
  4. We linking C2 to Bline A. Position of C2 not changed while linking, so all blines not recalculated and Bline A keeps its shape.

Another possible solution (ah-hoc):

  1. As the user invokes "Link to Bline" command for C2, we detected loop C2->B2->A2->C2.
    cr02.jpg
  2. We adding a new vertex A3 on Bline A where C2 must be connected. Then we moving (moving, not linking) C2 to the position Bline A where user had clicked. The blines C,B,A will change so C2 probably won't be on A.
  3. Just link C2 -> A3

Dealing with loops

To be written... if needed to.

Inverse Duck Manipulation

Derived from that request it appears the need to be able to manipulate the ducks that have been converted to a composition. That is: inverse manipulation of valuenodes. For the moment there are some convert types that allow inverse manipulation and only for certain parameters. For example tangents allow inverse manipulation (you modify the x/y position and it calculates the r,theta values. It is know that inverse manipulation leads on some inconsistencies. If the the function that convert a type into other is not biunivocal then it can produce undesired results form the point of view of the final user. For example, the Scale convert type would not have any inconsistency due to it has a easy computable reverse function (the reciprocal)

Considering that and taking account that inverse calculation of ValueNodes based on ducks position could need some extra computation, it would be good if some convert types can have inverse manipulation.

The proposal is that BLine Vertex converted types allow inverse manipulation. So, manipulating a vertex duck you move the attached vertex along the bline and also match the tangent of the attached vertex to the bline's tangent at that position.