Skip to content

Commit 9660d02

Browse files
authored
ofRandomDistributions: more explicit comparison/precedence for glm::vec elements (#7618)
#changelog #math
1 parent e4c8585 commit 9660d02

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

libs/openFrameworks/utils/ofRandomDistributions.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ T bound_normal(float min, float max, float focus = 4.0f) {
536536
template <typename T>
537537
std::enable_if_t<std::is_same_v<T, glm::vec2>, T>
538538
bound_normal(T min, T max, T focus = {4.0f, 4.0f}) {
539-
if (!min.x < max.x || !min.y < max.y) {
539+
if (min.x >= max.x || min.y >= max.y) {
540540
std::cout << "ofRandomNormalLimits()" << "max must be > than min\n";
541541
return {};
542542
} else {
@@ -545,8 +545,8 @@ bound_normal(T min, T max, T focus = {4.0f, 4.0f}) {
545545
return {};
546546
} else {
547547
T v;
548-
do { v.x = of::random::normal<float>((max.x+min.x)/2.0f, (max.x-min.x)/(2*focus.x)); } while (v.x < min || v.x > max);
549-
do { v.y = of::random::normal<float>((max.y+min.y)/2.0f, (max.y-min.y)/(2*focus.y)); } while (v.y < min || v.y > max);
548+
do { v.x = of::random::normal<float>((max.x+min.x)/2.0f, (max.x-min.x)/(2*focus.x)); } while (v.x < min.x || v.x > max.x);
549+
do { v.y = of::random::normal<float>((max.y+min.y)/2.0f, (max.y-min.y)/(2*focus.y)); } while (v.y < min.y || v.y > max.y);
550550
return v;
551551
}
552552
}
@@ -555,7 +555,7 @@ bound_normal(T min, T max, T focus = {4.0f, 4.0f}) {
555555
template <typename T>
556556
std::enable_if_t<std::is_same_v<T, glm::vec3>, T>
557557
bound_normal(T min, T max, T focus = {4.0f, 4.0f, 4.0f}) {
558-
if (!min.x < max.x || !min.y < max.y || !min.z < max.z) {
558+
if (min.x >= max.x || min.y >= max.y || min.z >= max.z) {
559559
std::cout << "ofRandomNormalLimits()" << "max must be > than min\n";
560560
return {};
561561
} else {
@@ -564,9 +564,9 @@ bound_normal(T min, T max, T focus = {4.0f, 4.0f, 4.0f}) {
564564
return {};
565565
} else {
566566
T v;
567-
do { v.x = of::random::normal<float>((max.x+min.x)/2.0f, (max.x-min.x)/(2*focus.x)); } while (v.x < min || v.x > max);
568-
do { v.y = of::random::normal<float>((max.y+min.y)/2.0f, (max.y-min.y)/(2*focus.y)); } while (v.y < min || v.y > max);
569-
do { v.z = of::random::normal<float>((max.z+min.z)/2.0f, (max.z-min.z)/(2*focus.z)); } while (v.z < min || v.z > max);
567+
do { v.x = of::random::normal<float>((max.x+min.x)/2.0f, (max.x-min.x)/(2*focus.x)); } while (v.x < min.x || v.x > max.x);
568+
do { v.y = of::random::normal<float>((max.y+min.y)/2.0f, (max.y-min.y)/(2*focus.y)); } while (v.y < min.y || v.y > max.y);
569+
do { v.z = of::random::normal<float>((max.z+min.z)/2.0f, (max.z-min.z)/(2*focus.z)); } while (v.z < min.z || v.z > max.z);
570570
return v;
571571
}
572572
}

0 commit comments

Comments
 (0)