You've got it now. A couple things to remember: In your formula
Vout = Vdc*(commanded number/maximum command number)
commanded number has a range of +/-maximum commanded number so you can source current into the phase or sink current out of it. In operation, a positive command turns on the top (sourcing) transistor, between Vdc and the phase, and a negative command turns on the bottom (sinking) transistor, between the phase and the return voltage (0V, or GND).
And yes, the PWM circuit is fundamentally a comparator, either analog or digital. In the analog scheme, your command number is put through a D/A converter, and the resulting voltage is compared to the voltage out of a high-frequency sawtooth generator (which must be of a significantly higher frequency than that of the analog signal your algorithm will produce -- this wasn't really the case in the drawing you put up).
In the digital scheme, the sawtooth generator is an up/down counter whose numerical value is compared to your command value.