## morping matrices – ctl-matrices

Mar 27, 2009 at 7:45pm

# 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

#43062
Mar 27, 2009 at 10:00pm
 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…

#154302
Mar 27, 2009 at 11:14pm

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

#154303
Mar 28, 2009 at 2:26am

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.

#154304
Mar 28, 2009 at 2:41am

–>
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.

#154305
Mar 28, 2009 at 4:34pm

hi all,

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

#154306
Mar 29, 2009 at 12:55am

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.

– Pasted Max Patch, click to expand. –
#154307
Mar 29, 2009 at 8:19am

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

#154308

You must be logged in to reply to this topic.