mercredi 6 juillet 2016

Create Numpy Array Representing a Geometric Shape

As the title suggests, how would one create a numpy array of 3D coordinates of a geometric shape?

Currently, I have the easiest shape already figured out:

latva = 6
latvb = 6
latvc = 6
latdiv = 20
lol = np.zeros((latdiv**3,4),dtype=np.float64)
lol[:,:3] = (np.arange(latdiv**3)[:,None]//(latdiv**2,latdiv,1)*(latvadiv,latvbdiv,latvcdiv)%(latva,latvb,latvc))

creates an array of (8000,4). If you then split the array along the 1,2,3 column (Ignoring the 4th as it's meaningless in this question) and plot it (Personally, I use pyplot) you get a Cube!

Easy enough. Also works for a rectangle.

But I've not the foggiest idea of how to get any further - say plotting a rhombus.

I'm not interested in black magic like spheres, ovals or shapes whose sides do not change following a line. Just things like your standard rhombus/Rhomboid/Parallelepiped/Whatever_you_want_to_call_it.

Any ideas on how to accomplish this?

Aucun commentaire:

Enregistrer un commentaire