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

From Synfig Studio :: Documentation
Jump to: navigation, search
(One spline)
m (Main equations: rearrangement)
Line 8: Line 8:
  
 
* <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^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^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^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
  
Finding tangents:
+
== How I found tangents formula ==
 +
 
 +
A,B,C,D defining spline segment. A,D - verticles, B,C - tangents.
  
 
* put a point on each line, some percentage of the way along each
 
* put a point on each line, some percentage of the way along each
Line 18: Line 22:
 
** 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>
 
** 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>
 
** 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:
+
** T1 on (M,N): <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
 
+
** T2 on (N,K): <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^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^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
+
  
 
== One spline ==
 
== One spline ==

Revision as of 20:46, 7 March 2008

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)} - points of bline vertex
  • 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_1,y^t_1), (x^t_2,y^t_2)} - tangent points
  • 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^t_L,y^t_L), (x^t_N,y^t_N)} - tangents of current 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^t_1,y^t_1) + 3 u^2 (1-u) (x^t_2,y^t_2) + u^3 (x_2,y_2)} - 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^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)} - yellow tangent of 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^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)} - red tangent of bline point

How I found tangents formula

A,B,C,D defining spline segment. A,D - verticles, B,C - tangents.

  • put a point on each line, some percentage of the way along each
    • M on (A,B): 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)(1-u) + (x^t_1,y^t_1)u}
    • N on (B,C): 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_1,y^t_1)(1-u) + (x^t_2,y^t_2)u}
    • K on (C,D): 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_2,y^t_2)(1-u) + (x^2,y^2)u}
  • 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): 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 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}
    • T2 on (N,K): 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 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}
  • then:
    • T1 on (M,N): 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_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)} - yellow tangent of bline point
    • T2 on (N,K): 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_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)} - red tangent of bline point

One spline

Case: Bline A. A2 linked to A (with tangent).

A2 with its tangent belongs to A, so:

  • 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_{A2} = (1-u)^3 x_{A1} + 3u(1-u)^2 x^t_{A1} + 3u^2(1-u) x^t_{A2} + u^3 x_{A2}}
  • 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_{A2} = (1-u)^2 x_{A1} + 2u(1-u) x^t_{A1} + u^2 x^t_{A2}}

Let's find 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_{A2}} 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 x^t_{A2}} :

  • 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_{A2} = \frac{(1-u)^3 x_{A1} + 3u(1-u)^2 x^t_{A1} + 3u^2(1-u) x^t_{A2} }{1 - u^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 x^t_{A2} = \frac{(1-u)^2 x_{A1} + 2u(1-u) x^t_{A1}} {1- u^2 }}

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:

  • Create bline with 2 points - A1,A2
  • Select point A2, 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.

I know we need a general formula but if this won't work then I definitely not right.

Two splines

...