Difference between revisions of "Dev:Linking to Blines - Equations"

From Synfig Studio :: Documentation
Jump to: navigation, search
(One spline)
 
(30 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
WARNING: This text is under HEAVY development. Please be patient.
 +
 
== Main equations ==
 
== Main equations ==
  
* <math>(x_1,y_1), (x_2,y_2)</math> - points of bline vertex
+
* <math>(x_1,y_1), (x_2,y_2)</math> - vertices, defining bline segment
* <math>(x^t_1,y^t_1), (x^t_2,y^t_2)</math> - tangent points
+
* <math>(x,y) </math> - current bline point
* <math> (x,y) </math> - current bline point
+
* <math>(x_{t1},y_{t1}), (x_{t2},y_{t2})</math> - tangent points defining bline segment
* <math>(x^t_L,y^t_L), (x^t_N,y^t_N)</math> - tangents of current point
+
* <math>(x_{t},y_{t})</math> - tangent coordinates for current bline point
 
* u - Amount of current segment, [0,1]
 
* u - Amount of current segment, [0,1]
  
* <math>(x,y) = (1-u)^3 (x_1,y_1) + 3 u(1-u)^2  (x^t_1,y^t_1) + 3 u^2 (1-u)  (x^t_2,y^t_2) + u^3 (x_2,y_2)</math> - bline point
+
* <math>(x,y) = (1-u)^3 (x_1,y_1) + 3 u(1-u)^2  (x_{t1},y_{t1}) + 3 u^2 (1-u)  (x_{t2},y_{t2}) + u^3 (x_2,y_2)</math> - bline point
  
Finding tangents:
+
==== Relative tangents ====
  
* put a point on each line, some percentage of the way along each
+
O'kay, I know, the <math>(x_{t1},y_{t1}), (x_{t2},y_{t2})</math> defining absolute position of tangents, but in synfig we have their coordinates relative to vertex. Moreover, coordinates of yellow tangent are inverted.
** M on (A,B): <math>(x_1,y_1)(1-u) + (x^t_1,y^t_1)u</math>
+
 
** N on (B,C): <math>(x^t_1,y^t_1)(1-u) + (x^t_2,y^t_2)u</math>
+
Let's say:
** K on (C,D): <math>(x^t_2,y^t_2)(1-u) + (x^2,y^2)u</math>
+
* <math>(\Delta x_{t1},\Delta y_{t1})</math> and <math>(\Delta x_{t2},\Delta y_{t2})</math> - relative coordinates of tangents
* then draw new lines from the point on A-B to the point on B-C, and from the point on B-C to the point on C-D; and put new points on those 2, the same percentage of the way along each
+
** T1 on (M,N): <math>M(1-u) + N u = ((x_1,y_1)(1-u) + (x^t_1,y^t_1)u)(1-u) + ((x^t_1,y^t_1)(1-u) + (x^t_2,y^t_2)u)u</math>
+
** T2 on (N,K): <math>N(1-u) + K u = ((x^t_1,y^t_1)(1-u) + (x^t_2,y^t_2)u)(1-u) + ((x^t_2,y^t_2)(1-u) + (x^2,y^2)u) u</math>
+
  
 
Then:
 
Then:
  
* <math>(x^t_L,y^t_L) = (1-u)^2 (x_1,y_1) + 2u(1-u)(x^t_1,y^t_1) + u^2(x^t_2,y^t_2)</math> - yellow tangent of bline point
+
*<math>(x_{t1},y_{t1}) = (x,y) + (\Delta x^{t1},\Delta y^{t1})</math>
* <math>(x^t_N,y^t_N) = (1-u)^2 (x^t_1,y^t_1) + 2u(1-u)(x^t_2,y^t_2) + u^2(x_2,y_2)</math> - red tangent of bline point
+
*<math>(x_{t2},y_{t2}) = (x,y) - (\Delta x^{t2},\Delta y^{t2})</math>
  
== One spline ==
+
Make substitution:
  
Case: Bline A. A2 linked to A (with tangent).
+
* Bline point: <math>(x,y) = (1-(3u^2-2u^3)) (x_1,y_1) + 3u(1-u)^2 (\Delta x_{t1},\Delta y_{t1}) - 3u^2(1-u) (\Delta x_{t2}, \Delta y_{t2}) + (3u^2-2u^3) (x_2,y_2)</math>
  
A2 with its tangent belongs to A, so:
+
=== Tangent coordinates ===
* <math>x_{A2} = (1-u)^3 x_{A1} + 3u(1-u)^2 x^t_{A1} + 3u^2(1-u) x^t_{A2} + u^3 x_{A2}</math>
+
* <math>x^t_{A2} = (1-u)^2 x_{A1} + 2u(1-u) x^t_{A1} + u^2 x^t_{A2}</math>
+
  
Let's find <math>x_{A2}</math> and <math>x^t_{A2}</math>:
+
<pre>
* <math>x_{A2} = \frac{(1-u)^3 x_{A1} + 3u(1-u)^2 x^t_{A1} + 3u^2(1-u) x^t_{A2} }{1 - u^3}</math>
+
<dooglus> look at etl/_calculus.h
* <math>x^t_{A2} = \frac{(1-u)^2 x_{A1} + 2u(1-u) x^t_{A1}} {1- u^2 }</math>
+
<dooglus> class derivative<hermite<T> >
 +
<dooglus>  T a = func[0], b = func[1], c = func[2], d = func[3];
 +
<dooglus>  typename hermite<T>::argument_type y(1-x);
 +
<dooglus>  return ((b-a)*y*y + (c-b)*x*y*2 + (d-c)*x*x) * 3;
 +
</pre>
 +
 
 +
: Can't understand, why *3? --{{l|User:Zelgadis|Zelgadis}} 05:31, 8 March 2008 (EST)
 +
 
 +
For x:
 +
* <math>\Delta x_{t} = (1-u)^2 \Delta x_{t1} + 2u(1-u) ((x_2 - \Delta x_{t2}) - (x_1 + \Delta x_{t1})) + u^2 \Delta x_{t2}  = </math> <math>= -2u(1-u)x_1 + (1-u)(1-3u)\Delta x_{t1} + (3u^2 - 2u)\Delta x_{t2} + 2u(1-u)x_2</math>
 +
 
 +
=== Checking formulas ===
 +
Well, I really wasn't sure if this formulas correct, that's why I did a little research and made some graphics and calculations. They are available [http://zelgadis.profusehost.net/files/synfig/circular_references/formula.zip here].
 +
 
 +
As result I got some final corrections to formulas (for x only):
 +
 
 +
* Bline point: <math>x = (1-(3u^2-2u^3)) x_1 + u(1-u)^2 \Delta x_{t1} - u^2(1-u) \Delta x_{t2} + (3u^2-2u^3) x_2</math>
 +
* Bline tangent: <math>\Delta x_{t} = -6u(1-u)x_1 + (1-u)(1-3u)\Delta x_{t1} + (3u^2 - 2u)\Delta x_{t2} + 6u(1-u)x_2</math>
 +
 
 +
=== Zelgadis, you wrong! ===
 +
 
 +
O'kay I understand what equations above could be wrong. But no one will argue what equations for bline point and tangents generally have form:
 +
 
 +
* <math>(x,y) = c_1(u) (x_1,y_1) + c_2(u)  (x_{t1},y_{t1}) + c_3(u)  (x_{t2},y_{t2}) + c_4(u) (x_2,y_2)</math>
 +
* <math>(\Delta x_{t},\Delta y_{t}) = c_{t1}(u) (x_1,y_1) + c_{t2}(u) (\Delta x_{t1}, \Delta y_{t1}) + c_{t3} (\Delta x_{t2}, \Delta y_{t2}) + c_{t4}(u) (x_2,y_2)</math>
 +
 
 +
where <math>c_i(u)</math> - some function from 'u' argument
 +
 
 +
So I will use this notation further.
 +
 
 +
For now we assume what:
 +
* <math>c_1(u)=1-(3u^2-2u^3)</math>
 +
* <math>c_2(u)=u(1-u)^2</math>
 +
* <math>c_3(u)=- u^2(1-u)</math>
 +
* <math>c_4(u)=3u^2-2u^3</math>
 +
* <math>c_{t1}(u)=-6u(1-u)</math>
 +
* <math>c_{t2}(u)=(1-u)(1-3u)</math>
 +
* <math>c_{t3}(u)=3u^2 - 2u</math>
 +
* <math>c_{t4}(u)=6u(1-u)</math>
 +
 
 +
== General model ==
 +
 
 +
The problem: see {{l|Linking_to_Blines#Creating_loops}}
 +
 
 +
So we need to determine position of vertex engaged in loop if she attachet ot some position of other bline.
 +
 
 +
: NOTICE: We need such recalculation only for cases when in loop included only 1 segment from each bline. Like this:<br>http://zelgadis.profusehost.net/files/synfig/circular_references/cr02.jpg http://zelgadis.profusehost.net/files/synfig/circular_references/cr04.jpg
 +
: We don't need to do recalculation for cases like those:<br>http://zelgadis.profusehost.net/files/synfig/attach-loop-simple.png
 +
 
 +
So, we have N blines (N bline segments) engaged in a loop.
 +
 
 +
To determine the x coordinate of vertex what finalizes the loop we need to solve matrix equation having form
 +
 
 +
<math>(A - B)*\alpha = \beta</math>
 +
 
 +
: NOTE: Solution formulas for y coordinate will be the same.
 +
 
 +
* <math>A, B</math> - matrices 4N x 4N
 +
* <math>\alpha, \beta</math> - 4N column vectors
 +
* <math>\alpha</math> - is unknown quantity
 +
 
 +
Each line in matrix or column vector corresponding to particular vertex or it's tangent.
 +
 
 +
After solving system we will find column vector <math>\alpha</math> which have form: <math>(x^{[1]}_1,\Delta x^{[1]}_{t1},\Delta x^{[1]}_{t2},x^{[1]}_2, x^{[2]}_1,\Delta x^{[2]}_{t1},\Delta x^{[2]}_{t2},x^{[2]}_2, ... ,x^{[N]}_1,\Delta x^{[N]}_{t1},\Delta x^{[N]}_{t2},x^{[N]}_2)</math> where <math>x^{[i]}_j</math> - point j of bline [i] and <math>\Delta x^{[i]}_tj</math> tangent of point j of bline i. From this vector we could retrieve x coordinate of desired vertex or tangent.
 +
 
 +
So:
 +
* the first line of each matrix or column vector corresponding to first vertex of first bline,
 +
* second line - corresponding to tangent of first vertex of first bline,
 +
* third line - to tangent of second vertex of first bline,
 +
* fourth - second vertex of first bline,
 +
* fifth - first vertex of second bline,
 +
* sixth - tangent of first vertex of second bline,
 +
* ...and so on...
 +
 
 +
: NOTE: Talking about bline we are talking about single (!) segment of bline which engaged in loop. That's why I not specify which tangent (yellow or red) we using - it's always tangent for current segment.
 +
 
 +
Column vector <math>\beta</math> have following structure. If position of vertex/tangent corresponding to vector element is "static" (i.e. it's not linked any other bline segment of the loop) then vector element is <math>\beta_i</math> where <math>\beta_i</math> is current x coordinate of this vector/tangent. If vertex/tangent is not "static" then corresponding vector element is zero.
 +
 
 +
: NOTE: When we calling vertex position "static" it's not means what vertex not linked to anything. The vertex could be linked to bline and still considered as "static" if that bline is not engaged into loop what we processing.
 +
 
 +
B matrix is zero-filled 4Nx4N matrix which we modifying in folowing way (rows and columns in matrix are numbered from 1):
 +
* if first vertex of bline [i] is linked to bline [j] then element at ( (i-1)*4+1 , (i-1)*4+1 ) = 1
 +
* if tangent of first vertex of bline [i] is linked to bline [j] then element at ( (i-1)*4+2 , (i-1)*4+2 ) = 1
 +
* if tangent of second vertex of bline [i] is linked to bline [j] then element at ( (i-1)*4+3 , (i-1)*4+3 ) = 1
 +
* if second vertex of bline [i] is linked to bline [j] then element at ( (i-1)*4+4 , (i-1)*4+4 ) = 1
 +
 
 +
A matrix is modified E matrix. <math>E = \begin{pmatrix} 1 & 0 & 0& ... & 0 \\ 0 & 1 & 0& ... & 0 \\ 0 & 0 & 1 & ... & 0 \\...&...&...&...&... \\ 0 & 0 & 0& ... & 1 \\ \end{pmatrix}</math>
 +
 
 +
It is modified in such way:
 +
* if first vertex of bline [i] is linked to bline [j] then element at position ( (i-1)*4+1, (i-1)*4+1 ) replaced with zero and elements in line (i-1)*4+1 at positions (j-1)*4+1, (j-1)*4+2, (j-1)*4+3, (j-1)*4+4 are replaced with <math>c^{[j]}_1(u^{[i]}_1), c^{[j]}_2(u^{[i]}_1), c^{[j]}_3(u^{[i]}_1), c^{[j]}_4(u^{[i]}_1)</math>
 +
* if tangent of first vertex of bline [i] is linked to bline [j] then element at position ( (i-1)*4+2, (i-1)*4+2 ) replaced with zero and elements in line (i-1)*4+2 at positions (j-1)*4+1, (j-1)*4+2, (j-1)*4+3, (j-1)*4+4 are replaced with <math>c^{[j]}_{t1}(u^{[i]}_1), c^{[j]}_{t2}(u^{[i]}_1), c^{[j]}_{t3}(u^{[i]}_1), c^{[j]}_{t4}(u^{[i]}_1)</math>
 +
* if tangent of second vertex of bline [i] is linked to bline [j] then element at position ( (i-1)*4+3, (i-1)*4+3 ) replaced with zero and elements in line (i-1)*4+3 at positions (j-1)*4+1, (j-1)*4+2, (j-1)*4+3, (j-1)*4+4 are replaced with <math>c^{[j]}_{t1}(u^{[i]}_2), c^{[j]}_{t2}(u^{[i]}_2), c^{[j]}_{t3}(u^{[i]}_2), c^{[j]}_{t4}(u^{[i]}_2)</math>
 +
* if second vertex of bline [i] is linked to bline [j] then element at position ( (i-1)*4+4, (i-1)*4+4 ) replaced with zero and elements in line (i-1)*4+4 at positions (j-1)*4+1, (j-1)*4+2, (j-1)*4+3, (j-1)*4+4 are replaced with <math>c^{[j]}_1(u^{[i]}_2), c^{[j]}_2(u^{[i]}_2), c^{[j]}_3(u^{[i]}_2), c^{[j]}_4(u^{[i]}_2)</math>
 +
 
 +
where <math>u^{[i]}_k</math> is a position of vertex/tangent k of bline [i] on bline which it's linked to.
 +
 
 +
== Examples ==
 +
Ok, I sure you guys are wondering how is this work. (I personally wondering IF this works or not :D).
 +
Let's view some examples.
 +
 
 +
=== One spline ===
 +
 
 +
'''Case 1: Given Bline [1]. Vertex 2 of bline [1] linked to bline [1].'''
 +
 
 +
http://zelgadis.profusehost.net/files/synfig/circular_references/cr05.jpg
 +
 
 +
For x coordinates we have following system of equations:
 +
 
 +
* <math>x^{[1]}_1 = X^{[1]}_1</math>
 +
* <math>\Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}</math>
 +
* <math>\Delta x^{[1]}_{t2} = \Delta X^{[1]}_{t2}</math>
 +
* <math>x^{[1]}_{2} = c^{[1]}_1(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[1]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[1]}_2) x^{[1]}_2</math> - because <math>x^{[1]}_2</math> belongs to bline [1]
 +
 
 +
<math>X^{[i]}_j</math> is a constant value of <math>x^{[i]}_j</math> and <math>\Delta X^{[i]}_{j}</math> is a constant value of <math>\Delta x^{[i]}_{j}</math>.
 +
<math>u^{[1]}_2</math> is a position of vertex 2 of bline [1] on the bline which it's linked to (i.e. bline [1]).
 +
 
 +
Transform:
 +
* <math>x^{[1]}_1 = X^{[1]}_1</math>
 +
* <math>\Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}</math>
 +
* <math>\Delta x^{[1]}_{t2} = \Delta X^{[1]}_{t2}</math>
 +
* <math>c^{[1]}_1(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[1]}_2) \Delta x^{[1]}_{t2} + (c^{[1]}_4(u^{[1]}_2) - 1) x^{[1]}_2 = 0</math>
 +
 
 +
So, we must solve the 4x4 matrix equation:
 +
<math>( \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 &0 \\ 0 & 0 & 1 & 0 \\ c^{[1]}_1(u^{[1]}_2) & c^{[1]}_2(u^{[1]}_2) & c^{[1]}_3(u^{[1]}_2) & c^{[1]}_4(u^{[1]}_2)  \end{pmatrix} -\begin{pmatrix} 0&0&0&0 \\ 0&0&0&0\\ 0&0&0&0 \\ 0&0&0&1\end{pmatrix})  \cdot \begin{pmatrix} x^{[1]}_1 \\ \Delta x^{[1]}_{t1} \\ \Delta x^{[1]}_{t2} \\ x^{[1]}_{2} \end{pmatrix} = \begin{pmatrix} X^{[1]}_1 \\ \Delta X^{[1]}_{t1} \\ \Delta X^{[1]}_{t2} \\ 0 \end{pmatrix}</math>
  
So if we look closely at the equations, we will see that all 4 points (2 tangents and 2 vertices) are placed on line defined by .
 
  
 
dooglus, can you check how this formula works in code? Something like:
 
dooglus, can you check how this formula works in code? Something like:
* Create bline with 2 points - A1,A2
+
* Create bline with 2 points - 1 and 2
* Select point A2, right click on bline -> "Link to bline"
+
* Select point 2, right click on bline -> "Link to bline"
* Place (not link!) at the position calculated by this formula. If we'll have A2 on bline after that then it's ok for now, if not - something wrong.
+
* Place (not link!) point 2 at the position calculated by this formula. If we'll have point 2 on bline after that then it's ok for now, if not - something wrong.
I know we need a general formula but if this won't work then I definitely not right.
+
 
 +
 
 +
''' Case 2: Given Bline [1]. Vertex 2 of bline [1] linked to bline [1] with it's tangent. '''
 +
http://zelgadis.profusehost.net/files/synfig/circular_references/cr05.jpg
 +
 
 +
For x coordinates we have following system of equations:
 +
 
 +
* <math>x^{[1]}_1 = X^{[1]}_1</math>
 +
* <math>\Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}</math>
 +
* <math>\Delta x^{[1]}_{t2} = c^{[1]}_{t1}(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_{t2}(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_{t3}(u^{[1]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_{t4}(u^{[1]}_2) x^{[1]}_2</math> - because tangent <math>\Delta x^{[1]}_{t2}</math> linked to bline [1]
 +
* <math>x^{[1]}_{2} = c^{[1]}_1(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[1]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[1]}_2) x^{[1]}_2</math> - because <math>x^{[1]}_2</math> belongs to bline [1]
 +
 
 +
<math>X^{[i]}_j</math> is a constant value of <math>x^{[i]}_j</math> and <math>\Delta X^{[i]}_{j}</math> is a constant value of <math>\Delta x^{[i]}_{j}</math>.
 +
<math>u^{[1]}_2</math> is a position of vertex 2 of bline [1] on the bline which it's linked to (i.e. bline [1]).
 +
 
 +
Transform:
 +
* <math>x^{[1]}_1 = X^{[1]}_1</math>
 +
* <math>\Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}</math>
 +
* <math>\Delta x^{[1]}_{t2} = c^{[1]}_{t1}(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_{t2}(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_{t3}(u^{[1]}_2) \Delta x^{[1]}_{t2} + (c^{[1]}_{t4}(u^{[1]}_2) - 1) x^{[1]}_2</math>
 +
* <math>c^{[1]}_1(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[1]}_2) \Delta x^{[1]}_{t1} + (c^{[1]}_3(u^{[1]}_2) -1) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[1]}_2) x^{[1]}_2 = 0</math>
 +
 
 +
So, we must solve the 4x4 matrix equation:
 +
<math>( \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 &0 \\ c^{[1]}_{t1}(u^{[1]}_2) & c^{[1]}_{t2}(u^{[1]}_2) & c^{[1]}_{t3}(u^{[1]}_2) & c^{[1]}_{t4}(u^{[1]}_2) \\ c^{[1]}_1(u^{[1]}_2) & c^{[1]}_2(u^{[1]}_2) & c^{[1]}_3(u^{[1]}_2) & c^{[1]}_4(u^{[1]}_2)  \end{pmatrix} -\begin{pmatrix} 0&0&0&0 \\ 0&0&0&0\\ 0&0&1&0 \\ 0&0&0&1\end{pmatrix})  \cdot \begin{pmatrix} x^{[1]}_1 \\ \Delta x^{[1]}_{t1} \\ \Delta x^{[1]}_{t2} \\ x^{[1]}_{2} \end{pmatrix} = \begin{pmatrix} X^{[1]}_1 \\ \Delta X^{[1]}_{t1} \\ 0 \\ 0 \end{pmatrix}</math>
 +
 
 +
=== Two splines ===
 +
 
 +
'''Case 1: Given Blines [1] and [2]. '''
 +
 
 +
'''Vertex 1 of bline [1] linked to bline [2].'''
 +
 
 +
'''Vertex 2 of bline [2] linked to bline [1].'''
 +
 
 +
http://zelgadis.profusehost.net/files/synfig/circular_references/cr07.jpg
 +
 
 +
For x coordinates we have following system of equations:
 +
 
 +
* <math>x^{[1]}_1 = c^{[2]}_1(u^{[1]}_1) x^{[2]}_1 + c^{[2]}_2(u^{[1]}_1) \Delta x^{[2]}_{t1} + c^{[2]}_3(u^{[1]}_1) \Delta x^{[2]}_{t2} + c^{[2]}_4(u^{[1]}_1) x^{[2]}_2</math> - because <math>x^{[1]}_1</math> belongs to bline [2]
 +
* <math>\Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}</math>
 +
* <math>\Delta x^{[1]}_{t2} = \Delta X^{[1]}_{t2}</math>
 +
* <math>x^{[1]}_2 = X^{[1]}_2</math>
 +
* <math>x^{[2]}_1 = X^{[2]}_1</math>
 +
* <math>\Delta x^{[2]}_{t1} = \Delta X^{[2]}_{t1}</math>
 +
* <math>\Delta x^{[2]}_{t2} = \Delta X^{[2]}_{t2}</math>
 +
* <math>x^{[2]}_{2} = c^{[1]}_1(u^{[2]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[2]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[2]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[2]}_2) x^{[1]}_2</math> - because <math>x^{[2]}_2</math> belongs to bline [1]
 +
 
 +
<math>X^{[i]}_j</math> is a constant value of <math>x^{[i]}_j</math> and <math>\Delta X^{[i]}_{j}</math> is a constant value of <math>\Delta x^{[i]}_{j}</math>.
 +
<math>u^{[2]}_2</math> is a position of vertex 2 of bline [2] on the bline which it's linked to (i.e. bline [1]).
 +
<math>u^{[1]}_1</math> is a position of vertex 1 of bline [1] on the bline which it's linked to (i.e. bline [2]).
 +
 
 +
Transform:
 +
 
 +
* <math>-x^{[1]}_1 + c^{[2]}_1(u^{[1]}_1) x^{[2]}_1 + c^{[2]}_2(u^{[1]}_1) \Delta x^{[2]}_{t1} + c^{[2]}_3(u^{[1]}_1) \Delta x^{[2]}_{t2} + c^{[2]}_4(u^{[1]}_1) x^{[2]}_2 = 0</math> - because <math>x^{[1]}_1</math> belongs to bline [2]
 +
* <math>\Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}</math>
 +
* <math>\Delta x^{[1]}_{t2} = \Delta X^{[1]}_{t2}</math>
 +
* <math>x^{[1]}_2 = X^{[1]}_2</math>
 +
* <math>x^{[2]}_1 = X^{[2]}_1</math>
 +
* <math>\Delta x^{[2]}_{t1} = \Delta X^{[2]}_{t1}</math>
 +
* <math>\Delta x^{[2]}_{t2} = \Delta X^{[2]}_{t2}</math>
 +
* <math>c^{[1]}_1(u^{[2]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[2]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[2]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[2]}_2) x^{[1]}_2 - x^{[2]}_{2} = 0</math> - because <math>x^{[2]}_2</math> belongs to bline [1]
 +
 
 +
 
 +
So, we must solve the 8x8 matrix equation:
 +
<math>(
 +
\begin{pmatrix}
 +
0 & 0 & 0 & 0 & c^{[2]}_1(u^{[1]}_1) & c^{[2]}_2(u^{[1]}_1) & c^{[2]}_3(u^{[1]}_1) & c^{[2]}_4(u^{[1]}_1)
 +
\\
 +
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0
 +
\\
 +
c^{[1]}_1(u^{[2]}_2) & c^{[1]}_2(u^{[2]}_2) & c^{[1]}_3(u^{[2]}_2) & c^{[1]}_4(u^{[2]}_2) & 0 & 0 & 0 & 0
 +
\end{pmatrix} - \begin{pmatrix}
 +
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
 +
\\
 +
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1
 +
\end{pmatrix})  \cdot \begin{pmatrix}
 +
x^{[1]}_1 \\ \Delta x^{[1]}_{t1} \\ \Delta x^{[1]}_{t2} \\ x^{[1]}_{2}
 +
\\
 +
x^{[2]}_1 \\ \Delta x^{[2]}_{t1} \\ \Delta x^{[2]}_{t2} \\ x^{[2]}_{2}
 +
\end{pmatrix} = \begin{pmatrix}
 +
0 \\ \Delta X^{[1]}_{t1} \\ \Delta X^{[1]}_{t2} \\ X^{[1]}_{2}
 +
\\
 +
X^{[2]}_1 \\ \Delta X^{[2]}_{t1} \\ \Delta X^{[2]}_{t2} \\ 0
 +
\end{pmatrix}</math>
 +
 
 +
== Conclusion ==
  
== Two splines ==
+
Maybe formulas are not correct, but I think you've got the idea:
...
+
For N Bline segments in loop we have 4N equations. If vertex is linked then we got appropriate equation, depending on what is linked. If vertex is not linked - just assigning constants.

Latest revision as of 13:03, 20 February 2010

WARNING: This text is under HEAVY development. Please be patient.

Main equations

  • 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_1,y_1), (x_2,y_2)} - vertices, defining bline segment
  • 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) } - current bline point
  • 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_{t1},y_{t1}), (x_{t2},y_{t2})} - tangent points defining bline segment
  • 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_{t},y_{t})} - tangent coordinates for current bline point
  • u - Amount of current segment, [0,1]
  • 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 (x_1,y_1) + 3 u(1-u)^2 (x_{t1},y_{t1}) + 3 u^2 (1-u) (x_{t2},y_{t2}) + u^3 (x_2,y_2)} - bline point

Relative tangents

O'kay, I know, the 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_{t1},y_{t1}), (x_{t2},y_{t2})} defining absolute position of tangents, but in synfig we have their coordinates relative to vertex. Moreover, coordinates of yellow tangent are inverted.

Let's say:

  • 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 (\Delta x_{t1},\Delta y_{t1})} and 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 (\Delta x_{t2},\Delta y_{t2})} - relative coordinates of tangents

Then:

  • 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_{t1},y_{t1}) = (x,y) + (\Delta x^{t1},\Delta y^{t1})}
  • 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_{t2},y_{t2}) = (x,y) - (\Delta x^{t2},\Delta y^{t2})}

Make substitution:

  • Bline point: 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-(3u^2-2u^3)) (x_1,y_1) + 3u(1-u)^2 (\Delta x_{t1},\Delta y_{t1}) - 3u^2(1-u) (\Delta x_{t2}, \Delta y_{t2}) + (3u^2-2u^3) (x_2,y_2)}

Tangent coordinates

<dooglus> look at etl/_calculus.h
<dooglus> class derivative<hermite<T> >
<dooglus>   T a = func[0], b = func[1], c = func[2], d = func[3];
<dooglus>   typename hermite<T>::argument_type y(1-x);
<dooglus>   return ((b-a)*y*y + (c-b)*x*y*2 + (d-c)*x*x) * 3;
Can't understand, why *3? --Zelgadis 05:31, 8 March 2008 (EST)

For x:

  • 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 \Delta x_{t} = (1-u)^2 \Delta x_{t1} + 2u(1-u) ((x_2 - \Delta x_{t2}) - (x_1 + \Delta x_{t1})) + u^2 \Delta x_{t2} = } 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 = -2u(1-u)x_1 + (1-u)(1-3u)\Delta x_{t1} + (3u^2 - 2u)\Delta x_{t2} + 2u(1-u)x_2}

Checking formulas

Well, I really wasn't sure if this formulas correct, that's why I did a little research and made some graphics and calculations. They are available here.

As result I got some final corrections to formulas (for x only):

  • Bline point: 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 = (1-(3u^2-2u^3)) x_1 + u(1-u)^2 \Delta x_{t1} - u^2(1-u) \Delta x_{t2} + (3u^2-2u^3) x_2}
  • Bline tangent: 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 \Delta x_{t} = -6u(1-u)x_1 + (1-u)(1-3u)\Delta x_{t1} + (3u^2 - 2u)\Delta x_{t2} + 6u(1-u)x_2}

Zelgadis, you wrong!

O'kay I understand what equations above could be wrong. But no one will argue what equations for bline point and tangents generally have form:

  • 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) = c_1(u) (x_1,y_1) + c_2(u) (x_{t1},y_{t1}) + c_3(u) (x_{t2},y_{t2}) + c_4(u) (x_2,y_2)}
  • 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 (\Delta x_{t},\Delta y_{t}) = c_{t1}(u) (x_1,y_1) + c_{t2}(u) (\Delta x_{t1}, \Delta y_{t1}) + c_{t3} (\Delta x_{t2}, \Delta y_{t2}) + c_{t4}(u) (x_2,y_2)}

where 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 c_i(u)} - some function from 'u' argument

So I will use this notation further.

For now we assume what:

  • 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 c_1(u)=1-(3u^2-2u^3)}
  • 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 c_2(u)=u(1-u)^2}
  • 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 c_3(u)=- u^2(1-u)}
  • 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 c_4(u)=3u^2-2u^3}
  • 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 c_{t1}(u)=-6u(1-u)}
  • 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 c_{t2}(u)=(1-u)(1-3u)}
  • 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 c_{t3}(u)=3u^2 - 2u}
  • 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 c_{t4}(u)=6u(1-u)}

General model

The problem: see Linking_to_Blines

So we need to determine position of vertex engaged in loop if she attachet ot some position of other bline.

NOTICE: We need such recalculation only for cases when in loop included only 1 segment from each bline. Like this:
cr02.jpg cr04.jpg
We don't need to do recalculation for cases like those:
attach-loop-simple.png

So, we have N blines (N bline segments) engaged in a loop.

To determine the x coordinate of vertex what finalizes the loop we need to solve matrix equation having form

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 (A - B)*\alpha = \beta}

NOTE: Solution formulas for y coordinate will be the same.
  • 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 A, B} - matrices 4N x 4N
  • 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 \alpha, \beta} - 4N column vectors
  • 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 \alpha} - is unknown quantity

Each line in matrix or column vector corresponding to particular vertex or it's tangent.

After solving system we will find column vector 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 \alpha} which have form: 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^{[1]}_1,\Delta x^{[1]}_{t1},\Delta x^{[1]}_{t2},x^{[1]}_2, x^{[2]}_1,\Delta x^{[2]}_{t1},\Delta x^{[2]}_{t2},x^{[2]}_2, ... ,x^{[N]}_1,\Delta x^{[N]}_{t1},\Delta x^{[N]}_{t2},x^{[N]}_2)} where 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^{[i]}_j} - point j of bline [i] and 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 \Delta x^{[i]}_tj} tangent of point j of bline i. From this vector we could retrieve x coordinate of desired vertex or tangent.

So:

  • the first line of each matrix or column vector corresponding to first vertex of first bline,
  • second line - corresponding to tangent of first vertex of first bline,
  • third line - to tangent of second vertex of first bline,
  • fourth - second vertex of first bline,
  • fifth - first vertex of second bline,
  • sixth - tangent of first vertex of second bline,
  • ...and so on...
NOTE: Talking about bline we are talking about single (!) segment of bline which engaged in loop. That's why I not specify which tangent (yellow or red) we using - it's always tangent for current segment.

Column vector 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 \beta} have following structure. If position of vertex/tangent corresponding to vector element is "static" (i.e. it's not linked any other bline segment of the loop) then vector element is 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 \beta_i} where 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 \beta_i} is current x coordinate of this vector/tangent. If vertex/tangent is not "static" then corresponding vector element is zero.

NOTE: When we calling vertex position "static" it's not means what vertex not linked to anything. The vertex could be linked to bline and still considered as "static" if that bline is not engaged into loop what we processing.

B matrix is zero-filled 4Nx4N matrix which we modifying in folowing way (rows and columns in matrix are numbered from 1):

  • if first vertex of bline [i] is linked to bline [j] then element at ( (i-1)*4+1 , (i-1)*4+1 ) = 1
  • if tangent of first vertex of bline [i] is linked to bline [j] then element at ( (i-1)*4+2 , (i-1)*4+2 ) = 1
  • if tangent of second vertex of bline [i] is linked to bline [j] then element at ( (i-1)*4+3 , (i-1)*4+3 ) = 1
  • if second vertex of bline [i] is linked to bline [j] then element at ( (i-1)*4+4 , (i-1)*4+4 ) = 1

A matrix is modified E matrix. 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 E = \begin{pmatrix} 1 & 0 & 0& ... & 0 \\ 0 & 1 & 0& ... & 0 \\ 0 & 0 & 1 & ... & 0 \\...&...&...&...&... \\ 0 & 0 & 0& ... & 1 \\ \end{pmatrix}}

It is modified in such way:

  • if first vertex of bline [i] is linked to bline [j] then element at position ( (i-1)*4+1, (i-1)*4+1 ) replaced with zero and elements in line (i-1)*4+1 at positions (j-1)*4+1, (j-1)*4+2, (j-1)*4+3, (j-1)*4+4 are replaced with 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 c^{[j]}_1(u^{[i]}_1), c^{[j]}_2(u^{[i]}_1), c^{[j]}_3(u^{[i]}_1), c^{[j]}_4(u^{[i]}_1)}
  • if tangent of first vertex of bline [i] is linked to bline [j] then element at position ( (i-1)*4+2, (i-1)*4+2 ) replaced with zero and elements in line (i-1)*4+2 at positions (j-1)*4+1, (j-1)*4+2, (j-1)*4+3, (j-1)*4+4 are replaced with 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 c^{[j]}_{t1}(u^{[i]}_1), c^{[j]}_{t2}(u^{[i]}_1), c^{[j]}_{t3}(u^{[i]}_1), c^{[j]}_{t4}(u^{[i]}_1)}
  • if tangent of second vertex of bline [i] is linked to bline [j] then element at position ( (i-1)*4+3, (i-1)*4+3 ) replaced with zero and elements in line (i-1)*4+3 at positions (j-1)*4+1, (j-1)*4+2, (j-1)*4+3, (j-1)*4+4 are replaced with 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 c^{[j]}_{t1}(u^{[i]}_2), c^{[j]}_{t2}(u^{[i]}_2), c^{[j]}_{t3}(u^{[i]}_2), c^{[j]}_{t4}(u^{[i]}_2)}
  • if second vertex of bline [i] is linked to bline [j] then element at position ( (i-1)*4+4, (i-1)*4+4 ) replaced with zero and elements in line (i-1)*4+4 at positions (j-1)*4+1, (j-1)*4+2, (j-1)*4+3, (j-1)*4+4 are replaced with 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 c^{[j]}_1(u^{[i]}_2), c^{[j]}_2(u^{[i]}_2), c^{[j]}_3(u^{[i]}_2), c^{[j]}_4(u^{[i]}_2)}

where 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 u^{[i]}_k} is a position of vertex/tangent k of bline [i] on bline which it's linked to.

Examples

Ok, I sure you guys are wondering how is this work. (I personally wondering IF this works or not :D). Let's view some examples.

One spline

Case 1: Given Bline [1]. Vertex 2 of bline [1] linked to bline [1].

cr05.jpg

For x coordinates we have following system of equations:

  • 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^{[1]}_1 = X^{[1]}_1}
  • 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 \Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}}
  • 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 \Delta x^{[1]}_{t2} = \Delta X^{[1]}_{t2}}
  • 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^{[1]}_{2} = c^{[1]}_1(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[1]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[1]}_2) x^{[1]}_2} - because 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^{[1]}_2} belongs to bline [1]

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^{[i]}_j} is a constant value of 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^{[i]}_j} and 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 \Delta X^{[i]}_{j}} is a constant value of 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 \Delta x^{[i]}_{j}} . 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 u^{[1]}_2} is a position of vertex 2 of bline [1] on the bline which it's linked to (i.e. bline [1]).

Transform:

  • 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^{[1]}_1 = X^{[1]}_1}
  • 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 \Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}}
  • 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 \Delta x^{[1]}_{t2} = \Delta X^{[1]}_{t2}}
  • 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 c^{[1]}_1(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[1]}_2) \Delta x^{[1]}_{t2} + (c^{[1]}_4(u^{[1]}_2) - 1) x^{[1]}_2 = 0}

So, we must solve the 4x4 matrix equation: 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 ( \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 &0 \\ 0 & 0 & 1 & 0 \\ c^{[1]}_1(u^{[1]}_2) & c^{[1]}_2(u^{[1]}_2) & c^{[1]}_3(u^{[1]}_2) & c^{[1]}_4(u^{[1]}_2) \end{pmatrix} -\begin{pmatrix} 0&0&0&0 \\ 0&0&0&0\\ 0&0&0&0 \\ 0&0&0&1\end{pmatrix}) \cdot \begin{pmatrix} x^{[1]}_1 \\ \Delta x^{[1]}_{t1} \\ \Delta x^{[1]}_{t2} \\ x^{[1]}_{2} \end{pmatrix} = \begin{pmatrix} X^{[1]}_1 \\ \Delta X^{[1]}_{t1} \\ \Delta X^{[1]}_{t2} \\ 0 \end{pmatrix}}


dooglus, can you check how this formula works in code? Something like:

  • Create bline with 2 points - 1 and 2
  • Select point 2, right click on bline -> "Link to bline"
  • Place (not link!) point 2 at the position calculated by this formula. If we'll have point 2 on bline after that then it's ok for now, if not - something wrong.


Case 2: Given Bline [1]. Vertex 2 of bline [1] linked to bline [1] with it's tangent. cr05.jpg

For x coordinates we have following system of equations:

  • 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^{[1]}_1 = X^{[1]}_1}
  • 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 \Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}}
  • 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 \Delta x^{[1]}_{t2} = c^{[1]}_{t1}(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_{t2}(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_{t3}(u^{[1]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_{t4}(u^{[1]}_2) x^{[1]}_2} - because tangent 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 \Delta x^{[1]}_{t2}} linked to bline [1]
  • 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^{[1]}_{2} = c^{[1]}_1(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[1]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[1]}_2) x^{[1]}_2} - because 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^{[1]}_2} belongs to bline [1]

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^{[i]}_j} is a constant value of 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^{[i]}_j} and 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 \Delta X^{[i]}_{j}} is a constant value of 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 \Delta x^{[i]}_{j}} . 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 u^{[1]}_2} is a position of vertex 2 of bline [1] on the bline which it's linked to (i.e. bline [1]).

Transform:

  • 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^{[1]}_1 = X^{[1]}_1}
  • 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 \Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}}
  • 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 \Delta x^{[1]}_{t2} = c^{[1]}_{t1}(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_{t2}(u^{[1]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_{t3}(u^{[1]}_2) \Delta x^{[1]}_{t2} + (c^{[1]}_{t4}(u^{[1]}_2) - 1) x^{[1]}_2}
  • 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 c^{[1]}_1(u^{[1]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[1]}_2) \Delta x^{[1]}_{t1} + (c^{[1]}_3(u^{[1]}_2) -1) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[1]}_2) x^{[1]}_2 = 0}

So, we must solve the 4x4 matrix equation: 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 ( \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 &0 \\ c^{[1]}_{t1}(u^{[1]}_2) & c^{[1]}_{t2}(u^{[1]}_2) & c^{[1]}_{t3}(u^{[1]}_2) & c^{[1]}_{t4}(u^{[1]}_2) \\ c^{[1]}_1(u^{[1]}_2) & c^{[1]}_2(u^{[1]}_2) & c^{[1]}_3(u^{[1]}_2) & c^{[1]}_4(u^{[1]}_2) \end{pmatrix} -\begin{pmatrix} 0&0&0&0 \\ 0&0&0&0\\ 0&0&1&0 \\ 0&0&0&1\end{pmatrix}) \cdot \begin{pmatrix} x^{[1]}_1 \\ \Delta x^{[1]}_{t1} \\ \Delta x^{[1]}_{t2} \\ x^{[1]}_{2} \end{pmatrix} = \begin{pmatrix} X^{[1]}_1 \\ \Delta X^{[1]}_{t1} \\ 0 \\ 0 \end{pmatrix}}

Two splines

Case 1: Given Blines [1] and [2].

Vertex 1 of bline [1] linked to bline [2].

Vertex 2 of bline [2] linked to bline [1].

cr07.jpg

For x coordinates we have following system of equations:

  • 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^{[1]}_1 = c^{[2]}_1(u^{[1]}_1) x^{[2]}_1 + c^{[2]}_2(u^{[1]}_1) \Delta x^{[2]}_{t1} + c^{[2]}_3(u^{[1]}_1) \Delta x^{[2]}_{t2} + c^{[2]}_4(u^{[1]}_1) x^{[2]}_2} - because 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^{[1]}_1} belongs to bline [2]
  • 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 \Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}}
  • 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 \Delta x^{[1]}_{t2} = \Delta X^{[1]}_{t2}}
  • 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^{[1]}_2 = X^{[1]}_2}
  • 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^{[2]}_1 = X^{[2]}_1}
  • 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 \Delta x^{[2]}_{t1} = \Delta X^{[2]}_{t1}}
  • 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 \Delta x^{[2]}_{t2} = \Delta X^{[2]}_{t2}}
  • 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^{[2]}_{2} = c^{[1]}_1(u^{[2]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[2]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[2]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[2]}_2) x^{[1]}_2} - because 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^{[2]}_2} belongs to bline [1]

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^{[i]}_j} is a constant value of 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^{[i]}_j} and 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 \Delta X^{[i]}_{j}} is a constant value of 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 \Delta x^{[i]}_{j}} . 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 u^{[2]}_2} is a position of vertex 2 of bline [2] on the bline which it's linked to (i.e. bline [1]). 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 u^{[1]}_1} is a position of vertex 1 of bline [1] on the bline which it's linked to (i.e. bline [2]).

Transform:

  • 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^{[1]}_1 + c^{[2]}_1(u^{[1]}_1) x^{[2]}_1 + c^{[2]}_2(u^{[1]}_1) \Delta x^{[2]}_{t1} + c^{[2]}_3(u^{[1]}_1) \Delta x^{[2]}_{t2} + c^{[2]}_4(u^{[1]}_1) x^{[2]}_2 = 0} - because 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^{[1]}_1} belongs to bline [2]
  • 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 \Delta x^{[1]}_{t1} = \Delta X^{[1]}_{t1}}
  • 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 \Delta x^{[1]}_{t2} = \Delta X^{[1]}_{t2}}
  • 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^{[1]}_2 = X^{[1]}_2}
  • 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^{[2]}_1 = X^{[2]}_1}
  • 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 \Delta x^{[2]}_{t1} = \Delta X^{[2]}_{t1}}
  • 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 \Delta x^{[2]}_{t2} = \Delta X^{[2]}_{t2}}
  • 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 c^{[1]}_1(u^{[2]}_2) x^{[1]}_1 + c^{[1]}_2(u^{[2]}_2) \Delta x^{[1]}_{t1} + c^{[1]}_3(u^{[2]}_2) \Delta x^{[1]}_{t2} + c^{[1]}_4(u^{[2]}_2) x^{[1]}_2 - x^{[2]}_{2} = 0} - because 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^{[2]}_2} belongs to bline [1]


So, we must solve the 8x8 matrix equation: 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 ( \begin{pmatrix} 0 & 0 & 0 & 0 & c^{[2]}_1(u^{[1]}_1) & c^{[2]}_2(u^{[1]}_1) & c^{[2]}_3(u^{[1]}_1) & c^{[2]}_4(u^{[1]}_1) \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ c^{[1]}_1(u^{[2]}_2) & c^{[1]}_2(u^{[2]}_2) & c^{[1]}_3(u^{[2]}_2) & c^{[1]}_4(u^{[2]}_2) & 0 & 0 & 0 & 0 \end{pmatrix} - \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{pmatrix}) \cdot \begin{pmatrix} x^{[1]}_1 \\ \Delta x^{[1]}_{t1} \\ \Delta x^{[1]}_{t2} \\ x^{[1]}_{2} \\ x^{[2]}_1 \\ \Delta x^{[2]}_{t1} \\ \Delta x^{[2]}_{t2} \\ x^{[2]}_{2} \end{pmatrix} = \begin{pmatrix} 0 \\ \Delta X^{[1]}_{t1} \\ \Delta X^{[1]}_{t2} \\ X^{[1]}_{2} \\ X^{[2]}_1 \\ \Delta X^{[2]}_{t1} \\ \Delta X^{[2]}_{t2} \\ 0 \end{pmatrix}}

Conclusion

Maybe formulas are not correct, but I think you've got the idea: For N Bline segments in loop we have 4N equations. If vertex is linked then we got appropriate equation, depending on what is linked. If vertex is not linked - just assigning constants.