Skip to main content

computational geometry - Is there a numerical method/built-in to calculate the boundary of a set of graphs?


Recently, I encounted a geometry problem in my work. For a curve-family that owns the following parametric equation: $$E(t,\theta)= \begin{pmatrix} x_E(t,\theta) \\ y_E(t,\theta) \end{pmatrix}$$


where, $\theta \in [0,2\pi]$ and $t\in [0,1]$


Traditionally, I could apply the envelope theory to solve the points that located in the boundary.


$$\frac{\partial x_E(t,\theta)}{\partial t}\frac{\partial y_E(t,\theta)}{\partial \theta}-\frac{\partial x_E(t,\theta)}{\partial \theta}\frac{\partial y_E(t,\theta)}{\partial t}=0 \qquad (1)$$


So for the fixed $t_i$, the parameter of envelope-point $\theta_i$ could be solved with equation$(1)$


Here is a normal instance that using above theory(denoted envelope-point with $\color{blue} \square$).


enter image description here



Obvisouly, I can connect $P_{0,1}, P_{1,1}, \dots P_{4,1}$ and $P_{0,2},P_{1,2},\dots P_{4,2}$ in sequence to achieve the boundary/envelope.


However, for the complicated case, there are only some envelope-points(denoted with $\color{blue} \square$) on the boundary/envelope. That is, the envelope theory will unapplicable.


enter image description here


So my question is:



  • Is there a numerical method/built-in to calculate the boundary?(and achieve the coordinates of points that located on the boundary)




Update


Here are some data



coeff = {{{0., -5., 0}, {-5.2203, 0., 1.7945}}, 
{{-0.4188, -4.9846, 0.1071}, {-5.3218, 0.3923, 2.0267}},
{{-0.8583, -4.9384, 0.1765}, {-5.4189, 0.7822, 2.3088}},
{{-1.3234, -4.8618, 0.2192}, {-5.5122, 1.1672, 2.6475}},
{{-1.8203, -4.7553, 0.2473}, {-5.6022, 1.5451, 3.0486}},
{{-2.3568, -4.6194, 0.2742}, {-5.6897, 1.9134, 3.5173}},
{{-2.9427, -4.455, 0.3147}, {-5.7755, 2.27, 4.0578}},
{{-3.5912, -4.2632, 0.3857}, {-5.8604, 2.6125, 4.6738}},
{{-4.3197, -4.0451, 0.5068}, {-5.9456, 2.9389, 5.368}},
{{-5.1524, -3.802, 0.7017}, {-6.0327, 3.2472, 6.1428}},

{{-6.1237, -3.5355, 1.}, {-6.1237, 3.5355, 7.}}};

coeff2 = {{{0., -5., 0}, {-5.2203, 0., 1.7945}},
{{-0.4188, -4.9846, 0.3754}, {-5.3218, 0.3923, 1.8307}},
{{-0.8583, -4.9384, 0.6792}, {-5.4189, 0.7822, 1.8663}},
{{-1.3234, -4.8618, 0.9146}, {-5.5122, 1.1672, 1.9093}},
{{-1.8203, -4.7553, 1.0855}, {-5.6022, 1.5451, 1.9672}},
{{-2.3568, -4.6194, 1.1959}, {-5.6897, 1.9134, 2.047}},
{{-2.9427, -4.455, 1.2502}, {-5.7755, 2.27, 2.1556}},
{{-3.5912, -4.2632, 1.2528}, {-5.8604, 2.6125, 2.2995}},

{{-4.3197, -4.0451, 1.2087}, {-5.9456, 2.9389, 2.4846}},
{{-5.1524, -3.802, 1.1229}, {-6.0327, 3.2472, 2.7164}},
{{-6.1237, -3.5355, 1.}, {-6.1237, 3.5355, 3.}}};

which are the coefficient of ellipse. Namely, {{a,b,c},{d,e,f}}


$\begin{cases} x=a \sin\theta+b \cos\theta +c \\ y=d \sin\theta +e \cos\theta +f \\ \end{cases}$


ellipsePoints[{mat1_, mat2_}] :=
{mat1.{Sin[#], Cos[#], 1},
mat2.{Sin[#], Cos[#], 1}} & /@ Range[0, 2 Pi, 0.02 Pi]


points = Flatten[ellipsePoints /@ coeff, 1];
points2 = Flatten[ellipsePoints /@ coeff2, 1];

Thanks for RunnyKine's alphaShapes2D[] with diferent threshold :1,3


reg = RegionBoundary@alphaShapes2D[points, 1];
Show[{reg, ListPlot[points, AspectRatio -> Automatic]}, Axes -> True]

reg2 = RegionBoundary@alphaShapes2D[points, 3];
Show[{reg2, ListPlot[point2s, AspectRatio -> Automatic]}, Axes -> True]


enter image description here



Answer



Here is another answer inspired by Rahul's answer that also uses only built-in functions:


RegionBoundary @ DiscretizeGraphics @ Graphics[Polygon /@ ellipsePoints /@ coeff]

Mathematica graphics


RegionBoundary@
DiscretizeGraphics@Graphics[Polygon /@ ellipsePoints /@ coeff2]

enter image description here



RegionBoundary@
DiscretizeGraphics@
Graphics[Polygon /@
Table[
Table[
RotationMatrix[m].{2 + 5 Cos[x], 3 + 6 Sin[x]},
{x, 0, 2 Pi, 0.02 Pi}], {m, 0, Pi, Pi/20}]]

enter image description here


Comments

Popular posts from this blog

plotting - Filling between two spheres in SphericalPlot3D

Manipulate[ SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, Mesh -> None, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], {n, 0, 1}] I cant' seem to be able to make a filling between two spheres. I've already tried the obvious Filling -> {1 -> {2}} but Mathematica doesn't seem to like that option. Is there any easy way around this or ... Answer There is no built-in filling in SphericalPlot3D . One option is to use ParametricPlot3D to draw the surfaces between the two shells: Manipulate[ Show[SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], ParametricPlot3D[{ r {Sin[t] Cos[1.5 Pi], Sin[t] Sin[1.5 Pi], Cos[t]}, r {Sin[t] Cos[0 Pi], Sin[t] Sin[0 Pi], Cos[t]}}, {r, 1, 2 - n}, {t, 0, Pi}, PlotStyle -> Yellow, Mesh -> {2, 15}]], {n, 0, 1}]

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]

plotting - Mathematica: 3D plot based on combined 2D graphs

I have several sigmoidal fits to 3 different datasets, with mean fit predictions plus the 95% confidence limits (not symmetrical around the mean) and the actual data. I would now like to show these different 2D plots projected in 3D as in but then using proper perspective. In the link here they give some solutions to combine the plots using isometric perspective, but I would like to use proper 3 point perspective. Any thoughts? Also any way to show the mean points per time point for each series plus or minus the standard error on the mean would be cool too, either using points+vertical bars, or using spheres plus tubes. Below are some test data and the fit function I am using. Note that I am working on a logit(proportion) scale and that the final vertical scale is Log10(percentage). (* some test data *) data = Table[Null, {i, 4}]; data[[1]] = {{1, -5.8}, {2, -5.4}, {3, -0.8}, {4, -0.2}, {5, 4.6}, {1, -6.4}, {2, -5.6}, {3, -0.7}, {4, 0.04}, {5, 1.0}, {1, -6.8}, {2, -4.7}, {3, -1.