python - Calculating the fraction of each cell in a grid overlapped by a 2D object -


i have arbitrary rectangular cartesian grid divided potentially 10^6 or rectangular cells. (arbitrary means $x$ grid along points $x_1,...x_n$ , same goes $y$ grid.) draw arbitrary object on top of (say rotated rectangle, or circle), , efficiently calculate fraction of each cell overlapped object: if cell entirely inside bounds of object, 1.0; if cell entirely outside, 0.0; if half of cell covered object, 0.5. if displayed image , scaled 1 black , 0 white, result antialiased drawing of black object.

my application question in python, , seems capability might provided existing graphics library. there python module test fractional intersection of rectangle , arbitrary object? there python library can @ least efficiently test if point inside arbitrary object rotated rectangle?

you use pycairo, has fast native routines drawing. it's antialiased default.

implementing drawing algorithms in python slow.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -