Heads or Tails with iLogic (UPDATED)

Coin Toss Update1

A while back I seemed to get obsessed with finding ways to use random number generators, and I created two interesting use cases, one was a coin flipper and the other was the magic 8 ball, I have these tagged on my site under “Toys”, which makes them easier to find.

The original Coin Toss / Heads or Tails blog post fires up a web page containing the result. After the success of the Magic 8 Ball I decided to improve on the coin, and use a coin modelled in Inventor.

The way it works is really simple, the model has a “start position” which is captured using one of the Wizards in iLogic, and then depending on the result of the random number generator, the model is “flipped” to either a “Heads” or a “Tails” position.

Here is the iLogic code:

'iLogic code by @ClintBrown3D, originally posted at https://clintbrown.co.uk/heads-or-tails2
'Set Initial views
InventorVb.SetViewCamera(ViewCameraOption.SetExtents, New Double() {-1.5707203701100697E-15, 0, 7.0738956735309575}, New Double() {0, 0, 0}, New Double() {-1, -2.2204460492503131E-16, -2.2204460492503131E-16}, New Double() {3.536947836807609, 5.7433725491905987})
InventorVb.SetViewCamera(ViewCameraOption.SetExtents, New Double() {9.8524146601508882, 3.9429965745003579, 6.7110793417660366 }, New Double() {3.0169178013451172, -2.8925002843053993, -0.12441751703973568 }, New Double() {-0.40824829046386291, 0.81649658092772626, -0.40824829046386318 }, New Double() {29.106799177083907, 47.264251298473546 })
InventorVb.SetViewCamera(ViewCameraOption.SetExtents, New Double() {2.9103608591370409, -9.5994965890430084, 5.8621371170114518}, New Double() {3.8086934809684454, 0.36351161531899656, 1.6868740044481605}, New Double() {-0.98648287937228829, 0.13048678091812277, 0.0991197695264936}, New Double() {29.106799177083907, 47.264251298473546})

'Generate a random number (In this case 1 or 0)
HEADSorTAILS = Round(Rnd * 1)
'If the result is 0 then the answer is Heads, if the result is 1 , then the answer is tails
If HEADSorTAILS = 0 Then : GoTo HEADS : Else : GoTo TAILS : End If

HEADS :'HEADS
InventorVb.SetViewCamera(ViewCameraOption.SetExtents, New Double() {-7.0738956735309575, -1.5707203701100697E-15, -1.5707203701100693E-15}, New Double() {0, 0, 0}, New Double() {-2.2204460492503131E-16, 2.2204460492503131E-16, 1}, New Double() {3.536947836807609, 5.7433725491906014})
Return

TAILS :'TAILS
InventorVb.SetViewCamera(ViewCameraOption.SetExtents, New Double() {7.0738956735309575, 1.5707203701100697E-15, 1.5707203701100693E-15}, New Double() {0, 0, 0}, New Double() {-2.2204460492503131E-16, 2.2204460492503131E-16, 1}, New Double() {3.536947836807609, 5.7433725491905987})

Download the Inventor 2020 version of the coin (with the iLogic code embedded in it) HERE.