Checking if a point is inside a polygon

I would suggest using the Path class from matplotlib import matplotlib.path as mplPath import numpy as np poly = [190, 50, 500, 310] bbPath = mplPath.Path(np.array([[poly[0], poly[1]], [poly[1], poly[2]], [poly[2], poly[3]], [poly[3], poly[0]]])) bbPath.contains_point((200, 100)) (There is also a contains_points function if you want to test for multiple points)

What is the fastest way to find the “visual” center of an irregularly shaped polygon?

I have found a very good solution to this from MapBox called Polylabel. The full source is available on their Github too. Essentially it tries to find the visual centre of the polygon as T Austin said. Certain details suggest this may be a practical solution: Unfortunately, calculating [the ideal solution ] is both complex … Read more

Convert Pixels to Points

There are 72 points per inch; if it is sufficient to assume 96 pixels per inch, the formula is rather simple: points = pixels * 72 / 96 There is a way to get the configured pixels per inch of your display in Windows using GetDeviceCaps. Microsoft has a guide called “Developing DPI-Aware Applications”, look … Read more