That's a longish notebook filled with redundant code, unused code, and very little to explain what is going on. The description of what is going wrong is also seriously lacking (I could not understand it).
Start from basic principles. A limacon has an implicit equation in cartesian coordinates, that is, a quartic of the form p(x,y)=0
. A point is inside or outside depending on whether p
evalautes to less than or greater than zero. If there is an inner loop you may need to decide whether you want to regard points therein as inside or outside, and adjust accordingly.
At a minimum, pare down the code to essentials and explain very clearly what it is that's wanted.