add new random vector fct

This commit is contained in:
luc 2020-03-30 23:30:09 +02:00
parent f94e255672
commit d103e7f04e
2 changed files with 38 additions and 0 deletions

View File

@ -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 ()
{

View File

@ -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 */