Fixed and tested disk and ball rands
This commit is contained in:
parent
695b058096
commit
387854dbe3
@ -141,7 +141,7 @@ GLM_FUNC_QUALIFIER detail::tvec4<T> gaussRand
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> diskRand
|
GLM_FUNC_QUALIFIER detail::tvec2<T> diskRand
|
||||||
(
|
(
|
||||||
T const & Radius
|
T const & Radius
|
||||||
)
|
)
|
||||||
@ -151,7 +151,7 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> diskRand
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Result = compRand2(-Radius, Radius);
|
Result = linearRand(detail::tvec2<T>(-Radius), detail::tvec2<T>(Radius));
|
||||||
LenRadius = length(Result);
|
LenRadius = length(Result);
|
||||||
}
|
}
|
||||||
while(LenRadius > Radius);
|
while(LenRadius > Radius);
|
||||||
@ -170,7 +170,7 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> ballRand
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Result = compRand3(-Radius, Radius);
|
Result = linearRand(detail::tvec3<T>(-Radius), detail::tvec3<T>(Radius));
|
||||||
LenRadius = length(Result);
|
LenRadius = length(Result);
|
||||||
}
|
}
|
||||||
while(LenRadius > Radius);
|
while(LenRadius > Radius);
|
||||||
|
@ -91,6 +91,36 @@ int test_sphericalRand()
|
|||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int test_diskRand()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
float ResultFloat = 0.0f;
|
||||||
|
double ResultDouble = 0.0f;
|
||||||
|
for(std::size_t i = 0; i < 100000; ++i)
|
||||||
|
{
|
||||||
|
ResultFloat += glm::length(glm::diskRand(2.0f));
|
||||||
|
ResultDouble += glm::length(glm::diskRand(2.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Error += ResultFloat < 200000.f ? 0 : 1;
|
||||||
|
Error += ResultDouble < 200000.0 ? 0 : 1;
|
||||||
|
assert(!Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_ballRand()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
@ -98,6 +128,8 @@ int main()
|
|||||||
Error += test_linearRand();
|
Error += test_linearRand();
|
||||||
Error += test_circularRand();
|
Error += test_circularRand();
|
||||||
Error += test_sphericalRand();
|
Error += test_sphericalRand();
|
||||||
|
Error += test_diskRand();
|
||||||
|
Error += test_ballRand();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user