LaTeX/TikZ Interpolation and animation for Inkscape

Discussion about writing code for Inkscape.
branco22000
Posts: 5
Joined: Mon Jun 11, 2012 8:13 pm

LaTeX/TikZ Interpolation and animation for Inkscape

Postby branco22000 » Fri Aug 31, 2012 1:05 am

i want to develop an extension to interpolate animated diagrams on inkscape.
SVG should be drawn in Inkscape and can be saved as .Tex.

The idea is Drawing in Inkscape and producing a Match in TeX that can be compiled with a tex editor. When drawing on inkscape, User can specify points (in an Interpolated form) and an animation can occur through the points.

to have a visual idea of what i mean, you can check:

http://www.texample.net/tikz/examples/a ... -integral/

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: LaTeX/TikZ Interpolation and animation for Inkscape

Postby Ailurus » Sun Sep 02, 2012 8:40 pm

Hi,

Yesterday I read this topic as well and for some reason I thought you meant interpolating between frames of an animation. That means, you'd draw two frames, and then would create some frames in between by interpolating these two.

But I just read it again, and now I get it (I guess :D). So the user simply draws some points, and these points should be interpolated. Interesting!

My knowledge of LaTeX is quite okay, but I don't have much experience with TikZ. My first thought would be to use (uniform) Lagrange interpolation, and let the degree depend on the number of points. That would mean 2 points = linear, 3 points = quadratic, 4 points = cubic and so on.

The reason to use uniform Lagrange polynomials is to make the process a little easier, otherwise you'd have to indicate which value for t to choose at each point (quadratic example, first point t=0, second point t=1, third point t=2).

Using a similar construction as the example you linked to should enable you to increase the value for t each animation step (and then draw the curve from 0 to t).

Hope that was helpful, keep us posted about any progress, sounds like an interesting extension.

branco22000
Posts: 5
Joined: Mon Jun 11, 2012 8:13 pm

Re: LaTeX/TikZ Interpolation and animation for Inkscape

Postby branco22000 » Mon Sep 03, 2012 1:31 am

Hi Ailurus,
Thanks for your contribution for the inkscape interpolation.
However, i dont have an idea on how to excecute it.
Is there any way to help? even if the services can be paid for..
Ill appriciate a reply
Thank you

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: LaTeX/TikZ Interpolation and animation for Inkscape

Postby Ailurus » Tue Sep 04, 2012 7:54 am

Hi,

Does this LaTeX/TikZ code work on your system?
http://www.texample.net/tikz/examples/gnuplot-basics/

I'll try to write a static interpolation code, that interpolates some given control points. What you'd have to write is:

- Code to read the SVG (in particular the control points) created by Inkscape, and convert it to TikZ nodes
- Animate it in the same way as in the code you referred to

branco22000
Posts: 5
Joined: Mon Jun 11, 2012 8:13 pm

Re: LaTeX/TikZ Interpolation and animation for Inkscape

Postby branco22000 » Tue Sep 04, 2012 9:49 pm

/hi,
yes it works on my system.
Ok Thanks, ill appriciate the interpolation code.

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: LaTeX/TikZ Interpolation and animation for Inkscape

Postby Ailurus » Wed Sep 05, 2012 12:24 am

Ok, here you go. It is a quadratic Lagrange curve that interpolates three points.

Code: Select all

% Requires GNUPLOT!

\documentclass{beamer}
%\usepackage{animate}
\usepackage{tikz}

\usepackage[active,floats,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}

\begin{document}

% Three control points -- A, B, and C, e.g.
% A = (2.0, 1.0)
% B = (4.0, 5.0)
% C = (7.0, 3.0)

% Store x coordinates (PAx = Point A x-coordinate, ...)
\def\PAx{2.0}
\def\PBx{4.0}
\def\PCx{7.0}

% Store y coordinates (PAy = Point A y-coordinate, ...)
\def\PAy{1.0}
\def\PBy{5.0}
\def\PCy{3.0}

% Three uniform Lagrange basis functions, t in [0,1]
% 2*t^2 - 3*t + 1
% -4*t^2 + 4*t
% 2*t^2 - t

\def\LA{(2*t**2 - 3*t + 1)}
\def\LB{(-4*t**2 + 4*t)}
\def\LC{(2*t**2 - t)}

\def\Radius{0.1}

% First interval will be empty [0.0, 0.0]
% Second will be [0.0, 0.25]

\foreach \a in {0.0,0.1,...,1}{
\begin{tikzpicture}[scale=1.2,domain=0.0:\a,smooth]
\draw [fill] (\PAx,\PAy) circle [radius=\Radius];
\draw [fill] (\PBx,\PBy) circle [radius=\Radius];
\draw [fill] (\PCx,\PCy) circle [radius=\Radius];
\draw plot[parametric,id=curve] function{ \PAx*\LA + \PBx*\LB + \PCx*\LC, \PAy*\LA + \PBy*\LB + \PCy*\LC };
\end{tikzpicture}}

\end{document}


In order to animate it, save it as "InterpolatingPoints.tex" (or something different), and then create a new tex file that looks like this

Code: Select all

\documentclass{beamer}
\usepackage{animate}

\begin{document}

\begin{frame}
\frametitle{Testing...}
\centering
\animategraphics{2}{InterpolatingPoints}{}{}
\end{frame}

\end{document}


I'm still working on how to do the animation within the same document. Did you make any progress on converting the control points in the SVG file to LaTeX / TikZ code?

branco22000
Posts: 5
Joined: Mon Jun 11, 2012 8:13 pm

Re: LaTeX/TikZ Interpolation and animation for Inkscape

Postby branco22000 » Wed Sep 05, 2012 8:14 pm

Thanks for the reply.

I have a code for converting Inscape to SVG. (I can send it to you to view) it does animation in layers. However, i dot understand the interpolation part of it as per converting the control part. Ill send it to you soon.
thanks for the efforts in helping me


Return to “Programming”