# How to compute the average distance till intersection within a triangle in R^2?

Lots of simple questions because I am a noob.

You are given 3 points in R^2; A, B, C forming a triangle with area > 0. You pick an arbitrary point inside ABC and an arbitrary direction. After some distance d you will intersect some side of a triangle. The task is to compute the expected d for a given triangle. Also, it would be nice to know the whole distribution. What kind of distribution (e.g. uniform, normal) would it be?

Next, what if I have a complex polygon? Can I combine my knowledge from individual triangles somehow to compute mean and distr. for the convex polygon?

Finally, how about a non-convex polygon?

-

If you call the random variable you described X, then it's much easier to compute the expected value of X2. Indeed, for any point P inside triangle ABC, the expected value of X2 where X is the length of a ray through P intersected with the interior of ABC is just the area of ABC divided by π—imagine trying to compute the area of ABC using polar coordinates with origin at P.

You can use a similar trick to write the expected value of X in terms of the average value of 1/d(P, Q) where P and Q are selected uniformly at random from the interior of triangle ABC, but this doesn't seem terribly helpful.

-

We can start by solving the problem for an arbitrary triangle and a fixed direction, say the upward direction, as we can always rotate the whole figure into that position.

In the generic case, no edge of the triangle is horizontal. Thus the triangle has a "top" vertex at (0, 0) -- this is the vertex with the largest y-coordinate. Without loss of generality, rescale so that the edge opposite the vertex at (0, 0) passes through (-1, 0). We'll say that the "height" of this triangle is 1, where by height we mean the length of the vertical dropped from the top vertex.

Then the set of points of vertical distance at least r from the top of the original triangle form a triangle of height 1-r, similar to the original triangle. Thus

$$Prob(\hbox{vertical distance from top } &gt; r) = (1-r)^2$$

and this gives the distribution. In particular the expected value of the vertical distance from a random point to the top of the triangle (after the rescaling given above) is 1/3.

If you want to pick a random direction, though, then this gets a lot harder because the rescaling step will act differently for different directions.

-
Trying to draw this. What is r? – S. Donovan Jan 2 '10 at 5:30

For a triangle, this seems relatively easy. construct the voronoi diagram of the sides, which in this case is merely the partition formed by the angle bisectors at each vertex. they intersect at the center of the incircle, forming three triangles. In each triangle, the 'distance to boundary' is really the distance to the corresponding side of the original triangle, and the answer is a straight integration.

-
I think the ray is in a uniformly random direction, not towards the nearest point on the boundary. – Reid Barton Jan 2 '10 at 5:04
ah dang. good point. missed that – Suresh Venkat Jan 2 '10 at 5:08

x is in the triangle. Draw segments that connect x to each vertex and segments perpendicular to each side from x. Then, starting from the nearest perpendicular segment, measure the angle formed by your vector and call it $\theta$. Note the length of the perpendicular, call it R. Then the distance, from x to the side in the direction of the vector, is: $R \sec (\theta)$.

-
This works for the convex... but not for the non-convex. – S. Donovan Jan 2 '10 at 5:03
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}