Method: CGLM::Vec3.random

Defined in:
ext/cglm/rb_cglm_vec3.c

.random([dest]) ⇒ dest | new Vec3

Fills dest or a new Vec3 with random values, and returns it.

Returns:



785
786
787
788
789
790
791
792
793
794
795
# File 'ext/cglm/rb_cglm_vec3.c', line 785

VALUE rb_cglm_vec3_new_random(int argc, VALUE *argv, VALUE self) {
  VALUE dest;
  rb_scan_args(argc, argv, "01", &dest);
  if (NIL_P(dest)) dest = VEC3_NEW(ALLOC_VEC3);

  VAL2VEC3(dest)[0] = drand48();
  VAL2VEC3(dest)[1] = drand48();
  VAL2VEC3(dest)[2] = drand48();

  return dest;
}