Plot and animate a 3D Dice Image

4 次查看(过去 30 天)
Alex Burton
Alex Burton 2015-4-13
编辑: pfb 2015-4-13
I am building a simple dice simulator. User inputs #of sides, dice, rolls, and a random number generator (randi()) outputs a value or values.
Part of the requirement of the program is that there needs to be some sort of visualization. I know it is possible to plot a 3d cube/pyramid/etc, but is there any way to plot the shape with the resulting number from the generator printed on the side? If that is possible, is there any way to give the object a simple animation, like make it spin a few times before stopping and showing the value?
I know this is a long shot, but any advice you can provide would be extremely appreciated.
Thanks!

回答(1 个)

pfb
pfb 2015-4-13
编辑:pfb 2015-4-13
perhaps placing dots (circles) instead of numbers on the faces of the dice is easier, at least for a traditional cubic dice. That would work also for a tetrahedron (even less dots). But if you plan a dice with many faces that becomes unpractical, readability-wise. Hard to tell apart 23 dots from 21.
I'd prepare the data for the faces of the dices and the relevant dots to be rendered using fill3. Then you can rotate them to build an animation.
Or else, you could rotate the point of view (setting the axes off).

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by