Forums > Jitter

to shift a 3d matrix?

February 5, 2010 | 1:47 am

Hi.
I’ve got a 3 dimensional, 9 plane matrix.

I’d like to be able to shift the matrix along any of its dimensions and have the excess wrap back around at the ohter side -similar to how jit.rota works with @boundmode 2 on a 2d matrix. Is there a simple and fast way to do this considering the matrix could be quite large or should I be copying chunks from one matrix to another setting srcdim and dstdim etc.?

Sorry if i’ve missed something obvious and hope i’ve made myself clear. Any pointers would really be appreciated.


February 5, 2010 | 8:20 pm

why not just use jit.rota itself? it works with all matrices…


February 6, 2010 | 1:39 am

Thanks for the reply Joshua, maybe i didn’t word my question too well but i’d like to shift this matrix along any of its dimensions – x, y and z. jit.rota doesn’t do the shift on the z axis (i think?). Any more ideas?


February 6, 2010 | 4:25 am

do you want to shift entire planes or specific cells? i would think a jit.unpack – switch – jit.pack structure would work if you want to do entire planes.


February 6, 2010 | 6:43 am

oh yeah, have you tried sending planemap messages to the matrix? im not sure how fast your wanting to do that but it works fast for me


February 6, 2010 | 7:42 pm

Thanks piwolf, but i don’t want to reorder the planes – i’d like to be able to shift the contents of all cells by a specified amount along the x, y or z axis. and have the excess wrap back around to the other end. I don’t know how else to describe this except to say, like jit.bounds but with a @offset_z..


February 7, 2010 | 2:42 am

try this mate. a zl rot to planemap message for z and jit.rota for x and y, let me know if it works. doing a 3d led matrix? ala James Clarr?

– Pasted Max Patch, click to expand. –

February 7, 2010 | 11:08 pm

Many thanks for the patch piwolf but it doesn’t do quite what i need because it’s still a 2d matrix:) i use the 3d matrix as large data structure -here i see it as a cube with each cell holding 9 values. Each data item i add has a position in the cube ie. a matrix cell, and 9 further properties associated with it.

matrix might be: [jit.matrix 9 float32 100 100 100]

then send the messgae: setcell 0 0 0 val 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

so a shift of -1 along the third dimension should place the values 0.1 0.2 0.3 etc. in cell 0 0 99.

the patch below does this. as in your patch I use jit.rota for the x and y shift, but then copy 2 chunks from one matrix to another to do the z shift. i’d just hoped there could be a better way -if there is i’d still like to hear about it..

– Pasted Max Patch, click to expand. –

February 8, 2010 | 5:46 pm

i understand the difference in what your trying to do now from what I was interpreting. I am curious what you are filling the nine planes with. I would think of a 3d array as a 2 d matrix with the planecount being the resolution of the z axis. so a 3d matrix with dims of x100 y100 z100 would be a jit.matrix with 100 planes and dims of x100 y100. you are dealing with 4 dimensions if you are trying to put a 3d matrix as one plane. Now that I read your first post, you were very clear and I was just thinking shift 3d. When thinking of shifting a 3d set inside of another 3d set, i think of gl and objects in render context so maybe there is a slick way to do what your trying with the gl objects but i dont know it. It seems to me that your taking your 3d matrix and dealing with it 9 times as opposed to once. Sorry i dont have a better solution for your puzzle. What type of dataset are you moving? Generative stuff like fractals or some statistical gatherings?


February 8, 2010 | 10:08 pm

i can’t really think of a better method than the one you’ve already devised using srcdim/dstdim attributes.


February 9, 2010 | 12:01 am

Another solution for this problem with existing objects would be 3 instances of jit.split->jit.concat.


February 9, 2010 | 7:24 pm

Piwolf
ah, i hadn’t thought about using a 2d matrix with the number of planes as the 3rd dimension. In this case though, i’d need more planes than we’re allowed. i’m working on vision based gesture recognition with the matrix holding input events -the 9 planes are for event data, like time and velocity.. at the minute im just researching what jitter will allow me to do.

Joshua
thanks for the advice. i now use jit.split and concat instead – the patch is a lot easier to understand.

thanks everyone!
.

result:

– Pasted Max Patch, click to expand. –

Viewing 12 posts - 1 through 12 (of 12 total)