Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In addition to my previus post, regarding plotting the surface of a Möbius strip, I now realised, that some of the eigenmodes for a Möbius strip are either oscillations of a scalar field OR a vector field, meaning that not all eigenmodes of this object can be shown in 3D as wobbles in the direction normal to the surface, because the Möbius strip is not orientable, like a cylinder is.

Now that I have learned this fact, I have to do the following:

  1. Represent all transversal oscillations as wobbles in the direction normal to the surface. This means that these are oscillations of a vector field with only one component. This has been succesfully done with the help in my previous question. Here is the solution for the case of a cylinder.

  2. I need to represent all the longitudinal oscillations as oscillations of a scalar field, which is usually done by showing changes of color on an object, like shown in this example for a cylinder: enter image description here

Problem

I would like to plot 4D data $(x,y,z,F)$ as a set of polygons that have been made using DelaunayTriangulation[] of a 2D mesh in 3D using Graphics3Dfor the case of a Möbius strip, where $(x,y,z)$ are the data points and $F$ is the color.

In my previous question I noted that ListSurfacePlot3D and ListPlot3D are not working properly for the case of the Möbius strip. The solution was to plot the strip as a set of polygons, generated by the mesh. A uniformly colored polygon surface looks like this: enter image description here

What I want

I would like to color these polygons with the color equal to the average value of $F$ for the surrounding 3 points.

Here is the provided data and code

Original 2D data of a rectangular $[0,1]\times[0,1]$ membrane:

data2D = Import["http://pastebin.com/raw.php?i=0Liw8F1r", "NB"];

Transformed 4D data parametrised as a Möbius strip with color data as the 4th column:

data4D = Import["http://pastebin.com/raw.php?i=zgrCRiQh", "NB"];

The code to draw the strip without the color data $F$:

tri = First@
   Cases[ListDensityPlot[Join[#, {0}] & /@ data2D], 
    Polygon[idx_] :> idx, Infinity];    

Graphics3D[
     GraphicsComplex[
      data4D[[;; , 1 ;; 3]], {Yellow, EdgeForm[], Polygon /@ tri}], 
     Boxed -> False, AspectRatio -> 1, BoxRatios -> Automatic, 
     SphericalRegion -> True, 
     PlotRange -> 0.9 {{-1, 1}, {-1, 1}, {-0.5, 0.5}}, ImageSize -> Large]

I tried to find some answers before posting the question, but all solutions had either discrete points or smooth plots in 3D, andI need to color the specific polygons.

Thank you all for your help, I hope that the problem is clearly stated.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Something like this?

data2D = Import["http://pastebin.com/raw.php?i=0Liw8F1r", "NB"];
data4D = Import["http://pastebin.com/raw.php?i=zgrCRiQh", "NB"];

Find min and max values for the color data

{min, max} = {Min[#], Max[#]} &@data4D[[All, -1]];

Now, I place a color in front of each polygon (like {color1, polygon1, color2, polygon2, ...}) when specifying the graphics used by GraphicsComplex. The color1 is the average of the color data (according to data4D) specified at each vertex of polygon1.

Labeled[Graphics3D[
  GraphicsComplex[
   data4D[[;; , 1 ;; 3]], {EdgeForm[], 
    Map[{ColorData["DarkRainbow"][
        Rescale[Mean[Part[data4D, #1, -1]], {min, max}]], 
       Polygon[#1]} &, tri]}], Boxed -> False, AspectRatio -> 1, 
  BoxRatios -> Automatic, SphericalRegion -> True, 
  PlotRange -> 0.9 {{-1, 1}, {-1, 1}, {-0.5, 0.5}}, 
  ImageSize -> Large], 
 BarLegend[{"DarkRainbow", {min, max}}], Right]

enter image description here

share|improve this answer
    
Great! This is exactly what I wanted. I had trouble getting the point data from the corresponding indices in a certain polygon. Thank's a lot! –  MasterApprentice Jul 9 at 17:19
    
Is it just me, or does this take a lot of time to plot? EDIT: Oh, nevermind, found the typo! –  MasterApprentice Jul 9 at 17:24
    
Is there a way to include interpolation though? Or somehow remove the shading on this polygons? –  MasterApprentice Jul 9 at 22:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.