Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Rotating a wheel with circumference

edited July 2013 in Questions Posts: 105

When you figure out the circumference of a circle (wheel of a car), can you then rotate the wheel depending on how far the car has come? I mean if the wheel-circumference is 78 and the car has driven 78 pixels, then the wheel have rotated 360 degrees. Is there any solution to this?

Comments

  • Posts: 391

    When drawing the wheel, add the rotate() function. Make sure the wheel and rotate function are inside pushMatrix and popMatrix or else it will rotate everything drawn. Then use a simple formula such as:

    rotate((360/circumference)*pixelsTraveled)

  • Posts: 105

    Thanks! Smart solution

Sign In or Register to comment.