Help trying to draw lines within a circle

pagarreton's icon

I am trying to draw in real time, depending on the amplitude of a signal input an image like the one I am attaching. The idea is to make the lines more spread if the signal's amplitude is greater. It must have the same imaged mirrored in four different position (once I have one it will not be difficult)
Any help or commentary are very welcome!

Captura-de-pantalla-2015-03-03-a-las-14.45.41.png
png
pagarreton's icon

Please recommend me any object or tutorial to start with!

Andro's icon

I'd imagine you could use a jit.gl.gridshape @shape sphere. If you use the scale command then you can squash it but you wouldn't have that curve effect like in the picture. I d advise building the model in blender. Use proportional editing to get the shape you want. Load it into jit.gl.model and then use the scale command.
Bezier curves are worth checking out as well.
If you use a jit.gl.slab effect like kaleidoscope then you only have to create one quarter of the shape the rest will then be copied and mirrored.

Andro's icon
pagarreton's icon

Thanks Andro, sa-function looks great but I don't know how to plot to jitter.
I've looked deeper in the forum and I found an example with jit.path, I think it could be a good starting point, it's very good since I can easily move the handles.

Max Patch
Copy patch and select New From Clipboard in Max.

Andro's icon

Jit.path is good but you'd have to still use an array of data to move so many handles at once. Better to stay in the jitter domain. If you make 1 model in blender. A sphere and export it in two states. State A the sphere as in your picture. State B squahed on the one axis to make it a line. Use 2 jit.gl.models @ matrix_out 1. Plug them both into jit.xfade then send that to the first inlet of jit.gl.gridshape. This will allow you to crossfade between the two states.
Another way but tricker is to turn an audio signal from sin~ into a mesh with (hmmm not behind my computer) i ghink jit.catch. Theres an object which turns an audio form into a 3d mesh. By doing this you could change the shape of the lines with amplitude and offset to create a line dynamically. This could then be duplicated with an offset for each mesh.

Andro's icon

Plus changing the path with a lot of instances uses a lot of the cpu and gpu( if im correct ).

pagarreton's icon

Andro, thanks for writing. I will give a try to the different possibilities you say, since I am not a jitter expert, I will need a few days to have results. I would like to post a patch and see if someone can help in a more specific way.

Andrew Benson's icon

My recommendation would be to start by breaking this thing down into its simplest components. You have a symmetrical shape that gets repeated 4 times. So you can focus your energy on solving for just one of those shapes and duplicate them later. In fact, you only need to worry about half of that shape, since it's symmetrical. From there it's a matter of drawing a single curve that starts at the origin, goes out to the amplitude amount, and then returns to the x-axis. A good place to start might be to play with jit.mgraphics since what you are drawing looks to be vector graphics. From there it's a matter of formatting sequences of drawing messages.

pagarreton's icon

Thanks for your comment
But for moving the lines in real time I should erase and then draw the curve again?
Aren't jit.gl objects better for animation?

Andro's icon

You always need to erase a frame before drawing it.

Andro's icon

jit.gl.render. Check its help file. It has a clear example which shows the erase bang operation for redrawing a frame.

Andrew Benson's icon

If you are doing vector-style graphics of this level of complexity (not very complex), it's unlikely you are going to hit an efficiency problem with either solution. OpenGL is a more powerful engine, and might give you more room to grow, but it's not really necessary here unless you generally want to use it. I would advise against using messages directly to jit.gl.render, as this may not be supported in the future, and you have more control and extensibility using objects like jit.gl.sketch or jit.gl.mesh for drawing.

pagarreton's icon

Thanks you Andrew, I have more knowledge in the max/msp any time I try to use jitter for rendering I feel like I don't know enough mathematics to completely understand how to get everything under control. I will take a look to all the jit.gl tutorials again. The only object I could use so far has been jit.path.

Andrew Benson's icon

Here's an example of using jit.gen to create geometry that is rendered with jit.gl.mesh. I'm just using a sine curve to make the shape, but plug in some different operations in there to change the curve.

Max Patch
Copy patch and select New From Clipboard in Max.

Wetterberg's icon

aww yess. This is supremely hackable! Thanks, Andrew!

phiol's icon

+1 on what Wetterberg said. thanks a lot andrew

Been toying with it, how can I give depth to it create a more spherical shape.
I tried adding z dimensions to the jit.matrix and in the jit.gen
I duplicated the PI chain . but no luck.

thanks again

Andrew Benson's icon

In jit.gen there is also a 'sphere' operator which is meant to take a normalized (0-1) [x,y] pair (from norm) and outputs sphere plotted points to use with tri_grid. You can also use this to plot arbitrary points on a sphere. Might be fun to play around with that.

phiol's icon

Hi Andrew, thanks for the info. Would you kindly show a little demo :-)

thanks

Wetterberg's icon
Max Patch
Copy patch and select New From Clipboard in Max.

here's one I hacked a bit. It's terribly broken now, hehe. Whoops.

phiol's icon

Then Wetterberg comes along and Boom!
Very well done man ;-) !
Makes me think of when I use [jit.bfg @basis noise.simplex] and stick it to mesh.

Wetterberg's icon

Thanks muchly. Same here - jit.bfg is still my favourite jitter object of them all :)

pagarreton's icon

Thanks you very much Andrew! and very nice experiment Wetterberg! Now I have a ground for experimenting and trying to get closer to my original idea.

pagarreton's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's my inexperienced jitter solution, any comments are welcome.
It still need a lot of work...

daddymax's icon

thanks Andrew - thats a really interesting little patch - im continually confused by gen, and these clever but succinct examples are of great help.

Wetterberg's icon

Pagarreton: I think it'll be a lot more efficient to stay in jit.gl for the whole thing. You can copy and rotate the jit.gl.mesh instead of rendering to a matrix and then rotating and copying *that*.

pagarreton's icon

Oooh! It was really easier this way thanks you!

pagarreton's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Finally its done! thanks you all