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