A
A
akswift2019-08-10 11:10:36
JavaScript
akswift, 2019-08-10 11:10:36

Winwheel.js How to calculate on which segment the wheel will stop?

Hello. The point is this. There is a website with a prize wheel. It is logical that we need to give out prizes depending on the quantity, which means keeping records on the server, and giving away prizes from there. We get a random prize. And now we must pass the number (segment on the wheel) to the animation itself.
But here's the difficulty, I can't understand this formula.

let stopAt = (91 + Math.floor((Math.random() * 43)))

And what he is responsible for, how he thinks, and what he will receive. This example is from the winwheel documentation. I came to you for help. Because I can't understand anything.
Link to documentation.
dougtesting.net/winwheel/docs/tut14_setting_the_prize

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexalexes, 2019-08-10
@akswift

Read the comment.

// This formula always makes the wheel stop somewhere inside prize 3 at least
// 1 degree away from the start and end edges of the segment.

Sector "Prize 3" is behind the 90th degree clockwise.
To get there, the minimum number must be generated a little more than 90, for example, 91.
Randomly generates substances. numbers in the range 0...1.
We need not to run out of the sector beyond the upper boundary.
Sectors 8, one sector accounts for 45 degrees.
91 + 45 = 136 degrees, ran to the next sector.
We take 44, we find ourselves on the border of sectors.
We take 43 - what we need, we found the upper limit of parameter generation (134 degrees).
PS:
91 is the minimum setting;
43 - max. intra-sector bias.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question