I have made a tank object that knows its position, speed, rotation, and a double value ranging from 1.0 to -1.0 for each tread. I want it to move base on those values. For example, if the value for the left tread is 1.0 and the value for the right tread is 0.5 the tank should follow a clockwise circular path. However, the closest I have come is when the left tread turns forward (positive) and/or the right tread turns backward (negative), the tank spins CCW and moves down the screen, while the reverse is true if the left tread turns backward and/or the right tread turns forward.
This is my code for moving the tank, where
lts is the left tread speed and
rts is the right tread speed:
rotation += speed * (rts / 12); rotation -= speed * (lts / 12); location.x += speed * (Math.cos(rts / 12) * 14.5); location.x -= speed * (Math.cos(lts / 12) * 14.5); location.y -= speed * (Math.sin(rts / 12) * 14.5); location.y += speed * (Math.sin(lts / 12) * 14.5);