8a369fbaf208fca6dffa66bb6043315e980d4d6a
[clinton/guile-figl.git] / upstream-man-pages / manglsl / refract.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id="refract">
5 <refmeta>
6 <refmetainfo>
7 <copyright>
8 <year>2011</year>
9 <holder>Khronos Group</holder>
10 </copyright>
11 </refmetainfo>
12 <refentrytitle>refract</refentrytitle>
13 <manvolnum>3G</manvolnum>
14 </refmeta>
15 <refnamediv>
16 <refname>refract</refname>
17 <refpurpose>calculate the refraction direction for an incident vector</refpurpose>
18 </refnamediv>
19 <refsynopsisdiv><title>Declaration</title>
20 <funcsynopsis>
21 <funcprototype>
22 <funcdef>genType <function>refract</function></funcdef>
23 <paramdef>genType <parameter>I</parameter></paramdef>
24 <paramdef>genType <parameter>N</parameter></paramdef>
25 <paramdef>float <parameter>eta</parameter></paramdef>
26 </funcprototype>
27 <funcprototype>
28 <funcdef>genDType <function>refract</function></funcdef>
29 <paramdef>genDType <parameter>I</parameter></paramdef>
30 <paramdef>genDType <parameter>N</parameter></paramdef>
31 <paramdef>float <parameter>eta</parameter></paramdef>
32 </funcprototype>
33 </funcsynopsis>
34 </refsynopsisdiv>
35 <refsect1 id="parameters"><title>Parameters</title>
36 <variablelist>
37 <varlistentry>
38 <term><parameter>I</parameter></term>
39 <listitem>
40 <para>
41 Specifies the incident vector.
42 </para>
43 </listitem>
44 </varlistentry>
45 <varlistentry>
46 <term><parameter>N</parameter></term>
47 <listitem>
48 <para>
49 Specifies the normal vector.
50 </para>
51 </listitem>
52 </varlistentry>
53 <varlistentry>
54 <term><parameter>eta</parameter></term>
55 <listitem>
56 <para>
57 Specifies the ratio of indices of refraction.
58 </para>
59 </listitem>
60 </varlistentry>
61 </variablelist>
62 </refsect1>
63 <refsect1 id="description"><title>Description</title>
64 <para>
65 For a given incident vector <parameter>I</parameter>, surface normal <parameter>N</parameter> and ratio of
66 indices of refraction, <parameter>eta</parameter>, <function>refract</function> returns the refraction vector,
67 <parameter>R</parameter>.
68 </para>
69 <para>
70 <parameter>R</parameter> is calculated as:
71 </para>
72 <para>
73 <programlisting><![CDATA[ k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
74 if (k < 0.0)
75 R = genType(0.0); // or genDType(0.0)
76 else
77 R = eta * I - (eta * dot(N, I) + sqrt(k)) * N;]]></programlisting>
78 </para>
79 <para>
80 The input parameters <parameter>I</parameter> and <parameter>N</parameter> should be normalized in order to achieve the desired result.
81 </para>
82 </refsect1>
83 <refsect1 id="versions"><title>Version Support</title>
84 <informaltable frame="topbot">
85 #VARTABLECOLS#
86 <thead>
87 #FUNCTABLEHEADER#
88 <row>
89 <entry>refract (genType)</entry>#newin11#
90 </row>
91 <row>
92 <entry>refract (genDType)</entry>#newin40#
93 </row>
94 </thead>
95 </tgroup>
96 </informaltable>
97 </refsect1>
98 <refsect1 id="seealso"><title>See Also</title>
99 <para>
100 <citerefentry><refentrytitle>dot</refentrytitle></citerefentry>,
101 <citerefentry><refentrytitle>reflect</refentrytitle></citerefentry>
102 </para>
103 </refsect1>
104 <refsect1 id="Copyright"><title>Copyright</title>
105 <para>
106 Copyright <trademark class="copyright"></trademark> 2011 Khronos Group.
107 This material may be distributed subject to the terms and conditions set forth in
108 the Open Publication License, v 1.0, 8 June 1999.
109 <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>.
110 </para>
111 </refsect1>
112 </refentry>