Given a straight line passing through
and
, we wish
to calculate the
position at a given
position
.
Using the definition of a line,

we find that value as
which can be rewritten in the familiar form
where
and
.
This is linear interpolation in two dimensions.
See p. 126 of Numerical Recipes in C++ for implementation detail.
Implementation details in Numerical Recipes in C++.
Measure the physical overlap between pixels, and weight accordingly. This requires the use of (often slow) PolygonClipping routines.
[PTV+03] Press, William H., Saul A. Teukolsky, William T. Vetterling and Brian P. Flannery. Numerical Recipes in C++: The Art of Scientific Computing, 2003. Cambridge University Press, 2nd edition, 2003.