0

I need to write a program that simulates a ring going down a hill showing the velocity vector. Or at least a simulation of a circle rotating with a velocity vector. It doesn't necessarily need to be going down a hill. This is what I have so far. Thank you so much to anyone that can help.

'''
cylinderhill.py
'''
from visual import *
from math import *

inclinedPlane = box(pos = vector(1, 0, 0), size = (2, 0.2, 0.2), color = color.blue)
cir = ring(pos=(5,0,0), axis=(5,0,0), radius = (.05), thickness = (.01), color = color.red)
cir.vel = vector(1,1)
  • "This is what I have so far". I.e. nothing much. What are you thinking needs doing next? – The Archetypal Paul Nov 25 '14 at 17:29
  • You seem to want an animated image of the rotating ring. I suggest you start with an animated image of a moving, non-rotating ring. Once that's working perfectly, you can look into making it rotate. – Beta Nov 26 '14 at 04:53

1 Answers1

0
  1. add needed variables for you object (ring)

    you need: position,velocity,acceleration,radiuses and set them at start to start position/state (speeds to zero ...).

  2. create engine App able of redrawing the scene

    all objects (ring,surface ...) and update/redraw on some timer

  3. add physical simulation

    compute actual acceleration acc (gravity,surface/collision normal interaction,frictions,actuators,...). Then update velocity vel,position pos according to Newtonian/D'Alembert equations

    vel+=acc*dt;
    pos+=vel*dt;
    

    do this in each ontimer call before redraw. The dt is the timer interval ...

  4. some tips

    add if (|vel|<1e-6) vel={0,0,...,0}; before pos update to avoid floating accuracy problems. The acc,vel,pos are vectors (for 2D simulation use 2D vectors). Use float or double variables.

  5. rotation

    if you have no drift (full grip) then angular speed is:

    omg=|vel|/R;
    

    where R is ring's outer radius. If you have a drift then you have to compute angular acceleration eps first from external and internal forces and then compute:

    omg+=eps*dt;
    

    the rest is similar to position computation... angular position:

    ang+=omg*dt;
    

See some related Q/A:

Spektre
  • 49,595
  • 11
  • 110
  • 380