| 1 | /// @ref core |
| 2 | /// @file glm/geometric.hpp |
| 3 | /// |
| 4 | /// @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> |
| 5 | /// |
| 6 | /// @defgroup core_func_geometric Geometric functions |
| 7 | /// @ingroup core |
| 8 | /// |
| 9 | /// These operate on vectors as vectors, not component-wise. |
| 10 | /// |
| 11 | /// Include <glm/geometric.hpp> to use these core features. |
| 12 | |
| 13 | #pragma once |
| 14 | |
| 15 | #include "detail/type_vec3.hpp" |
| 16 | |
| 17 | namespace glm |
| 18 | { |
| 19 | /// @addtogroup core_func_geometric |
| 20 | /// @{ |
| 21 | |
| 22 | /// Returns the length of x, i.e., sqrt(x * x). |
| 23 | /// |
| 24 | /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. |
| 25 | /// @tparam T Floating-point scalar types. |
| 26 | /// |
| 27 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a> |
| 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 | template<length_t L, typename T, qualifier Q> |
| 30 | GLM_FUNC_DECL T length(vec<L, T, Q> const& x); |
| 31 | |
| 32 | /// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). |
| 33 | /// |
| 34 | /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. |
| 35 | /// @tparam T Floating-point scalar types. |
| 36 | /// |
| 37 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a> |
| 38 | /// @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> |
| 39 | template<length_t L, typename T, qualifier Q> |
| 40 | GLM_FUNC_DECL T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1); |
| 41 | |
| 42 | /// Returns the dot product of x and y, i.e., result = x * y. |
| 43 | /// |
| 44 | /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. |
| 45 | /// @tparam T Floating-point scalar types. |
| 46 | /// |
| 47 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a> |
| 48 | /// @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> |
| 49 | template<length_t L, typename T, qualifier Q> |
| 50 | GLM_FUNC_DECL T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y); |
| 51 | |
| 52 | /// Returns the cross product of x and y. |
| 53 | /// |
| 54 | /// @tparam T Floating-point scalar types. |
| 55 | /// |
| 56 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a> |
| 57 | /// @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> |
| 58 | template<typename T, qualifier Q> |
| 59 | GLM_FUNC_DECL vec<3, T, Q> cross(vec<3, T, Q> const& x, vec<3, T, Q> const& y); |
| 60 | |
| 61 | /// Returns a vector in the same direction as x but with length of 1. |
| 62 | /// According to issue 10 GLSL 1.10 specification, if length(x) == 0 then result is undefined and generate an error. |
| 63 | /// |
| 64 | /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. |
| 65 | /// @tparam T Floating-point scalar types. |
| 66 | /// |
| 67 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a> |
| 68 | /// @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> |
| 69 | template<length_t L, typename T, qualifier Q> |
| 70 | GLM_FUNC_DECL vec<L, T, Q> normalize(vec<L, T, Q> const& x); |
| 71 | |
| 72 | /// If dot(Nref, I) < 0.0, return N, otherwise, return -N. |
| 73 | /// |
| 74 | /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. |
| 75 | /// @tparam T Floating-point scalar types. |
| 76 | /// |
| 77 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a> |
| 78 | /// @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> |
| 79 | template<length_t L, typename T, qualifier Q> |
| 80 | GLM_FUNC_DECL vec<L, T, Q> faceforward( |
| 81 | vec<L, T, Q> const& N, |
| 82 | vec<L, T, Q> const& I, |
| 83 | vec<L, T, Q> const& Nref); |
| 84 | |
| 85 | /// For the incident vector I and surface orientation N, |
| 86 | /// returns the reflection direction : result = I - 2.0 * dot(N, I) * N. |
| 87 | /// |
| 88 | /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. |
| 89 | /// @tparam T Floating-point scalar types. |
| 90 | /// |
| 91 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a> |
| 92 | /// @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> |
| 93 | template<length_t L, typename T, qualifier Q> |
| 94 | GLM_FUNC_DECL vec<L, T, Q> reflect( |
| 95 | vec<L, T, Q> const& I, |
| 96 | vec<L, T, Q> const& N); |
| 97 | |
| 98 | /// For the incident vector I and surface normal N, |
| 99 | /// and the ratio of indices of refraction eta, |
| 100 | /// return the refraction vector. |
| 101 | /// |
| 102 | /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. |
| 103 | /// @tparam T Floating-point scalar types. |
| 104 | /// |
| 105 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a> |
| 106 | /// @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> |
| 107 | template<length_t L, typename T, qualifier Q> |
| 108 | GLM_FUNC_DECL vec<L, T, Q> refract( |
| 109 | vec<L, T, Q> const& I, |
| 110 | vec<L, T, Q> const& N, |
| 111 | T eta); |
| 112 | |
| 113 | /// @} |
| 114 | }//namespace glm |
| 115 | |
| 116 | #include "detail/func_geometric.inl" |