## Make a Sphere of Primitives with jit.gl.multiple + jit.expr?

Nov 26 2014 | 12:15 pm
I'm crawling painfully slowly towards some kind of grasp of the 3d jitter world.
I've created 20 rows of 20 cylinders each arranged in a circle, kind of forming a cylinder of cylinders (see code below)
However what I'm hoping to achieve is a sphere of cylinders. I want to vary the number of cylinders in each row.
But matrices are rectangular.....so is this possible using jit.expr? Can I have null values?

• Nov 26 2014 | 2:19 pm
here's a patch i made a while back demonstrating some 3d tricks in jitter. the one on the right shows one way to make a sphere of spheres using gl.multiple and gl.gridshape matrixoutput:
take a look at the gen patch-a-day tutorials for some more ideas. https://cycling74.com/tutorials/gen-patch-a-day/ the day 5 patch might be interesting to you.
• Nov 26 2014 | 3:57 pm
That's great and similar to the patch @Wetterburg just showed me - great minds etc.
However I notice that each row of the sphere is actually made of the same number of individual components but the spacing is different. I guess this is determined by the properties of the sphere primitive. I'm guessing that the 'poles' of the big sphere have several instances of the mini sphere, all in the same place.
I'm looking to create a sphere where the spacing of the elements is the same for each row, but are less per row as we approach the extremities
ie: x xxxxx xxxxxxx xxxxx x
• Nov 28 2014 | 10:11 pm
I abandoned using the gl.gridshape output in the end for the reasons I attempted (and possibly failed) to explain above.
I went with a jit.expr solution, using a formula to generate the position of the shapes and then multiplying that matrix by another 'mask matrix' to change the size of the shapes I didn't want to 0, thus creating a sphere with a varying number of components in each row.
If anyone's interested, the meat of it is here: