Visual Methods for Dividing a Closed Plane using n Lines for Animation with Manim

56 Views Asked by At

I am planning to use Manim to animate the process of dividing a closed plane into $\frac{n(n+1)}{2} + 1$ regions using $n$ lines. The formula is derived from this recurrence relation: \begin{align} L_0&=1 \\ L_n&=L_{n-1} + n \end{align} However, manually placing each line to satisfy the relation can be difficult. Are there any systematic methods to draw the lines such that the relation is always satisfied? It is possible to draw $n$ lines that are not parallel to each other, but I am looking for something visually intuitive, something that will clearly show the divided regions as I add more lines.

1

There are 1 best solutions below

2
On BEST ANSWER

Have you thought about a rendering under the form of a checkerboard pattern, i.e., with alternating white and colored polygons ?

enter image description here

It can be realized in a very simple manner in Matlab (but most software would allow to use "fill" function in the same way) like this :

 T=2*pi*rand(1,50);
 fill(sin(T),cos(T),'r');

(I have chosen to place endpoints of line segments on the unit circle but they can be placed elsewhere).

Edit : Here is now a Matlab program using the above principle giving a progressive "uprising" of lines and their associated "regionalizations" :

 clear all;close all;hold on;axis equal off;
 axis([-1,1,-1,1]);
 set(gcf,'color','w');
 c=0.6154;n=13; % can be changed !
 T=c*(1:n)+0.1*rand(1,n); mult. of c + small random perturbations
 T=2*pi*(T-floor(T)); % fractional parts of 2*pi
 for k=3:n;
    u=T(1:k); % k lines are drawn
    f=fill(cos(u),sin(u),'r');
    set(f,'Visible','on','Edgecolor','none');
    pause(0.25);% not to small to avoid "flickering"
    if k<n;set(f,'Visible','off');end;
 end;

I wish you can implement these features in Manim langage.