mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 18:24:35 +00:00
Added linearRand implementation
This commit is contained in:
parent
dd2de8b20d
commit
3aefc82e95
@ -12,5 +12,73 @@
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER glm::half linearRand
|
||||
(
|
||||
glm::half const & Min,
|
||||
glm::half const & Max
|
||||
)
|
||||
{
|
||||
return glm::half(float(std::rand()) / float(RAND_MAX) * (float(Max) - float(Min)) + float(Min));
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER float linearRand
|
||||
(
|
||||
float const & Min,
|
||||
float const & Max
|
||||
)
|
||||
{
|
||||
return float(std::rand()) / float(RAND_MAX) * (Max - Min) + Min;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER double linearRand
|
||||
(
|
||||
double const & Min,
|
||||
double const & Max
|
||||
)
|
||||
{
|
||||
return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> linearRand
|
||||
(
|
||||
detail::tvec2<T> const & Min,
|
||||
detail::tvec2<T> const & Max
|
||||
)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
linearRand(Min.x, Max.x),
|
||||
linearRand(Min.y, Max.y));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> linearRand
|
||||
(
|
||||
detail::tvec3<T> const & Min,
|
||||
detail::tvec3<T> const & Max
|
||||
)
|
||||
{
|
||||
return detail::tvec3<T>(
|
||||
linearRand(Min.x, Max.x),
|
||||
linearRand(Min.y, Max.y),
|
||||
linearRand(Min.z, Max.z));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> linearRand
|
||||
(
|
||||
detail::tvec4<T> const & Min,
|
||||
detail::tvec4<T> const & Max
|
||||
)
|
||||
{
|
||||
return detail::tvec4<T>(
|
||||
linearRand(Min.x, Max.x),
|
||||
linearRand(Min.y, Max.y),
|
||||
linearRand(Min.z, Max.z),
|
||||
linearRand(Min.w, Max.w));
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
Loading…
Reference in New Issue
Block a user