## Merging rectangles into rectilinear polygon

Having a set of adjacent rectangles, what would be the algorithm that gets the rectilinear polygon wrapping around them?

## Draw off center connection between rectangles

I am trying to create a sequence diagram using draw.io

For that, I need to create long rectangles and draw multiple connections between them along the side of the rectangle.

However, using the blue arrow that creates connections, I can only draw connections to and from the center of the rectangle. I have to manually drag the arrow to the desired position.

Is there a way to make this quicker?

## Defining Measure 0 Sets with Open or Closed Rectangles

I have been reading through Calculus on Manifolds by Michael Spivak, and I am not understanding what he states after defining measure 0 sets. On page 50, he states

“A subset $$A$$ of $$\mathbb{R}^n$$ has (n-dimensional) measure 0 if for every $$\varepsilon > 0$$ there is a cover $$\{U_1, U_2, U_3, \dotsc\}$$ of $$A$$ by closed rectangles such that $$\sum_{i = 1}^\infty v(U_i) < \varepsilon$$.”

And follows this by stating

“The reader may verify that open rectangles may be used instead of closed rectangles in the definition of measure 0.”

I have been trying to prove the equivalence between the definition of measure zero with open rectangles and closed rectangles. I have been able to prove that if we can do this with open rectangles, then we can do it with closed rectangles. However, I have not been able to prove the other direction. I have written the question as the following statement:

Suppose that for $$A \subset \mathbb{R}^n$$ and $$\varepsilon > 0$$, there is a cover $$\{F_1, F_2, F_3, \dotsc\}$$ of $$A$$ by closed rectangles such that $$\sum_{i = 1}^\infty v(F_i) < \varepsilon$$. Then, for any $$\varepsilon’ > 0$$, there is a cover $$\{U_1, U_2, U_3, \dotsc\}$$ of $$A$$ by open rectangles such that $$\sum_{i = 1}^\infty v(U_i) < \varepsilon’$$.

Spivak Page 50

I included the Lebesgue measure, since I understand Spivak’s definition of volume of a rectangle to be connected, but if this is incorrect, feel free to remove that tag.

## Area of Union Of Rectangles using Segment Trees

I’m trying to understand the algorithm that can be used to calculate the area of the union of a set of axis aligned rectangles.

The solution that I’m following is here : http://tryalgo.org/en/geometry/2016/06/25/union-of-rectangles/

The part I don’t understand is :

The segment tree is the right choice for this data structure. It has complexity O(logn) for the update operations and O(1) for the query. We need to augment the segment tree with a score per node, with the following properties.

• every node corresponds to a y-interval being the union of the elementary y-intervals over all the indices in the span of the node.
• if the node value is zero, the score is the sum of the scores of the descendants (or 0 if the node is a leaf).
• if the node value is positive, the score is the length of the y-interval corresponding to the node.

How do we achieve this in O(n log n) ?

My idea was to create a segment tree, and update each range’s value as and when we encounter the range(y range as the height of the rectangle) while line sweeping. And then for for each interval(two consecutive elements in the sorted x array, multiple Δx by the total length of the y range active in this interval, by looking at the sum of all elements in the segment tree)

This would still leads us to having max(y) – min(y) elements in the segment tree’s base.

Hence, I’m not sure how this is O(n log n) – where n is the number of rectangles.

Would greatly appreciate any help here.

I got an answer here : https://stackoverflow.com/questions/55702005/area-of-union-of-rectangles-using-segment-trees

But I’m not sure I understand @Photon’s solution.

Thanks!

## I am having problem with displaying the svg rectangles with D3.js and using data through firebase

My firestore databse is saved in a follwing way: *Collection is “test” *Document “google auto generated id” *Data: 2 arrays, [1] is month_name = [Jan, Feb, Mar, Apr, May] [2] is ac_output = [20, 15, 5, 14, 3]

I was able to retrieve data from the database, but none of the rectangles displayed on the browser. Then, I tried to show one rectangle at a time, but still no success. I am not even getting any error on the console, so I dont know where the problem is in my code. I really need help with this. Thanks

//Javascript Code:  //select the svg container const svg = d3.select('.canvas')   .append('svg')     .attr('width', 600)     .attr('height', 600);  //get data from the firestore db.collection('test').get().then(res => {    var data = [];   res.docs.forEach(doc => {         data.push(doc.data());   });  //append data to the rects in the DOM const rects = svg.selectAll('rect')                 .data(data);  //set the attributes for rects in DOM   rects.attr('width', 50)                 .attr('height', function(...d) {                                   return d[0].ac_output})                 .attr('fill', 'orange')              .attr('x', (d, i) => i*70)  //append the enter selection to the DOM      rects.enter()                 .append('rect')                   .attr('width',50)                   .attr("height", function(...d) {                                return(d[0].ac_output})                                       .attr('fill', 'orange') })

The expected result is supposed to be a bunch of rectangles on the browser for now, which will eventually be turned into a bar graph.

## Suppose $f:[0,1]\times[0,1]\mapsto X$ is a continuous function. Show that $[0,1]\times[0,1]$ can partitioned into rectangles s.t $f(R_i)\subseteq U_k$

Suppose $$f:[0,1]\times[0,1]\mapsto X$$, is a continuous function where $$X$$ compact and connected subset of $$\mathbb{R}^n$$. Show that $$[0,1]\times[0,1]$$ can partitioned into rectangles $$R_i$$ such that $$f(R_i)\subseteq U_i$$ where $$U_i\in C$$ a cover for $$X$$.

My attempt at a proof:

Choose a cover $$C$$ of $$X$$.

Since $$f$$ is a continuous function on a compact set it is uniformly continuous.

Thus there exists a $$\delta>0$$ such that $$\forall \epsilon>0$$ and $$\forall x,y\in [0,1]\times[0,1]$$ if $$\vert x-y\vert<\delta$$ then $$\vert f(x)-f(y)\vert<\epsilon$$

Choose $$R_i$$ with side lengths $$\frac{\delta}{\sqrt{2}}$$, idea is to guarantee the elements in the rectangles are $$\delta$$ close. Then the image $$f(R_i)$$ can be contained in a ball $$B_\epsilon(f(x))$$ for any point $$f(x)\in f(R_i)$$ for any $$\epsilon>0$$. Since the open cover is fixed we can choose $$\epsilon=\max d(x,y)$$ for any $$x,y\in U_i$$ for any $$U_i\in C$$. So that $$f(R_i)\subseteq B_\epsilon(f(x))$$ for some $$f(x)\in f(R_i)$$ and $$B_\epsilon(f(x))\subseteq U_i$$

Does this seem correct? I think there are some issues with my choice of $$\epsilon$$.

## Fitting $\frac1n\times\frac1{n+1}$ rectangles into the unit square

Consider the set of rectangles $$r_n | n \in \Bbb N$$ such that rectangle $$r_n$$ has shape $$\frac1n\times\frac1{n+1}$$. The total area composed by one copy of each $$r_n$$ as $$n$$ ranges from $$1$$ to infinity is $$1$$. Call that set of rectangles $$S$$.

In Concrete Mathematics it is speculated that you can fit all the rectangles in $$S$$ into a unit square, without overlap of any interior area. It is also speculated (by the second author) that they can’t all be fit, and it is presented as a research problem.

I have a computer-based approach which could potentially decide the issue if you can’t fit them (but won’t provide a proof if they can fit). In particular, it seems to indicate that if you add the restriction that the rectangles (ordered by area) are forced to alternate long-side-vertical and long-side-horizontal, you come to an impasse.

But since the volume I saw it in is 25 years old, I’m wondering, before implementing and error-checking and optimizing the method for arbitrary placement, whether this question has, in the intervening years, been resolved.

So my question is

Is it known whether $$S$$ can be packed into a unit square, without overlap?

## Arithmetic that corresponds to combinatorial rectangles and cylinder intersections?

Definable subsets of $$\mathbb N$$ in the language of Presburger arithmetic are exactly the eventually periodic sets.

In communication complexity the interpretation is more on intersection and union of combinatorial rectangles or complements of combinatorial cylinder intersections which does not seem to be as nice as what comes from geometric interpretation of Presburger.

Is there an arithmetic that corresponds to definable sets in communication complexity?

Would it be reasonable to expect something?

## Highest stack of rectangles

Suppose we have a set of $$n$$ dimensional rectangles $$R = \{(x_{i,1}, \ldots, x_{i,n}), i \in 1 \ldots k\}$$. We want to create the highest stack in say the first dimension such that each side of the rectangles form a monotonically increasing sequence. More formally from the $$l-tuples$$ satisfying this

$$\max_{l: (j_{1}, \ldots, j_{l}), j_{i} \in 1 \ldots k, j_{q} = j_{p} \iff q = p}{\forall q \in 1 \ldots l – 1, \forall p \in 1 \ldots n: x_{j_{q}, p} < x_{j_{q + 1}, p}}$$

take the one with the maximal $$\sum_{i = 1}^{l}{x_{j_{i}, 1}}$$ or just simply calculate this maximal value.

What’s the algorithmic complexity of this? For $$n = 1$$ we can think of this as a weighted LIS. Is there a better approach than just sorting it on the first dimension and trying to find the longest increasing sub sequence for all dimensions?

## Tiling a square with rectangles whose areas or perimeters are 1, 2, 3, … N

For which positive integers N does there exist a square that can be completely tiled with rectangles whose areas or perimeters are precisely 1, 2, 3 …N?