Spinning Top

Blitz3D Forums/Blitz3D Beginners Area/Spinning Top

Kirkkaf13(Posted 2010) [#1]
I have made a basic demo of a cone spinning similar to a spinning top.

How come if I increase the line: spin = spin + 0.5

any higher than 0.5 (0.51) it spins out of control. I wanted it to be similar to a spinning top slowing down (wobble) by increase Z each frame but it doesn't seem to work very well.




Midimaster(Posted 2010) [#2]
your first problem is, that your variable SPIN is INTEGER. This makes that SPIN keeps always the value 1. The function is not working!You can see this if you add a...

DEBUGLOG spin

In the moment you change the add to 0.51, SPIN changes it changes to value 2,3,4....



Try to change this:

Global Spin#=0.01


and inside the function SPIN()

....
Spin=Spin + 0.01
DEBUGLOG Spin
...


Now you can continue with you experiments, but you will see, that to turn the Cone in your way (with such big steps) will not bring you the result you want. Therefore use an add of 0.01


xlsior(Posted 2010) [#3]
Midimaster: you need to use [ /code ] to close your code blocks


Midimaster(Posted 2010) [#4]
@xlsior thanks, immediately changed (only forgot it during paste and copy...)


Serpent(Posted 2010) [#5]
When you're working in 3D positions and rotations, it's always (from my experience at least) best to work with floating point numbers rather than integers. Just about anything you do in 3D will NOT involve whole numbers, but rather fractions of units and degrees. If you use integers, as Midimaster said, you cannot rotate something by anything in between whole numbers - i.e. whatever you do will be rounded off to the nearest whole value.

Also, I'm not sure if this is what you're trying to achieve, but each frame, the amount that you rotate the cone by is increased. Because of this, unless the values are really small like Midimaster suggested (which would spoil the effect), the cone will start spinning extremely fast in no time at all with no limit to the speed.

This post looks dead, but I thought I'd say this anyway :)


Guy Fawkes(Posted 2010) [#6]
can someone make a spinout effect for this code when the top loses its balance?


Guy Fawkes(Posted 2010) [#7]


a small fix to make it more precise