# Animating a rolling square wheel effect

I basically want the effect shown in the linked gif, like a cube that roles on the floor and doesn't clip the surface as it moves forward, like a rotating square wheel

I can do the automatic rotation when moving with drivers, but how would I set up the up and down movement as it rotates forward.

https://gyazo.com/8e754d39d4363bd82b1134872f72bbe1

• Interesting question. I'm not really much of a math person, not sure I could help much, but you could probably do it with drivers if you could find the right math function. What you need is something close to the middle graph here 31.media.tumblr.com/1789b63316899d072a23db31f6aec0c4/… Source reddit.com/r/educationalgifs/comments/4pk3nr/… Commented Jul 20, 2016 at 1:29
• The equation you want for the z position as a function of the x position is z=sqrt(2 - (mod(x, 2) - 1) ^ 2). Commented Jul 20, 2016 at 2:11

Ok a long hard battle with my very limited math knowledge I think I came to an approximate solution.

It is not at all mathematically perfect, meaning the cube will be slightly floating at times, and will appear to slide or drift slightly, but it is as far as I could go.

I would ask anyone with a better math knowledge to improve on this solution.

You will need to set up drivers for it's rotation in such way that say rotation along Y axis will equal pi*locationX

For the tricky part, the Z height will be driver by something like:

0.5+(abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2))))

Where roty is the rotation along the Y axis and sl will be the length of the side of the cube.

If you want it to react to rotation in two axis jus add the equation above to itself 0.5+(abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2)))) + (abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2))))

For my case with a 1 x 1 unit cube you would get 0.5+(abs(cos(2*roty-pi/2))*(sqrt(.25**2)))+(abs(cos(2*rotx-pi/2))*(sqrt(.25**2)))

• Is there a blend file for this? Commented Aug 16, 2018 at 16:40