# moving object based on shrinkwrap constraint with python

I have a circle object within a triangle that I have previously been moving based on a mathematical constraint like so

positions.append(get_triangle_constraints([(0,0,0),(5,0,0),(2.5,5,0)]))


where the positions array corresponds with the circles possible points.

However I want to abstract this so have been trying to create a shrinkwrap constraint based on the triangle that would allow me to remove the mathematical constraints. My question is how can I tell the positions array you see above to append only points based on the constraint? Or is there another, more optimal way to iterate through a positions array when using a shrinkwrap constraint?

Below you can see the triangle and circles I am talking about. I currently constrained the circles by using line equations from the triangles vertices but would like to use a shrinkwrap constraint in a python script. Any help would be appreciated.