I have the following problem which is most easily described by this diagram:
We start off with a quadrilateral, not necessarily a square, with four fixed points, here represented in green. We have a fifth point p
, here shown in red. At the start, the user can freely place this point anywhere in the initial quad. This could be a Locator
in a Manipulate
for example. In the remaining iterations, this point is just the centroid of the enclosing quad.
The algorithm looks something like this:
- Calculate the blue midpoints of the four edges of the current quad enclosing the red point.
- Create four new quads by joining the midpoints up to the red point. The red point is custom on the first iteration, and after that is just the centroid of the quad.
- Repeat, continuing to recursively subdivide each new quad until reaching some maximum depth.
One avenue I am exploring is adapting the code from this question but I want most of all to be able to move the seed (red) point around interactively.