Basically, all movements are (small) straight lines, the volume of a straight line is easily calculated as you already guessed.

To calculate the volume to be extruded you multiply the following parameters:

 - the layer height *(h)*
 - flow modifier (e.g. as percentage) *(SF)*
 - extruder nozzle diameter *(d<sub>n</sub>)* (or extruder line width if different from nozzle diameter)
 - distance of the straight line *(l)*

With this volume you can calculate how much filament you need to extrude. To get the length (thus the length defined by the `E` parameter), divide the obtained volume by surface area of your used filament by:

- π * (filament radius)<sup>2</sup> or alternatively π /4 * (filament diameter)<sup>2</sup> = (π /4 * d<sub>f</sub><sup>2</sup>)


To sum up, the value of E is given by:

$$ E_{value} = \frac{h \times {SF} \times d_{n} \times l}{\frac{\pi}{4}d_{f}^2} = \frac{4 \times h \times {SF} \times d_{n} \times l}{\pi \times d_{f}^2} $$

  [1]: https://i.sstatic.net/TYAvf.gif