### morping matrices – ctl-matrices

hello all,

i use jit.gl.nurbs and distort them with the ctlmatrix matrix command.

i put matrices of the dimension 5*5 in the ctlmatrix.

and i interpolate between random control-matrixes

for that i use [line] and setcell to independly interpolate the cells between random numbers.

this is (although the matrix is quite small) computationally demanding as i change all the values for the ctl-matrices with a [metro 30] all the time.

i was wonering whether there’s an efficient way to randomly morph a matrix – constantly change it’s values independly.

or is there a more efficent way to distort the nurbs in general ?

help is very much appreciated

thanks a lot

frank

jit.slide?

frank desben wrote on Fri, 27 March 2009 14:45 |

hello all, |

i use jit.gl.nurbs and distort them with the ctlmatrix matrix command.

i put matrices of the dimension 5*5 in the ctlmatrix.

and i interpolate between random control-matrixes

for that i use [line] and setcell to independly interpolate the cells between random numbers.

this is (although the matrix is quite small) computationally demanding as i change all the values for the ctl-matrices with a [metro 30] all the time.

Not sure about the optimization question, but one thought: if you use jit.spill to put your ctlmatrix into a list (like a multislider), then you can use the very powerful [pattr] to interpolate between entire sets of ctl-points, rather than the [line] and setcell for each. You won’t have the same kind of individual control, but it could make certain morphing effects much easier. Use a [preset] and set @pattrstorage of it to the pattrstorage you’re using. Then you can interpolate between stored slots/presets (here’s where [line] or [mtr] can also be very handy). Just use jit.fill after the multislider to get the list back into matrix form, to go to the jit.gl.nurbs. (pattr does not support matrices directly.)

Also for lots more cool generative ctlmatrices, look into jit.bfg if you haven’t already. This function is amazing and can save lots of work, and can generate all kinds of interesting functions with little work. Hook up a [counter] to the offset X offset Y commands (or a separate counter for each) and the matrix will "flow along" automatically through its functions.

You might also try jit.gl.mesh with these ctlmatrices as the vertex matrix, that also works great, and may be more optimized. Perhaps the jit.gl.nurbs does a lot more calculations than jit.gl.mesh, I’m not sure but I imagine so as there’s lots of interpolation required.

Possibly these ideas will slow things down even more, but they sure are cool…

if you want to interpolate two matrices i think jit.xfade is a good object to do that

It’s more efficient to do all your processing in "matrix" domain (than to transform to list and use pattr for instance). Stay with matrices, and try as far as possible to not treat individual cells nor transform them into lists.

For morphing, I like [jit.slide], although you don’t have the same control as with [jit.xfade] or something of your own with [jit.op].

Feel free to send a small patch to show what you are doing. You may get more answers.

Jean-François.

–>

It’s more efficient to do all your processing in "matrix" domain (than to transform to list and use pattr for instance). Stay with matrices, and try as far as possible to not treat individual cells nor transform them into lists.

–>

That’s good to know, I figured it would be less efficient, but thought it would be useful for pattr. After thinking about it a little, though, using a jit.matrixset and jit.xfade between two stored matrices seems like it would give similar results to interpolating between pattrstorage slots, and using a lookup table instead of a straight [line] to the xfade could simulate the interpolation types available in pattr. You could also use an integer [line] to access the lookup table, or a counter, etc.

hi all,

thank you for all you very helpful advices!

jit.slide has the problem that i can conly go from one matrix to another – if i generate random matrices and then morph between them you can actually see when the endpoint is reached and a new morph begins.

i actually use the pattr object to morph between matrices i have saved – that works very well – if i want to go directly to one matrix! but for the individual cell morphing it’s not so good.

jit.bfg is a good hint, perhaps i should do it with jit.expr – i have to think whether i can come up with a good formular that does what I try to do – but thanks for the idea to go in that direction.

i think i’ll give jit.expr a try now.

thanks again, best frank

Here is a basic pattrstorage-like interpolator for 3 matrix inputs. The big trick is normalizing the weights. I also included a subpatch that does perpixel weighted interpolations using a matrix input, but I think it’s probably overkill. There are a number of tricks similar to this in the tutorial "A Noisy Matrix" I wrote a couple of years back:

http://www.cycling74.com/story/2006/6/29/15148/4131

Let me know if that helps.

Andrew B.

**all**of the following text. Then, in Max, select

*New From Clipboard*.

----------begin_max5_patcher---------- 2017.3oc4b01bahCD9yN+JX7zOzdIMGRBA36S49czoSFrshqZw.GVtI2049u efjv1xArWiAUkqSmhCx7xtO5YWsRZW+ialLcd9KrMS89CuO4MYxOtYxDYS0M LQe9joqSdYQZxF4kMMi8b97uN8N0WIXuHjMW3UvJ+XA+EV5G4YBVYQykjscM OKkIj2NZei4aEMs5qakuT9rpd9eLvu49eJOSjkrlI+p+rjmj17MEIhEegms5 wR1BgRGng26emWre8QjOp9Cb0Ide9fG1F9+HeXH789G9jXkZ0Vq2UWMOk8cV 4Fdd1AB+joG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dfplLHxUODGNa2YCgvhFXxOQ+yEfpLzzhN kLLBqiYUfgv.wyrpLghcOY5nWWGxTjckIHiPZVNFmWlvXYdKShQ5eStZN4ZE VJTg0hDsH2qSEF4O5x5TshShHiwMFcYBCQln1EmBfJSVjOAxwUfUwIDEpL4Z CDhsKeh.UlrHNAJHFGLfAyZ6wMFaAYW+SHDTYpu8cUm7u27e.GaoOA. -----------end_max5_patcher-----------

hi andrew,

thanks for the tip

unfortunately i get an error message when i paste to max – does it work for you (to copy the code below)?

thanks

frank

andrew’s code works fine. are you on max 5?

Forums > Jitter