Method: CGLM::Quat.random
- Defined in:
- ext/cglm/rb_cglm_quat.c
.random([dest]) ⇒ dest | new Quat
Fills dest or a new Quat with a random orientation, and returns it.
317 318 319 320 321 322 323 324 325 326 |
# File 'ext/cglm/rb_cglm_quat.c', line 317
VALUE rb_cglm_quat_new_random(int argc, VALUE *argv, VALUE self) {
VALUE dest;
rb_scan_args(argc, argv, "01", &dest);
if (NIL_P(dest)) dest = QUAT_NEW(ALLOC_QUAT);
glm_quat(VAL2QUAT(dest), drand48(), drand48(), drand48(), drand48());
glm_quat_normalize(VAL2QUAT(dest));
return dest;
}
|