0
  • I have the closed loop stored as a two column by N row numpy array.

  • The last row of the array is the same as the first row, implying that it is, indeed, a closed loop.

  • The number of angular divisions in the rotation (as in, "slices of pie" so to speak) ought be set by a variable called 'angsteps'

  • The profile in question is plotted in the x-y coordinate plane, and is rotated about the 'x-axis'.

  • You can find the profile in question plotted here. https://i.stack.imgur.com/U6bHP.png

I apologize for the lack of code, but the profile data has so many interdependencies that I can't post the code that generates it without basically taking a shortcut to plugging the github page for it.

a downsampled version of the curve data looks like this.

    bulkmat =         [[  5.2          0.        ]
     [  0.381        0.        ]
     [  0.381        3.164     ]
     [  2.           3.164     ]
     [  2.           4.1       ]
     [  3.78         4.1       ]
     [  3.78         6.477     ]
     [  1.898        6.477     ]
     [  1.898        7.        ]
     [  3.18         7.        ]
     [  3.18         9.6       ]
     [  1.898        9.6       ]
     [  1.898        9.6       ]
     [  2.31987929  12.42620027]
     [  3.4801454   15.24663923]
     [  5.22074074  17.97407407]
     [  7.38360768  20.521262  ]
     [  9.81068861  22.80096022]
     [ 12.34392593  24.72592593]
     [ 14.825262    26.20891632]
     [ 17.09663923  27.16268861]
     [ 19.          27.5       ]
     [ 19.          27.5       ]
     [ 19.62962963  27.44718793]
     [ 20.18518519  27.29972565]
     [ 20.66666667  27.07407407]
     [ 21.07407407  26.7866941 ]
     [ 21.40740741  26.45404664]
     [ 21.66666667  26.09259259]
     [ 21.85185185  25.71879287]
     [ 21.96296296  25.34910837]
     [ 22.          25.        ]
     [ 22.          25.        ]
     [ 21.12125862  24.17043472]
     [ 18.91060645  23.59946824]
     [ 15.97201646  22.9218107 ]
     [ 12.84280513  21.85346069]
     [  9.96762011  20.14089993]
     [  7.67242798  17.51028807]
     [  6.13850192  13.61665735]
     [  5.37640942   7.99310742]
     [  5.2          0.        ]]
bdazman
  • 3
  • 2
  • That's a nice task. Where is the problem? – ImportanceOfBeingErnest Nov 16 '17 at 16:05
  • The problem is that I don't know how to generate a 3d surface plot from this. I've consulted the surfaces documentation that matplotlib offers (as well as significantly more examples than that) and I haven't been able to fully understand how to condition this data and then pass it into plt.surface() – bdazman Nov 16 '17 at 16:10
  • What about [this question](https://stackoverflow.com/questions/36464982/ploting-solid-of-revolution-in-python-3-matplotlib-maybe)? – ImportanceOfBeingErnest Nov 16 '17 at 16:11
  • I've seen ones similar to that, mainly [this one](https://stackoverflow.com/questions/35592250/python-how-to-revolve-a-surface-around-z-axis-and-make-a-3d-plot?rq=1) but the problem is that I don't have a symbolic function, I have data points. How ought I go about rectifying this? – bdazman Nov 16 '17 at 16:16
  • My suggestion would be to use the information you have available to plot a solid of revolution of a function. Make this very easy (like 6 points or so). Then try to replace the function with some points. If that causes a problem, edit your question here accordingly such that people know at which point to help. – ImportanceOfBeingErnest Nov 16 '17 at 16:20
  • You've got it. Thank you. My largest hang up whilst in the midst of trying this is trying to understand how to format the 3d data properly. It appears that the square matrices created don't have their size correlate to either the number of vertices in the surface model, or the number of faces. Do you know where I can learn more about why this is? – bdazman Nov 16 '17 at 17:27
  • So did you solve the problem now? I don't know what you want to learn, but I guess you learn best by trying things out and if it fails you may always ask a question here. – ImportanceOfBeingErnest Nov 16 '17 at 19:40
  • Nah haven't cracked it yet. Still trying to aquaint myself with what exactly meshgrid does. As well as how in gods name to format input data for the surfaceplot – bdazman Nov 16 '17 at 20:59
  • I have given you an example below for 4 input points (last one is repeated to "close" the shape). I think this will allow to expand to your real input data, but at the same time keep it simple enough to understand the issue. – ImportanceOfBeingErnest Nov 16 '17 at 23:22

1 Answers1

0

The following would be an example of a solid of revolution plotted around the z axis. As input we take some points and then create the necessary 2D arrays from them.

import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as axes3d

# input xy coordinates
xy = np.array([[1,0],[2,1],[2,2],[1,1.5],[1,0]])
# radial component is x values of input
r = xy[:,0]
# angular component is one revolution of 60 steps
phi = np.linspace(0, 2*np.pi, 60)
# create grid
R,Phi = np.meshgrid(r,phi)
# transform to cartesian coordinates
X = R*np.cos(Phi)
Y = R*np.sin(Phi)
# Z values are y values, repeated 60 times
Z = np.tile(xy[:,1],len(Y)).reshape(Y.shape)


fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
ax2 = fig.add_axes([0.05,0.7,0.15,.2])
ax2.plot(xy[:,0],xy[:,1], color="k")

ax.plot_surface(X, Y, Z, alpha=0.5, color='gold', rstride=1, cstride=1)

plt.show()

enter image description here

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • You are a superhero, friend. – bdazman Nov 17 '17 at 19:36
  • Now I am attempting to figure out which pattern of your parameters governed which axis you rotated about. I am sure I will find it soon, then I'll be able to label this post as resolved. – bdazman Nov 17 '17 at 19:50