Density of lines passing through sides of a rectangle?

120 Views Asked by At

Edit: Reframed the problem to find an actual answer! Though I may well be talking to myself at this point. Answer below the original problem.


The original context of this question is a ridiculous, brainless mobile game. But the geometric question that arises seems quite interesting--I suspect it has already been studied. But I can't quite figure out how to calculate, or even if it can be calculated.

Consider a rectangle $ABCD$ centered on the origin (just for simplicity/symmetry). Now consider two sets of lines: $H$, the set of all lines passing through a point on $\overline{AB}$ and a point on $\overline{CD}$; and $V$, the set of lines passing through a point on $\overline{AD}$ and a point on $\overline{BC}$.

(Or perhaps more simply, all of the lines in $\mathbb{R}^2$ that pass through opposite sides of the rectangle.)

Is there a density function $f(x_0, y_0)$ that computes the proportion of these lines that pass through an infinitesimal area defined as any of the points $(x_0-\delta < x < x_0 + \delta, y_0 - \delta < y < y_0 + \delta)$? If not, can we find such a function that works for a non-infinitesimal area?

Other questions might include:

  • Does the density function change based on the length:width ratio, or does the function stretch uniformly as we deform the rectangle?
  • Does the shape of the inner square matter, e.g., would the density function change if it were a circle?

It seems to me that (assuming the function isn't just trivially uniform) an integral from $A$ to $B$ of the ratio: (the range of angles that create lines that pass through the inner square from this point)/(the range of valid angles of lines drawn from this point) would be a start. Then add similar integrals from the other three sides. (Or find the mean of the four?) But I'm wholly uncertain how to represent those ratios mathematically.

In addition, a first educated guess suggests the maximum density ought to be at the origin, if there is a maximum, and minima toward the corners.

Any thoughts? Or any references to a solution to this?



Answer

To get to an answer, I've simplified slightly and rearranged the parameters. Instead of trying to converge on an infinitesimal, I thought, maybe we could start with the infinitesimal, i.e., the point we want a probability for. Let's have a new diagram:

enter image description here

The square is centered at the origin, and its corners are at $(\pm 1, \pm 1)$. The point $P$ is at $(p,q)$. (You can mess with this diagram at GeoGebra if desired.)

All of the "admissible" lines will sit between $AV$ and $BU$ (horizontally) and between $CS$ and $DT$ (vertically). Hence the "density"--really, a probability--is the proportion $\frac{1}{\tau} (2 \alpha + 2 \gamma)$. It turns out, though, that determining $\beta$ is a lot easier than determining $\gamma$, so we will instead measure $\frac{1}{\tau} (\tau +2 \alpha - 2 \beta)$.

In fact, we can determine both $\alpha$ and $\beta$ using just the law of cosines. If we take the side length as $s$, we can see that:

$$ \begin{align} 2 ab \cos \alpha &= a^2 + b^2 - s^2 \\ 2 cd \cos \beta &= c^2 + d^2 - s^2 \\ \end{align} $$

The lengths $a, b, c,$ and $d$ are determined easily by the Pythagorean distance formula, which I'll assume is well-known. I could write out a bunch of messy equations here, but I'm pretty sure that's not useful.

However, there is one more thing of note. Just as a square has eightfold symmetry, the probability at various points has the same. That is, one should expect the same probability for points at $(0.6, 0.3), (-0.6, -0.3)$, and $(0.3, -0.6)$. Hence, the following transformations make the math slightly simpler:

$$ x' = \max(|x|, |y|) \ ; \ y' = \min(|x|, |y|) $$

This transform maps every point in the square onto a point with $x \geq 0, y \geq 0, x \geq y$.

Other minor points of interest:

  • At the origin, the probability is $1$, as all the angles are right angles. Note that "probability" at this point means "number of points at the edges that can produce an admissible line, divided by all points."
  • The probability drops to a minimum of $0.25$ at the corners, and to around $0.30$ at the centers of the edges.
2

There are 2 best solutions below

0
On

Let $A=(a/2;b/2)$, $B=(-a/2;b/2)$, $C=(-a/2;-b/2)$, $D=(a/2;-b/2$.

Consider rectangle $(x,y;x+dx,y+dy)$, taking for simplicity (because of symmetry) $x>0$, $y>0$.

The minimum slope for this rectangle is $k_{min}=\frac{y}{x+dx}=\frac{y}{x}\frac{1}{1+dx/x}=\frac{y}{x}(1-dx/x)=\frac{y}{x}-\frac{y}{x^2}dx$. The maximum slope is $k_{max}=\frac{y+dy}{x}=\frac{y}{x}+\frac{1}{x}dy$.

The number of lines going through the rectangle is $N=\int_{k_{min}}^{k_{max}} f(k) dk$, where $f(k)$ is distribution function for slopes. $k_{min}-k_{max}=\frac{1}{x}dy+\frac{y}{x^2}dx$, $N=f(y/x) \cdot\left(\frac{1}{x}dy+\frac{y}{x^2}dx\right)$. $N$ is not proportional to $dx dy$, so we cannot use density per area here, but we can introduce line density as ratio of $N$ to infinitesimal square side $dy=dx$. Such density is $f(y/x)\cdot (1/x+y/x^2)$.

The constant slope distribution function $f(k)=A$ makes lines distibution more dense along $y$-axis ($x=0$), because this area corresponds to infinite $k$-range.

1
On

In the spirit of trying to continue through with my own progress, here is a partial answer that gets us much closer. First, a picture from GeoGebra. You can play with it here; points $M$ and $P$ are moveable. Figure 1

I've made some decisions/changes for simplicity. First, the rectangle $ABCD$ is now a unit square, with $A$ at the origin. Second, so that we can readily use angles, the area of interest is a circle around point $P:(a,b)$ with radius $r$. This lets us use tangents, and eliminates some (literal) corner cases. We take the distribution of angles as uniform; it seems to me this might be easier than uniform distribution of slopes--if they're not the same.

In the end, we want to integrate on $x$ between $0$ and $1$, and find some function $f(x)$ to calculate the ratio between the angle of the green area and the angle of the blue area. Eventually we'll want to find the limit as $r \to 0$.

There are several angles to define on the diagram, all of which are technically functions of $x$. We measure from the vertical.

  • The angle directly through point $P$ is $\alpha = \arctan \frac{a-x}{b}$
  • The angle between $\alpha$ and the two tangent lines is $\delta = \arcsin \frac{r}{d}$, where $s$ is the distance between points $M$ and $P$, i.e., $d = \sqrt{(a-x)^2 + b^2}$
  • The leftmost angle allowed--that is, the one passing through point $D$--is $\gamma = \arctan (-x)$
  • The rightmost angle allowed, passing through point $C$, is $\beta = \arctan (1-x)$

What, then, is $f(x)$? It seems like we might be able to get away with a single integral if we can define (the green area)/(the blue area) at each $x$. And that seems easy enough: it's just $\frac{2\delta}{\beta - \gamma}$. Which works most of the time... unless $\alpha + \delta > \beta$, or $\alpha - \delta < \gamma$. Then, the green area is partly (or fully) outside the blue area, and the simple fraction fails to work. Instead, then, $f(x)$ is a piecewise function:

$$ f(x) = \begin{cases} 0, & \beta < \alpha - \delta \\ \frac{\beta - \alpha + \delta}{\beta - \gamma}, & \alpha - \delta \leq \beta < \alpha + \delta \\ \frac{2\delta}{\beta - \gamma}, & \gamma \leq \alpha - \delta < \alpha + \delta \leq \beta \\ \frac{\gamma - \alpha + \delta}{\beta - \gamma}, & \alpha - \delta < \gamma \leq \alpha + \delta \\ 0, & \gamma > \alpha + \delta \end{cases} $$

Integrating a piecewise function is plenty doable; we take the integrals of the pieces. But here it gets complicated, because the limits on the integrals are functions of the variable of integration. If I understand correctly, we can safely swap in a separate variable, so that we integrate with limits in $t$ and the function in $x$, so that:

$$\int_{t=0}^{t=1} f(x) \ dx = \int_{t: \ \beta = \alpha - \delta}^{t: \ \beta = \alpha + \delta} \frac{\beta - \alpha + \delta}{\beta - \gamma} \ dx + \int_{t: \ \beta = \alpha + \delta}^{t: \ \gamma = \alpha - \delta} \frac{2\delta}{\beta - \gamma} \ dx + \int_{t: \ \gamma = \alpha - \delta}^{t: \ \gamma = \alpha + \delta} \frac{ \alpha + \delta - \gamma}{\beta - \gamma} \ dx$$

where in the limits, the angles are functions of $t$, and in the integrand, they are functions of $x$. The lower limit of the first or second integral can be $t=0$, and the upper limit of the second or third integral can be $t=1$. In the cases where the green area is always within the blue area, only the second integral remains, with limits of $0$ and $1$.

I have yet to do the trig work and actual integration. We'll see what develops as I go through that. And of course we do this for all four sides and average the four results, I believe.