39 template<
typename T,
typename ...Args>
42 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
55 template<
typename A,
typename B>
inline A
min(A a, B b) {
return a < b ? a : b; }
56 template<
typename A,
typename B>
inline A
max(A a, B b) {
return a > b ? a : b; }
58 template<
typename Type>
64 template<
typename Type>
70 template<
typename Type>
76 template<
typename Type>
82 template<
typename Type>
88 template<
typename Type>
94 template<
typename A,
typename B,
typename C>
95 inline C
clamp(A val, B minval, C maxval)
97 return max((A)minval,
min((A)maxval, val));
100 template<
typename A,
typename B,
typename C>
103 return a * (C(1) -
mix) + b * mix;
136 template<
typename Type>
142 template<
typename Type>
148 template<
typename Type>
154 template<
typename A,
typename B,
typename C>
inline C
smoothstep(A edge0, B edge1, C x)
156 C
t =
clamp((x - edge0) / (edge1 - edge0), C(0), C(1));
157 return t * t * (C(3) - C(2) * t);
160 inline int step(
int edge,
int x)
162 return x < edge ? 0 : 1;
165 inline long long step(
long long edge,
long long x)
167 return x < edge ? 0 : 1;
170 inline float step(
float edge,
float x)
172 return x < edge ? 0.0f : 1.0f;
175 inline double step(
double edge,
double x)
177 return x < edge ? 0.0 : 1.0;
180 template<
typename Type>
186 template<
typename Type>
192 template<
typename Type>
std::unique_ptr< T > make_unique(Args &&...args)
Definition: cl_math.h:40
A min(A a, B b)
Definition: cl_math.h:55
T pow2(T value)
Definition: cl_math.h:50
2D vector
Definition: line.h:43
Type x
Definition: vec3.h:74
3D vector
Definition: line_ray.h:43
Type x
Definition: vec4.h:74
Type x
Definition: vec2.h:75
C smoothstep(A edge0, B edge1, C x)
Definition: cl_math.h:154
int step(int edge, int x)
Definition: cl_math.h:160
Type z
Definition: vec3.h:76
Type y
Definition: vec2.h:76
C clamp(A val, B minval, C maxval)
Definition: cl_math.h:95
Type y
Definition: vec4.h:75
Type w
Definition: vec4.h:77
A max(A a, B b)
Definition: cl_math.h:56
Type y
Definition: vec3.h:75
int sign(int x)
Definition: cl_math.h:106
Type z
Definition: vec4.h:76
A mix(A a, B b, C mix)
Definition: cl_math.h:101
Definition: Application/application.h:35
4D vector
Definition: size.h:44