<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) ENPC - Jean-Philippe Chancelier
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"  xml:lang="en" xml:id="champ">
    <refnamediv>
        <refname>champ</refname>
        <refpurpose>2D vector field plot</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            champ(x, y, fx, fy, [arfact, rect, strf])
            champ(x, y, fx, fy, &lt;opt_args&gt;)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>x, y</term>
                <listitem>
                    <para>two vectors which define the grid.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>fx</term>
                <listitem>
                    <para>
                        a matrix which describes the x component of the vector
                        field. <literal>fx(i,j)</literal> is the x
                        component of the vector field at point
                        <literal>(x(i),y(j))</literal>.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>fy</term>
                <listitem>
                    <para>
                        a matrix which describes the y component of the vector
                        field. <literal>fy(i,j)</literal> is the y component of
                        the vector field at point <literal>(x(i),y(j))</literal>.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>&lt;opt_args&gt;</term>
                <listitem>
                    <para>
                        This represents a sequence of statements
                        <literal>key1=value1, key2=value2</literal>,... where
                        <literal>key1</literal>, <literal>key2</literal>,... can
                        be one of the following: <varname>arfact</varname>,
                        <varname>rect</varname>, <varname>strf</varname> (see below).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>arfact</term>
                <listitem>
                    <para>
                        an optional argument of type <literal>real</literal>
                        which gives a scale factor for the display of the arrow
                        heads on the plot (default value is
                        <literal>1.0</literal>).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>rect</term>
                <listitem>
                    <para>
                        a vector <literal>rect=[xmin, ymin, xmax, ymax]</literal>
                        which gives the boundaries of the graphics frame to use.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>strf</term>
                <listitem>
                    <para>
                        a string of length 3 "xyz" which has the same meaning as
                        the <varname>strf</varname> parameter of
                        <function>plot2d</function>. The first  character
                        <literal>x</literal> has no effect with
                        <function>champ</function>.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <function>champ</function> draws a 2D vector field. The length of
            the arrows is proportional to the intensity of the field.
        </para>
        <para>
            If you want colored arrows with the color of the arrows depending on
            the intensity of the field, set <literal>gce().colored = "on"</literal>.
        </para>
        <para>
            Enter the command <code>champ()</code> to see a demo.
        </para>
        <para>
            Be cautioned about the fact that using <link linkend="meshgrid">meshgrid</link> function before
            using <code>champ</code> requires adjustment. For more details, see the last example below.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
// using rect as plot boundaries
champ(-5:5,-5:5,rand(11,11),rand(11,11),rect=[-10,-10,10,10],arfact=2)
 ]]></programlisting>
        <scilab:image>
            champ(-5:5,-5:5,rand(11,11),rand(11,11),rect=[-10,-10,10,10],arfact=2);
        </scilab:image>
        <programlisting role="example"><![CDATA[
// using (x,y) to get boundaries
clf()
champ(-5:5,-5:5,rand(11,11),rand(11,11),2,[-10,-10,10,10],"021")
 ]]></programlisting>
        <scilab:image>
            champ(-5:5,-5:5,rand(11,11),rand(11,11),2,[-10,-10,10,10],"021")
        </scilab:image>
        <programlisting role="example"><![CDATA[
// using meshgrid to get fx and fy
clf()
x = linspace(-1,1,30);
y = linspace(-1,1,30);
[X,Y] = meshgrid(x,y);
fy = 2.*Y;
fx = 2.*X;
champ(x,y,fx',fy'); //here we have transposed fx and fy
]]></programlisting>
        <scilab:image>
            x = linspace(-1,1,30);
            y = linspace(-1,1,30);
            [X,Y] = meshgrid(x,y);
            fy = 2.*Y;
            fx = 2.*X;
            champ(x,y,fx',fy');
        </scilab:image>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="fchamp">fchamp</link>
            </member>
            <member>
                <link linkend="xarrows">xarrows</link>
            </member>
            <member>
                <link linkend="polyline_properties">Arrowed polyline</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
