X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fvmath.h;h=463fea6e32ef6e0bbd8ad5611be235cae15622fa;hp=3cdbedf7fc4353ccf494b2a456d508ec2304975a;hb=fcac764d752234a03df536dd408235170394f6ad;hpb=5029eb9f7a538dd58e1c66c0945784acac8cc58b diff --git a/src/vmath.h b/src/vmath.h index 3cdbedf..463fea6 100644 --- a/src/vmath.h +++ b/src/vmath.h @@ -141,4 +141,22 @@ static INLINE void mat4_transpose(float *mat) } } +/* misc stuff */ +static vec3_t INLINE sphrand(float rad) +{ + vec3_t res; + + float u = (float)rand() / RAND_MAX; + float v = (float)rand() / RAND_MAX; + + float theta = 2.0f * M_PI * u; + float phi = acos(2.0f * v - 1.0f); + + res.x = rad * cos(theta) * sin(phi); + res.y = rad * sin(theta) * sin(phi); + res.z = rad * cos(phi); + + return res; +} + #endif /* VMATH_H_ */