Switching positive and negative voltage
simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. A single-coil motor in a 'H-bridge' configuration.

Really easy:


In Figure 1 left current flows through SW1, the motor and SW4. The left motor terminal is positive and the right is negative.
If we switch the switches carfully to avoid 'shoot-through' (e.g., if SW1 and 2 were on simultaneously enough current might flow to destroy the circuit) we can reverse the current flow through the motor. In Figure 1 right current flows through SW7, the motor and SW6. Note that the motor polarity has been reversed.


The result is that either motor terminal can be connected to battery positive or negative. For a simple DC motor this allows reversal of rotation.

The three-phase situation is more complex but still understandable:


If one winding is connected to positive then at least one of the other two has to provide the return path to the supply negative.
To approximate the sinusoidal waveform pulse-width modulation (PWM) is used with progressively wider pulses averaging to the rising voltage on the sine.