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)

Fitting largest circle in free area in image with distributed particle

Lets do some maths my friend, as maths will always get to the end! Wikipedia: In mathematics, a Voronoi diagram is a partitioning of a plane into regions based on distance to points in a specific subset of the plane. For example: rng(1) x=rand(1,100)*5; y=rand(1,100)*5; voronoi(x,y); The nice thing about this diagram is that if … Read more

How to do a scatter plot with empty circles in Python?

From the documentation for scatter: Optional kwargs control the Collection properties; in particular: edgecolors: The string ‘none’ to plot faces with no outlines facecolors: The string ‘none’ to plot unfilled outlines Try the following: import matplotlib.pyplot as plt import numpy as np x = np.random.randn(60) y = np.random.randn(60) plt.scatter(x, y, s=80, facecolors=”none”, edgecolors=”r”) plt.show() Note: … Read more

Converting an svg arc to lines

SVG elliptic arcs are really tricky and took me a while to implement it (even following the SVG specs). I ended up with something like this in C++: //————————————————————————— class svg_usek // virtual class for svg_line types { public: int pat; // svg::pat[] index virtual void reset(){}; virtual double getl (double mx,double my){ return 1.0; … Read more