random function

List<double> random(
  1. List<double> out,
  2. double? scale
)

Generates a random vector with the given scale

@param {vec2} out the receiving vector @param {Number} scale Length of the resulting vector. If omitted, a unit vector will be returned @returns {vec2} out

Implementation

List<double> random(List<double> out, double? scale) {
  scale ??= 1.0;
  double r = GlMatrix.random() * 2.0 * math.pi;
  out[0] = math.cos(r) * scale;
  out[1] = math.sin(r) * scale;
  return out;
}