# 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.

• Please add images to your question to clarify your intention. May 17, 2018 at 14:14
• I have edited to show you an example of triangles and circles May 22, 2018 at 20:14
• What you are trying to do is still pretty unclear. You want to find random positions inside a triangle? You have 3D coordinates but "triangle" and 3 points only constitute a flat triangle? You want the points ON this triangle face? You could use particle system for instance. Do you want to have these exact points but to "clamp" them to the triangle that you plan to move somehow? Jun 4, 2018 at 7:51
• @kheetor these points move around the triangle in a simulation, but they need to be constrained to stay within the triangle. For sake of clarity, this means they can be at any place in the triangle at any time, as long as they don't leave it's bounds. The triangle will not move but the 3 circles do move within the triangle. Jun 4, 2018 at 16:18
• When making a simulation, wouldn't it make sense to constraint them to the specified area or volume via actual physics since there are built-in solutions for managing and baking simulations? This is not exactly my area of expertise though. Jun 5, 2018 at 8:44