Xkonti / govec

Go library providing 2D and 3D vector operations
MIT License
6 stars 7 forks source link

Implement `RandIn` operation #21

Open Xkonti opened 1 year ago

Xkonti commented 1 year ago

Generates a vector with random components within a specified range. The range is specified by vector/component and a zero vector.

// These are the same
V2F{12, 13}.RandIn() == V2F{12, 13}.RandBetween(V2F{0, 0})

rangeX, rangeY, rangeZ := 12, 34, 15
rangeVec := V3I{rangeX, rangeY, rangeZ}

random1 := rangeVec.RandIn() // Returns a new random vector
rangeVec.RandInInPlace() // Updates the existing vector with random values