7 template<length_t L,
typename T, qualifier Q,
bool Aligned>
12 return sqrt(dot(v, v));
16 template<length_t L,
typename T, qualifier Q,
bool Aligned>
21 return length(p1 - p0);
25 template<
typename V,
typename T,
bool Aligned>
28 template<
typename T, qualifier Q,
bool Aligned>
37 template<
typename T, qualifier Q,
bool Aligned>
47 template<
typename T, qualifier Q,
bool Aligned>
53 return tmp.x + tmp.y + tmp.z;
57 template<
typename T, qualifier Q,
bool Aligned>
63 return (tmp.x + tmp.y) + (tmp.z + tmp.w);
67 template<
typename T, qualifier Q,
bool Aligned>
72 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559,
"'cross' accepts only floating-point inputs");
75 x.y * y.z - y.y * x.z,
76 x.z * y.x - y.z * x.x,
77 x.x * y.y - y.x * x.y);
81 template<length_t L,
typename T, qualifier Q,
bool Aligned>
86 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559,
"'normalize' accepts only floating-point inputs");
88 return v * inversesqrt(dot(v, v));
92 template<length_t L,
typename T, qualifier Q,
bool Aligned>
95 GLM_FUNC_QUALIFIER
static vec<L, T, Q> call(
vec<L, T, Q> const& N,
vec<L, T, Q> const& I,
vec<L, T, Q> const& Nref)
97 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559,
"'normalize' accepts only floating-point inputs");
99 return dot(Nref, I) <
static_cast<T
>(0) ? N : -N;
103 template<length_t L,
typename T, qualifier Q,
bool Aligned>
108 return I - N * dot(N, I) *
static_cast<T
>(2);
112 template<length_t L,
typename T, qualifier Q,
bool Aligned>
117 T
const dotValue(dot(N, I));
118 T
const k(
static_cast<T
>(1) - eta * eta * (
static_cast<T
>(1) - dotValue * dotValue));
120 (k >=
static_cast<T
>(0)) ? (eta * I - (eta * dotValue + std::sqrt(k)) * N) :
vec<L, T, Q>(0);
127 template<
typename genType>
128 GLM_FUNC_QUALIFIER genType length(genType x)
130 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559,
"'length' accepts only floating-point inputs");
135 template<length_t L,
typename T, qualifier Q>
138 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559,
"'length' accepts only floating-point inputs");
144 template<
typename genType>
145 GLM_FUNC_QUALIFIER genType distance(genType
const& p0, genType
const& p1)
147 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559,
"'distance' accepts only floating-point inputs");
149 return length(p1 - p0);
152 template<length_t L,
typename T, qualifier Q>
160 GLM_FUNC_QUALIFIER T dot(T x, T y)
162 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559,
"'dot' accepts only floating-point inputs");
166 template<length_t L,
typename T, qualifier Q>
169 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559,
"'dot' accepts only floating-point inputs");
174 template<
typename T, qualifier Q>
189 template<length_t L,
typename T, qualifier Q>
192 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559,
"'normalize' accepts only floating-point inputs");
198 template<
typename genType>
199 GLM_FUNC_QUALIFIER genType faceforward(genType
const& N, genType
const& I, genType
const& Nref)
201 return dot(Nref, I) <
static_cast<genType
>(0) ? N : -N;
204 template<length_t L,
typename T, qualifier Q>
205 GLM_FUNC_QUALIFIER
vec<L, T, Q> faceforward(
vec<L, T, Q> const& N,
vec<L, T, Q> const& I,
vec<L, T, Q> const& Nref)
211 template<
typename genType>
212 GLM_FUNC_QUALIFIER genType reflect(genType
const& I, genType
const& N)
214 return I - N * dot(N, I) * genType(2);
217 template<length_t L,
typename T, qualifier Q>
224 template<
typename genType>
225 GLM_FUNC_QUALIFIER genType refract(genType
const& I, genType
const& N, genType eta)
227 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559,
"'refract' accepts only floating-point inputs");
228 genType
const dotValue(dot(N, I));
229 genType
const k(
static_cast<genType
>(1) - eta * eta * (
static_cast<genType
>(1) - dotValue * dotValue));
230 return (eta * I - (eta * dotValue +
sqrt(k)) * N) *
static_cast<genType
>(k >=
static_cast<genType
>(0));
233 template<length_t L,
typename T, qualifier Q>
236 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559,
"'refract' accepts only floating-point inputs");
241#if GLM_CONFIG_SIMD == GLM_ENABLE
GLM_FUNC_DECL GLM_CONSTEXPR genType abs(genType x)
GLM_FUNC_QUALIFIER vec< L, T, Q > sqrt(vec< L, T, Q > const &x)
Definition func_exponential.inl:128
GLM_FUNC_QUALIFIER vec< L, T, Q > normalize(vec< L, T, Q > const &x)
Definition func_geometric.inl:190
GLM_FUNC_QUALIFIER vec< 3, T, Q > cross(vec< 3, T, Q > const &x, vec< 3, T, Q > const &y)
Definition func_geometric.inl:175
detail namespace with internal helper functions
Definition json.h:249
Core features
Definition common.hpp:21
Definition func_geometric.inl:69
Definition func_geometric.inl:18
Definition func_geometric.inl:26
Definition func_geometric.inl:94
Definition func_geometric.inl:9
Definition func_geometric.inl:83
Definition func_geometric.inl:105
Definition func_geometric.inl:114
Definition qualifier.hpp:60
Definition qualifier.hpp:35