diff --git a/sweet_math.c b/sweet_math.c index 5cf2a5c..ab8ce62 100755 --- a/sweet_math.c +++ b/sweet_math.c @@ -525,6 +525,38 @@ vec3_angle (vec3 a, vec3 b) return acos (dot); } +vec2 +vec2_positive_random () +{ + vec2 v; + v.x = (float)rand() / (float)RAND_MAX; + v.y = (float)rand() / (float)RAND_MAX; + return vec2_normalize (v); +} + +vec3 +vec3_positive_random () +{ + vec3 v; + v.x = (float)rand() / (float)RAND_MAX; + v.y = (float)rand() / (float)RAND_MAX; + v.z = (float)rand() / (float)RAND_MAX; + + return vec3_normalize (v); +} + +vec4 +vec4_positive_random () +{ + vec4 v; + v.x = (float)rand() / (float)RAND_MAX; + v.y = (float)rand() / (float)RAND_MAX; + v.z = (float)rand() / (float)RAND_MAX; + v.w = (float)rand() / (float)RAND_MAX; + + return vec4_normalize (v); +} + vec2 vec2_random () { diff --git a/sweet_math.h b/sweet_math.h index ff99f87..59081ec 100755 --- a/sweet_math.h +++ b/sweet_math.h @@ -188,7 +188,13 @@ float vec2_angle (vec2 vector1, vec2 vector2); float vec3_angle (vec3 vector1, vec3 vector2); /** Random */ +vec2 vec2_positive_random (); +vec3 vec3_positive_random (); +vec4 vec4_positive_random (); + +vec2 vec2_random (); vec3 vec3_random (); +vec4 vec4_random (); vec3 vec3_random_ortho (vec3 v); /** Mult */