Xkonti / govec

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

Implement `RandBetween` operation #22

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 2 vectors.

fromVec := V3F{12.3, 45.6, 78.9}
toX, toY, toZ := 12.0, 34.0, 15.0
toVec := V3F{toX, toY, toZ}

random1 := fromVec.RandBetween(toVec) // Returns a new random vector
random2 :=  fromVec.RandBetweenComp(toX, toY, toZ) // Returns a new random vector
rangeVec.RandBetweenInPlace(toVec) // Updates the existing vector with random values
rangeVec.RandBetweenInPlace(toX, toY, toZ) // Updates the existing vector with random values