Because of their unique shape, mecanum wheels allow for omnidirectional movement (forwards, backwards, sideways, diagonally, rotating, etc.). These wheels work by applying a force at a 45 degree angle to the rotation of the wheel. Combinations of these forces allow the robot to move in different directions.

Because of the shape of the mecanum wheels, rotating a wheel causes it to apply a force at a 45 degree angle to its rotation. The direction of rotation determines the direction of the force.

If all motors rotate forward, the robot moves forward, because the sideways forces cancel out, and therefore the sum of the force vectors (shown in the picture in black) is forward.

To go sideways, the motors on the direction that one is trying to go in (in this case, right) rotate towards each other, and the wheels on the other side rotate away from each other. The resultant force from this goes to the right.

To move diagonally, only the two motors across from each other rotate; the others do not rotate at all.