<!DOCTYPE refentry [ <!ENTITY % mathent SYSTEM "math.ent"> %mathent; ]>

<!-- Converted by db4-upgrade version 1.1 -->

<refentry xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="mix">
    <info>
        <copyright>
            <year>2011-2015</year>
            <holder>Khronos Group</holder>
        </copyright>
    </info>
    <refmeta>
        <refentrytitle>mix</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>mix</refname>
        <refpurpose>linearly interpolate between two values</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Declaration</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>genType <function>mix</function></funcdef>
                <paramdef>genType <parameter>x</parameter></paramdef>
                <paramdef>genType <parameter>y</parameter></paramdef>
                <paramdef>genType <parameter>a</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
        <funcsynopsis>
            <funcprototype>
                <funcdef>genType <function>mix</function></funcdef>
                <paramdef>genType <parameter>x</parameter></paramdef>
                <paramdef>genType <parameter>y</parameter></paramdef>
                <paramdef>float <parameter>a</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
        <funcsynopsis>
            <funcprototype>
                <funcdef>genType <function>mix</function></funcdef>
                <paramdef>genType <parameter>x</parameter></paramdef>
                <paramdef>genType <parameter>y</parameter></paramdef>
                <paramdef>genBType <parameter>a</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 xml:id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>x</parameter></term>
            <listitem>
                <para>
                    Specify the start of the range in which to interpolate.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>y</parameter></term>
            <listitem>
                <para>
                    Specify the end of the range in which to interpolate.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>a</parameter></term>
            <listitem>
                <para>
                    Specify the value to use to interpolate between <parameter>x</parameter> and <parameter>y</parameter>.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 xml:id="description"><title>Description</title>
        <para>
            <function>mix</function> performs a linear interpolation between <parameter>x</parameter>
            and <parameter>y</parameter> using <parameter>a</parameter> to weight between them. The return value
            is computed as follows:
            <inlineequation>
                <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                    <mml:mi>x</mml:mi>
                    <mml:mo lspace="2px" rspace="2px">&sdot;</mml:mo>
                    <mml:mo stretchy="false">(</mml:mo>
                    <mml:mn>1</mml:mn>
                    <mml:mo>&minus;</mml:mo>
                    <mml:mi>a</mml:mi>
                    <mml:mo stretchy="false">)</mml:mo>
                    <mml:mo>+</mml:mo>
                    <mml:mi>y</mml:mi>
                    <mml:mo lspace="2px" rspace="2px">&sdot;</mml:mo>
                    <mml:mi>a</mml:mi>
                </mml:math>
            </inlineequation>.
        </para>
        <para>
            For the variants of <function>mix</function> where <parameter>a</parameter> is <constant>genBType</constant>,
            elements for which <parameter>a</parameter>[<emphasis>i</emphasis>] is <constant>false</constant>, the result for that
            element is taken from <parameter>x</parameter>, and where <parameter>a</parameter>[<emphasis>i</emphasis>] is
            <constant>true</constant>, it will be taken from <parameter>y</parameter>. Components of <parameter>x</parameter>
                        and <parameter>y</parameter> that are not selected are allowed to be invalid floating point values and will have no effect
                        on the results.
        </para>
    </refsect1>
    <refsect1 xml:id="versions"><title>Version Support</title>
        <informaltable>
            <tgroup cols="5" align="left">
                <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="funchead.xml" xpointer="xpointer(/*/*)"/>
                <tbody>
                    <row>
                        <entry>mix (genType)</entry>
                        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="version.xml" xpointer="xpointer(/*/*[@role='es10']/*)"/>
                    </row>
                    <row>
                        <entry>mix (genBType)</entry>
                        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="version.xml" xpointer="xpointer(/*/*[@role='es30']/*)"/>
                    </row>
                </tbody>
            </tgroup>
        </informaltable>
    </refsect1>
    <refsect1 xml:id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>min</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>max</refentrytitle></citerefentry>
        </para>
    </refsect1>
    <refsect1 xml:id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"/> 2011-2015 Khronos Group.
            This material may be distributed subject to the terms and conditions set forth in
            the Open Publication License, v 1.0, 8 June 1999.
            <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://opencontent.org/openpub/">http://opencontent.org/openpub/</link>.
        </para>
    </refsect1>
</refentry>
