blob: 0f83639c8c7d45d8c5a1552584b2f25e7e7839d4 [file] [log] [blame]
Tony-LunarGb0b195d2015-05-13 15:01:06 -06001///////////////////////////////////////////////////////////////////////////////////
2/// OpenGL Mathematics (glm.g-truc.net)
3///
4/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
5/// Permission is hereby granted, free of charge, to any person obtaining a copy
6/// of this software and associated documentation files (the "Software"), to deal
7/// in the Software without restriction, including without limitation the rights
8/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9/// copies of the Software, and to permit persons to whom the Software is
10/// furnished to do so, subject to the following conditions:
11///
12/// The above copyright notice and this permission notice shall be included in
13/// all copies or substantial portions of the Software.
14///
15/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21/// THE SOFTWARE.
22///
23/// @ref core
24/// @file glm/core/func_geometric.hpp
25/// @date 2008-08-03 / 2011-06-14
26/// @author Christophe Riccio
27///
28/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
29///
30/// @defgroup core_func_geometric Geometric functions
31/// @ingroup core
32///
33/// These operate on vectors as vectors, not component-wise.
34///////////////////////////////////////////////////////////////////////////////////
35
36#ifndef glm_core_func_geometric
37#define glm_core_func_geometric
38
39#include "type_vec3.hpp"
40
41namespace glm
42{
43 /// @addtogroup core_func_geometric
44 /// @{
45
46 /// Returns the length of x, i.e., sqrt(x * x).
47 ///
48 /// @tparam genType Floating-point vector types.
49 ///
50 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
51 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
52 template <typename genType>
53 GLM_FUNC_DECL typename genType::value_type length(
54 genType const & x);
55
56 /// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
57 ///
58 /// @tparam genType Floating-point vector types.
59 ///
60 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
61 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
62 template <typename genType>
63 GLM_FUNC_DECL typename genType::value_type distance(
64 genType const & p0,
65 genType const & p1);
66
67 /// Returns the dot product of x and y, i.e., result = x * y.
68 ///
69 /// @tparam genType Floating-point vector types.
70 ///
71 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
72 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
73 template <typename T, precision P, template <typename, precision> class vecType>
74 GLM_FUNC_DECL T dot(
75 vecType<T, P> const & x,
76 vecType<T, P> const & y);
77
78 /// Returns the dot product of x and y, i.e., result = x * y.
79 ///
80 /// @tparam genType Floating-point vector types.
81 ///
82 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
83 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
84 template <typename genType>
85 GLM_FUNC_DECL genType dot(
86 genType const & x,
87 genType const & y);
88
89 /// Returns the cross product of x and y.
90 ///
91 /// @tparam valType Floating-point scalar types.
92 ///
93 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a>
94 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
95 template <typename T, precision P>
96 GLM_FUNC_DECL detail::tvec3<T, P> cross(
97 detail::tvec3<T, P> const & x,
98 detail::tvec3<T, P> const & y);
99
100 /// Returns a vector in the same direction as x but with length of 1.
101 ///
102 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a>
103 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
104 template <typename genType>
105 GLM_FUNC_DECL genType normalize(
106 genType const & x);
107
108 /// If dot(Nref, I) < 0.0, return N, otherwise, return -N.
109 ///
110 /// @tparam genType Floating-point vector types.
111 ///
112 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a>
113 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
114 template <typename genType>
115 GLM_FUNC_DECL genType faceforward(
116 genType const & N,
117 genType const & I,
118 genType const & Nref);
119
120 /// For the incident vector I and surface orientation N,
121 /// returns the reflection direction : result = I - 2.0 * dot(N, I) * N.
122 ///
123 /// @tparam genType Floating-point vector types.
124 ///
125 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a>
126 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
127 template <typename genType>
128 GLM_FUNC_DECL genType reflect(
129 genType const & I,
130 genType const & N);
131
132 /// For the incident vector I and surface normal N,
133 /// and the ratio of indices of refraction eta,
134 /// return the refraction vector.
135 ///
136 /// @tparam genType Floating-point vector types.
137 ///
138 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a>
139 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
140 template <typename T, precision P, template <typename, precision> class vecType>
141 GLM_FUNC_DECL vecType<T, P> refract(
142 vecType<T, P> const & I,
143 vecType<T, P> const & N,
144 T const & eta);
145
146 /// @}
147}//namespace glm
148
149#include "func_geometric.inl"
150
151#endif//glm_core_func_geometric