1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) Serge Steer
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2018-2019 - Samuel GOUGEON
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
15 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
16 xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
17 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
18 xml:lang="en_US" xml:id="comet">
20 <refname>comet</refname>
21 <refpurpose>2D comet animated plot</refpurpose>
31 comet(..., "colors",c)
35 <title>Parameters</title>
40 a real vector or matrix. If omitted, it is assumed to be the vector
41 <literal>1:np</literal> where <literal>np</literal> is the total number of
42 curve points (see below). As a matrix, each column defines the abscissae
43 of the trace of a separate comet.
50 a real vector or matrix. As a matrix, each column defines the ordinates
51 of the trace of a separate comet.
52 <literal>nc=size(y,"c")</literal> is the number of comets simultaneously drawn.
59 a real scalar in the interval<literal>[0,1[</literal>. Default value is 0.1:
60 It defines the Leading fraction of the comet's trace.
61 The <literal>k=Lf*np</literal> most recent points are plotted in thicker line.
68 a scilab function with syntax <literal>y = fun(x)</literal>.
69 <varname>fun</varname> can also be a polynomial or a rational fraction.
76 <literal>nc</literal> colors of the <literal>nc</literal> comets traces.
77 They may be specified as a vector of <literal>nc</literal> color indices or
78 <link linkend="color_list">color names</link> or "#RRGGBB" hexadecimal
79 color codes. Or by a matrix (ncx3) of <literal>[r,g,b]</literal> vectors of
80 Red-Green-Blue intensities in the [0,1] interval.
87 <title>Description</title>
89 If <literal>(x,y)</literal> are two vectors, this function draws a 2D comet animated
90 plot showing the progression of the curve <literal>(x(1:m),y(1:m))</literal> for
91 <literal>m</literal> varying from <literal>1</literal> to
92 <literal>np=length(x)</literal>.
95 The plot is made of three parts:
97 <tr><td><emphasis role="bold">a head</emphasis></td>
99 mark that shows the current <literal>(x(i),y(i))</literal> position.
102 <tr><td><emphasis role="bold">a body</emphasis></td>
103 <td>consisting in the <literal>k=round(Lf*np)</literal> most recent points
104 of the trajectory, displayed as a thicker part of the trace.
107 <tr><td><emphasis role="bold">a tail</emphasis></td>
109 that shows the <literal>(x(1:i-k),y(1:i-k))</literal> part of the curve.
114 <literal>comet(x,fun,...)</literal> is equivalent to
115 <literal>comet(x, feval(x,fun),...)</literal>.
118 If <varname>x</varname> and <varname>y</varname> are matrices with identical sizes,
119 then animated curves are drawn for each pair <literal>(x(:,j),y(:,j))</literal>.
120 In this case <literal>np</literal> is the number of rows of
121 <varname>x</varname> and <varname>y</varname>.
124 <literal>comet(...,"colors",c)</literal> can be used to set the colors of each
130 <title>Examples</title>
131 <programlisting role="example"><![CDATA[
132 // One comet in spiral:
133 t = linspace(0, 10*%pi, 500);
135 comet(t.*sin(t), t.*cos(t), "colors", "orange")
139 <imagedata fileref="../../images/comet_1.png"/>
143 <programlisting role="example"><![CDATA[
144 // Two simultaneous comets with default colors:
145 t = linspace(0, 10*%pi, 500)';
147 comet(t.*sin(t), [t.*sin(2*t) t.*sin(3*t)])
150 <programlisting role="example"><![CDATA[
152 t = linspace(0, 10*%pi, 500)';
154 comet(t.*sin(t), [t.*cos(t) t.*sin(2*t)], "colors", ["orange" "mag"])
158 <imagedata fileref="../../images/comet_2.png"/>
162 <programlisting role="example"><![CDATA[
167 comet(linspace(0,5,500),traj)
170 <programlisting role="example"><![CDATA[
172 comet(linspace(-2,4,500), (%s-3)/(%s^3+2*%s^2+1))
175 <refsection role="see also">
176 <title>See also</title>
177 <simplelist type="inline">
179 <link linkend="comet3d">comet3d</link>
182 <link linkend="paramfplot2d">paramfplot2d</link>
185 <link linkend="realtime">realtime</link>
188 <link linkend="color_list">colors names</link>
193 <title>History</title>
196 <revnumber>5.3.2</revnumber>
198 Function comet() introduced.
202 <revnumber>6.1.0</revnumber>
204 Colors can now be specified also by their name, or by their "#RRGGBB" hexadecimal
205 code, or by their [r g b] Red-Green-Blue intensities.