Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard mesh for Concave Hexagons with two Mouths?

I am planning a visualization of flows though Concave Bisymmetric hexagons with two mouths.

Example where the length of the side d1 equals the other length of the side d2:

enter image description here

which naming I discussed initially here about Irregular hexagons.

There is the standard Mesh tool where you can draw your own meshes but I would like have some standard library such that I can cooperate better with others with the flow simulations later. I did not find any Mesh library for Hexagons in MathCentral File Exchange here.

Is there any standard Mesh library for irregular hexagon shapes? I am open to any other languages too because I could read the code and convert it those standards to Matlab library.

like image 566
Léo Léopold Hertz 준영 Avatar asked May 23 '15 09:05

Léo Léopold Hertz 준영


4 Answers

For example you could take a look of example done by Alexandra Baumgart and Hazuki Okuda using Mathematica. This is implemented with Manipulate effectively creating a basic UI.

enter image description here

Code:

Manipulate[
Grid[{{Show[
ParametricPlot3D[{1.25Cos[t], 1.25 Sin[t],s+2-2w},{s,0,.25},{t,0,2Pi},PlotStyle->Directive[Opacity[1],Gray],Mesh->None, Lighting->"Neutral"], 
ParametricPlot3D[{r Cos[t], r Sin[t],2.25-2w},{r,0,1.25},{t,0,2Pi},PlotStyle->Directive[Opacity[1],Gray],Mesh->None, Lighting->"Neutral"],
ParametricPlot3D[{r Cos[t], r Sin[t],2-2w},{r,0,1.25},{t,0,2Pi},PlotStyle->Directive[Opacity[1],Gray],Mesh->None, Lighting->"Neutral"],
ParametricPlot3D[{1.25Cos[t], 1.25 Sin[t],s-2.25+2w},{s,0,.25},{t,0,2Pi},PlotStyle->Directive[Opacity[1],Gray],Mesh->None, Lighting->"Neutral"],
ParametricPlot3D[{r Cos[t], r Sin[t],-2.25+2w},{r,0,1.25},{t,0,2Pi},PlotStyle->Directive[Opacity[1],Gray],Mesh->None],
ParametricPlot3D[{r Cos[t], r Sin[t],-2+2w},{r,0,1.25},{t,0,2Pi},PlotStyle->Directive[Opacity[1],Gray],Mesh->None, Lighting->"Neutral"],  
ParametricPlot3D[{(1-s/2) Cos[t],(1-s/2) Sin[t],Max[0,-s+2 ]},{s,Min[2-(2^(2/3) (2 \[Pi]-Min[2Pi,3 V((w^2)/(.04))])^(1/3))/\[Pi]^(1/3)-w,1.99],2},{t,0, 2 Pi},PlotStyle->Directive[Opacity[1],Hue[a]],Mesh->None, Lighting->"Neutral"],
ParametricPlot3D[{r Cos[t], r Sin[t],Max[0,(2^(2/3) (2 \[Pi]-Min[2Pi,3 V((w^2)/(.04))])^(1/3))/\[Pi]^(1/3)-w]},{r,0, .000000000001+w+((2^(2/3) (2 \[Pi]-Min[2Pi,3 V((w^2)/(.04))])^(1/3))/\[Pi]^(1/3)-w)/2},{t,0,2Pi},PlotStyle->Directive[Opacity[1], Hue[a]],Mesh->None, Lighting->"Neutral"],
ParametricPlot3D[{r Cos[t], r Sin[t], Min[0,-(2^(2/3) (2 \[Pi]-Min[2Pi,3 V((w^2)/(.04))])^(1/3))/\[Pi]^(1/3)]},{r, 0, .00000000001+w+((2^(2/3) (2 \[Pi]-Min[2Pi,3 V((w^2)/(.04))])^(1/3))/\[Pi]^(1/3)-w)/2},{t,0,2Pi},PlotStyle->Directive[Opacity[1],Hue[a]],Mesh->None, Lighting->"Neutral"],
ParametricPlot3D[{(1-s/2) Cos[t],(1-s/2) Sin[t],Min[0,s -2 ]},{s,w,2},{t,0, 2 Pi},PlotStyle->Directive[Opacity[.2],Gray],Mesh->None, Lighting->"Neutral"],ParametricPlot3D[{(1-s/2) Cos[t],(1-s/2) Sin[t],Max[0,-s + 2 - w]},{s,w,2},{t,0, 2 Pi},PlotStyle->Directive[Opacity[.2],Gray],Mesh->None, Lighting->"Neutral"], 
ParametricPlot3D[{(1-s/2) Cos[t],(1-s/2) Sin[t],Min[0,s-2+ w]},{s,w,Min[2-(2^(2/3) (2 \[Pi]-Min[2Pi,3 V((w^2)/(.04))])^(1/3))/\[Pi]^(1/3)-w,2]},{t,0, 2 Pi},Mesh->None, PlotStyle->Directive[Opacity[1],Hue[a]], Lighting->"Neutral"],  ParametricPlot3D[{(w/2) Cos[t],(w/2) Sin[t], b},{t,0,2Pi}, {b, -2 + w, 0}, PlotStyle->Directive[Opacity[1], Hue[a]],Mesh->None, Lighting->"Neutral"],PlotRange->All,ImageSize->{300,300}, SphericalRegion-> True]},{Row[{Text["time to empty = "], Text[2Pi (.04)/(3w^2)],Text[" seconds"]}]}}],{start,ControlType->None},{end,ControlType->None},
{{V,.01,"time (seconds)"},0.01,34,.01,ControlType->Animator,AnimationRate->1,AnimationRunning->False,ImageSize->Small}, 
{{w,.05,"neck width (millimeters)"}, .05, .3,.01,Appearance->"Labeled"}, 
{{a,0,"color of sand"}, 0, 1,Appearance->"Labeled"}]

Source: http://demonstrations.wolfram.com/FlowTimeInAnHourglass/

like image 194
Margus Avatar answered Nov 16 '22 04:11

Margus


If this is to stand-in as purely the presentation layer, then it really depends on the output of the simulation and the representation you select for it.

For example, if the simulation outputs one single variable (e.g. the volume of one of the compartments), then this could be assigned directly to an attribute of the visualisation such as the location of the "top" cap of a cylinder. A "complementary" cylinder could stand on top of the previous one with its bottom-cap coordinates assigned to (totalVolume-lowerCompartmentVolume).

In this case, the visualisation is just a dashboard and does not feed back into the simulation (e.g. object collisions or proximity in general are not taken into account by the simulation).

To generalise this, we are talking about a solution where a set of quantities is assigned to a set of visualisation attributes.

From this point of view, a set of complex objects could be created using VRML (or X3D), their attributes could be binded directly to simulation outputs and the rendering be triggered every n-th simulation timestep.

To create the "scene" or visualisation objects, you can use a software like blender which can export VRML scenes, or write the VRML manually (it is really a straightforward task).

In terms of infrastructure, MATLAB has a VRML toolkit and Python has a really wide selection of modules by which VRML can be handled (please see this and this link for example).

For a more concrete example:

Given some simulation output y and a template VRML file like:

#VRML V2.0 utf8
Transform {
  translation 0 0 0
  children [
    Shape { geometry Box {2,2,zSize} }
  ]
}

You could do something like:

data = (Read contents of VRML file as string data).
for n in [0..1000]:
    y = getSimulationOutput(aParameterVector)
    renderData = substitute(data, "zSize", y) #This function could be provided by a template module like jinja for example. 
    simulationFrame = renderVRML(renderData)
    saveImage(simulationFrame)

(Please note: More information about Jinja can be found here - comment inline link not rendering properly above.)

Going back into the file and binding different elements to different quantities (for example, changing the transform which can rotate, scale, translate the box, or changing the appearance of the box by assigning a different colour), you can create any sort of "dashboard" output for your simulation....including irregular hexagons.

This technique is a direct application of Data Driven Documents but to a different substrate (than HTML or SVG) here.

Hope this helps.

like image 20
A_A Avatar answered Nov 16 '22 04:11

A_A


If your goal is to visualize such hexagons in matlab, then fill and fill3 should do the trick. Here is an example code, which assumes that your hexagons are parameterized by two widths w1 and w2 and the d1 and d2 parameters which are lengths of the sides:

function draw_hexagon(w1, w2, d1, d2)
    a=(w1-w2)/2;
    b1=sqrt(d1^2 - a^2);
    b2=sqrt(d2^2 - a^2);

    xs=[-w1/2, w1/2, w2/2, w1/2, -w1/2, -w2/2];
    ys=[b1, b1, 0, -b2, -b2, 0];

    fill(xs, ys, 'b')
    axis square 
    grid on
end

It will produce the following for w1=4, w2=2, d1=2, d2=3:

enter image description here

And similarly for 3D:

function draw_hexagon_3d(w1, w2, d1, d2)
    a=(w1-w2)/2;
    b1=sqrt(d1^2 - a^2);
    b2=sqrt(d2^2 - a^2);

    xs=[-w1/2, w1/2, w2/2, w1/2, -w1/2, -w2/2];
    ys=[0, 0, 0, 0, 0, 0];
    zs=[b1, b1, 0, -b2, -b2, 0];

    fill3(xs, ys, zs, 'b')
    grid on
    axis square 
end

we get:

enter image description here

like image 25
Andrzej Pronobis Avatar answered Nov 16 '22 04:11

Andrzej Pronobis


Trying to set a standard mesh library, I believe we should start by determining the degrees of freedom.

For concave bissymetric hexagons with 2 mouths it could be:

  1. mouth ax width (W_m)
  2. relative top width (w_t = W_t / W_m)
  3. relative bottom width (w_b = W_b / W_m)
  4. relative top height
  5. relative bottom height

The answers from Margus and A_A will be helpful for the realization.

like image 26
Bert Avatar answered Nov 16 '22 06:11

Bert