Is there a simpler equation for this 2-d Analog to Coefficent of Variation?

52 Views Asked by At

I'm creating a test that measures how evenly distributed is closed curve $\mathcal{C}$. This requires the average ray length (from point $(u,v)$ to the boundary of the shape) inside $\mathcal{C}$ using ray length per radian measure.

Suppose $\mathcal{C}$ can be represented as $(a_1(t),a_2(t))$. We start by finding the average absolute deviation between the ray length and a constant length.

\begin{equation} \min\limits_{z} \left\{\int\limits_{a_1(p_1)}^{a_1(p_2)}\left|\sqrt{\left(a_1(t)-u\right)^2+\left(a_2(t)-v\right)^2}-z\right| d\theta\right\} \label{Minimum} \end{equation}

\begin{equation} \min\limits_{z} \left\{\int\limits_{a_1(p_1)}^{a_1(p_2)}\left[\left|\sqrt{\left(a_1(t)-u\right)^2+\left(a_2(t)-v\right)^2}-z\right| \frac{d\theta}{dt}\left(\frac{1}{2\pi}\tan^{-1}\left(\frac{a_2(t)-u}{a_1(t)-v}\right)\right)\right] dt \right\} \label{Minimum2} \end{equation}

Where $a_1(p_1)<t<a_1(p_2)$ parametrizes the entire shape

Here is picture to clarify.

SS

(Note the blue circle is created by the angular displacement from the rotated tip of the constant length. Once the tips' back in its initial position, the displacement should be $2\pi$ radians. Hence, $(u,v)$ must remain inside the shape for a credible distribution number.)

This can be found by setting the "constant" to the average radius $\overline{r}(u,v)$. Hence we are taking the mean absolute deviation. Say this function, in terms of $(u,v)$ is

\begin{equation} \int\limits_{a_1(p_1)}^{a_1(p_2)}\left[\left|\sqrt{\left(a_1(t)-u\right)^2+\left(a_2(t)-v\right)^2}-\overline{r}(u,v)\right|\frac{d\theta}{dt}\left(\frac{1}{2\pi}\tan^{-1}\left(\frac{a_2(t)-u}{a_1(t)-v}\right)\right)\right]dt \label{AverageRadiusIn} \end{equation}

In order to keep the radius consistent to curves geometrically similar, we divide the integral by the average radius. This gives us distribution $\phi(u,v)$.

\begin{equation} \phi(u,v)=\frac{1}{\overline{r}(u,v)}\int\limits_{a_1(p_1)}^{a_1(p_2)}\left[\left|\sqrt{\left(a_1(t)-u\right)^2+\left(a_2(t)-v\right)^2}-\overline{r}(u,v)\right|\frac{d\theta}{dt}\left(\frac{1}{2\pi}\tan^{-1}\left(\frac{a_2(t)-u}{a_1(t)-v}\right)\right)\right]dt \label{CompleteEquation} \end{equation}

Which determines how evenly distributed is curve $\mathcal{C}$.

In a post, a code was given to parametrize implicitly defined $\mathcal{C}$ using arclength.

     expr = (x^2 + y^2 + Sin[4 x] + Sin[4 y] - 4)^2 + .415 x - .4;
        exprt = expr /. {x -> x[t], y -> y[t]};
        odes = {D[exprt, t], x'[t]^2 + y'[t]^2 - 1}
        starty = y /. FindRoot[(expr /. x -> 0) == 0, {y, 2/9}]
        Quiet[soln = 
           NDSolveValue[
            Join[Thread[odes == 0], {x[0] == 0, y[0] == starty}], {x[t], 
             y[t]}, {t, 0, 25}];]
        {solnX, solnY} = soln;
        ParametricPlot[soln, {t, 0, 25}]
        Plot[(solnX - 0)^2 + (solnY - starty)^2, {t, 0, 25}]
        {min, val} = NMinimize[(solnX - 0)^2 + (solnY - starty)^2, {t, 20, 25}]
        stopt = t /. val;
        r = Compile[{{x, _Real}, {y, _Real}}, 
          NIntegrate[
            Sqrt[(solnX - x)^2 + (solnY - y)^2]*
             D[ArcTan[solnX - x, solnY - y], t], {t, 0, stopt}, 
            MaxRecursion -> 100, Method -> "Trapezoidal"]/(2*Pi)]

s = Compile[{{x, _Real}, {y, _Real}}, 
  NIntegrate[
    Abs[Sqrt[(solnX - x)^2 + (solnY - y)^2] - r[x, y]]*
     D[ArcTan[solnX - x, solnY - y], t], {t, 0, stopt}, 
    MaxRecursion -> 100, Method -> "Trapezoidal"]/(2*Pi)]

The distrbution number is

Phi = Compile[{{x, _Real}, {y, _Real}}, s[x, y]/r[x, y]]

However, there is no clear way of determining where to measure $(u,v)$. If we set $(u,v)$ to the centroid, it could be outside the curve and hence the ray won't rotate with an angular displacement of $2\pi$ radians. So where do we set $(u,v)$?

My assumption is to take the average of $\phi(u,v)$ inside $\mathcal{C}$. This leads to a brutal formula.

$$\omega=\frac{1}{\text{Area}\left(\mathcal{C}\right)} \iint\limits_{C} \phi(u,v) \ du \ dv$$

Question

Is there a simpler way to describe the integral and distribution?