constrain matrix to boundaries

Oct 15, 2007 at 5:51pm

constrain matrix to boundaries

hi, i have a “shatter”-based particle system which i would like to constrain
to a maximum radius (circle).
did anyone had success with boundary clipping of a matrix?
i *think* what i need is jit.clip with a second input for matrix. i tried
using jit.op (

each particle from center and constrain it if it is longer the allowed.

here is a patch

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 338 201 18 9109513 < <;
#N vpatcher 15 55 615 455;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 50 95 93 9109513 jit.op @op * @val 2.;
#P objectname jit.matrix[2];
#P newex 50 72 97 9109513 jit.op @op – @val 0.5;
#P objectname jit.matrix[1];
#P newex 50 50 101 9109513 jit.noise 3 float32 10 8;
#P objectname jit.matrix[6];
#P inlet 50 30 15 0;
#P outlet 50 119 15 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P lcolor 1;
#P connect 3 0 4 0;
#P lcolor 1;
#P connect 4 0 0 0;
#P pop;
#P newobj 255 201 82 9109513 p noisy_placment;
#N vpatcher 15 55 615 455;
#P window setfont “Sans Serif” 9.;
#P newex 50 251 32 9109513 jit.clip;
#P comment 244 222 18 9109513 ??;
#P newex 50 219 191 9109513 jit.expr @expr “hypot(snorm[0] \, snorm[1])”;
#P window linecount 2;
#P comment 180 155 227 9109513 and even if there was , this matrix wont
help as every particle will only be checked against one point;
#P window linecount 1;
#P newex 52 99 105 9109513 jit.matrix 3 float32 10 8;
#P newex 166 91 105 9109513 jit.matrix 3 float32 80 1;
#P newex 166 114 118 9109513 jit.scanwrap 3 float32 10 8;
#P newex 52 138 124 9109513 jit.op @op clip;
#P button 166 50 15 0;
#P newex 166 70 314 9109513 jit.gl.gridshape @shape circle @dim 80 1
@matrixoutput 1 @automatic 1;
#P comment 185 52 271 9109513 get outer ring and warp to fill all matrix;
#P comment 180 139 100 9109513 but there isnt one…;
#P connect 7 0 4 0;
#P connect 3 0 2 0;
#P connect 2 0 6 0;
#P connect 6 0 5 0;
#P connect 5 0 4 1;
#P pop;
#P newobj 355 201 54 9109513 p constrain;
#P newex 255 139 33 9109513 r draw;
#P newex 255 159 68 9109513 speedlim 1000;
#P objectname jit.matrix[5];
#P button 144 36 15 0;
#P newex 255 224 16 9109513 t l;
#P objectname jit.matrix[3];
#N vpatcher 421 64 850 484;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 137 257 191 9109513 < here we force every quad to face ceneter;
#P button 72 52 15 0;
#P newex 128 286 87 9109513 jit.matrix _distance;
#B color 4;
#P objectname jit.matrix[1];
#P newex 50 71 27 9109513 b 2;
#P newex 50 50 21 9109513 r l0;
#P newex 50 159 195 9109513 jit.op @op * * * pass pass @val 0.15 0.15 0.;
#B color 6;
#P objectname jit.op[2];
#P newex 285 190 86 9109513 jit.matrix feedback;
#B color 4;
#P objectname jit.matrix[4];
#N vpatcher 370 221 746 385;
#P origin 0 -10;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 285 29 69 9109513 loadmess 1.57;
#P objectname jit.expr[1];
#P flonum 249 32 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 0;
#P newex 16 49 249 9109513 jit.expr @expr “in[0].p[0]*cos(PI/2.) -
in[0].p[1]*sin(PI/2.)” “in[0].p[1]*cos(PI/2.) + in[0].p[0]*sin(PI/2.)” in[0]
in[0] in[0];
#P objectname jit.expr;
#P inlet 16 31 15 0;
#P outlet 16 121 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P connect 4 0 3 0;
#P connect 3 0 2 1;
#P pop;
#P newobj 50 205 102 9109513 p matrix2rotationZZZZ;
#B color 5;
#P newex 118 231 212 9109513 jit.expr @expr 0. 0. “atan2(in[0].p[1] \,
in[0].p[0])”;
#P newex 285 158 33 9109513 r draw;
#P objectname receive[3];
#N vpatcher 370 221 928 467;
#P origin 0 -10;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 11 83 467 9109513 jit.expr @expr in[0]
“in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])”
“in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])” in[0] in[0];
#P objectname jit.expr[2];
#P window linecount 0;
#P newex 469 56 56 9109513 jit.unpack 3;
#P objectname jit.unpack;
#P newex 11 120 469 9109513 jit.expr @expr
“in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])” in[0]
“in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])” in[0] in[0];
#P objectname jit.expr[1];
#P newex 11 159 480 9109513 jit.expr @expr “in[0].p[0]*cos(in[1]) -
in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])” in[0]
in[0] in[0];
#P objectname jit.expr;
#P inlet 11 63 15 0;
#P inlet 467 32 15 0;
#P outlet 11 181 15 0;
#P connect 2 0 6 0;
#P connect 6 0 4 0;
#P connect 4 0 3 0;
#P connect 3 0 0 0;
#P connect 5 0 6 1;
#P connect 1 0 5 0;
#P fasten 5 1 4 1 489 119 475 119;
#P fasten 5 2 3 1 504 150 486 150;
#P pop;
#P newobj 50 254 78 9109513 p matrix2rotation;
#B color 5;
#P newex 50 183 44 9109513 jit.matrix;
#P objectname receive[2];
#N vpatcher 25 70 595 342;
#P origin 0 -10;
#P button 75 28 15 0;
#P window setfont “Sans Serif” 9.;
#P flonum 152 129 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 0;
#P newex 50 129 98 9109513 jit.op @op * @val 0.9;
#P objectname jit.op[4];
#P newex 50 108 58 9109513 jit.op @op +;
#P objectname jit.op[3];
#P window setfont “Sans Serif” 14.;
#P window linecount 2;
#P newex 98 73 392 9109518 jit.expr @expr “(cell[0]%4.>0.)*(cell[0]%4.<3.)"
“(cell[0]%4>1)” “0.” “(cell[0]%4.>0.)*(cell[0]%4.<3.)*0.1" "(cell[0]%4>1)*
0.1″;
#P objectname jit.expr[1];
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 50 50 110 9109513 jit.matrix 5 float32 40 10;
#B color 4;
#P objectname jit.matrix[1];
#P inlet 50 30 15 0;
#P outlet 50 153 15 0;
#P comment 191 131 100 9109513 why?!;
#P connect 2 0 3 0;
#P connect 8 0 3 0;
#P connect 3 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 1 0;
#P connect 7 0 8 0;
#P fasten 3 0 4 0 55 71 103 71;
#P connect 4 0 5 1;
#P connect 7 0 6 1;
#P pop;
#P newobj 50 137 61 9109513 p quadMaker;
#P newex 50 115 203 9109513 jit.expr @expr “-0.5″ “-0.5″ “0.” norm[0]
norm[1];
#P objectname jit.expr[2];
#P newex 50 94 105 9109513 jit.matrix 5 float32 10 8;
#P objectname jit.matrix[3];
#P outlet 50 312 15 0;
#P window linecount 2;
#P comment 218 287 100 9109513 < use the distance to clip motion to circle;
#P connect 15 0 13 0;
#P connect 12 0 13 0;
#P connect 13 0 2 0;
#P connect 13 1 2 0;
#P connect 2 0 3 0;
#P connect 3 0 4 0;
#P connect 4 0 11 0;
#P fasten 7 0 5 0 290 180 55 180;
#P connect 11 0 5 0;
#P connect 5 0 9 0;
#P connect 9 0 6 0;
#P connect 6 0 1 0;
#P fasten 10 0 8 0 290 226 123 226;
#P fasten 8 0 6 1 123 251 123 251;
#P fasten 8 0 14 0 123 252 133 252;
#P fasten 7 0 10 0 290 183 290 183;
#P pop;
#P newobj 145 232 73 9109513 p quad_Prepere;
#P newex 159 86 23 9109513 s l2;
#P number 72 30 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname number;
#P newex 24 27 21 9109513 r l2;
#P objectname receive;
#P newex 183 86 23 9109513 s l0;
#P newex 159 62 34 9109513 t b b;
#P window setfont “Sans Serif” 14.;
#P newex 159 34 67 9109518 loadbang;
#B color 5;
#P window setfont “Sans Serif” 9.;
#N vpatcher 530 245 771 446;
#P origin 64 -4;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 51 84 40 9109513 sel 0 1;
#P message 51 128 152 9109513 border 1 , size 320 240 , pos 10 463;
#P message 66 107 160 9109513 border 0 , size 1024 778 , , pos 1024 0;
#P toggle 51 66 15 0;
#P window linecount 0;
#P newex 50 44 35 9109513 sel 27;
#P newex 50 21 40 9109513 key;
#P outlet 56 154 15 0;
#P fasten 1 0 2 0 55 42 55 42;
#P connect 2 0 3 0;
#P connect 3 0 6 0;
#P fasten 6 0 5 0 56 106 56 106;
#P connect 4 0 0 0;
#P connect 5 0 0 0;
#P connect 6 1 4 0;
#P pop;
#P newobj 9 142 25 9109513 p fs;
#P window linecount 2;
#P newex 9 164 131 9109513 jit.window rott @size 320 240 @floating 1 @pos 10
450;
#P objectname jit.window;
#P newex 48 127 141 9109513 jit.gl.render rott @camera 0 0 3 @erase_color 0.
0. 0. 1.;
#P objectname jit.gl.render;
#P toggle 48 27 20 0;
#P objectname toggle;
#P window linecount 1;
#P newex 48 53 50 9109513 qmetro 20;
#P newex 72 106 35 9109513 s draw;
#P newex 48 75 58 9109513 t b b erase;
#P window linecount 2;
#P newex 145 293 234 9109513 jit.gl.mesh rott @draw_mode quads @color 1. 1.
1. 1. @blend_enable 1 @depth_enable 0 @texture numbers;
#P objectname jit.gl.mesh;
#P window linecount 1;
#P comment 229 40 28 9109513 bang;
#P button 255 182 15 0;
#P newex 266 257 86 9109513 jit.matrix feedback;
#P objectname jit.matrix[4];
#P newex 145 257 120 9109513 jit.op @op + + + pass pass;
#P objectname jit.op[2];
#P window linecount 2;
#P comment 415 202 83 9109513 how do i constrain position to circle?;
#P window linecount 1;
#P comment 357 258 137 9109513 look in quad_prepere for usage;
#P connect 21 0 2 1;
#P lcolor 1;
#P fasten 21 0 3 0 260 250 271 250;
#P lcolor 1;
#P connect 4 0 26 0;
#P connect 26 0 21 0;
#P connect 13 0 12 0;
#P connect 17 0 10 0;
#P connect 10 0 9 0;
#P fasten 9 0 7 0 53 83 53 83;
#P fasten 7 2 11 0 101 102 53 102;
#P connect 7 0 11 0;
#P connect 7 1 8 0;
#P fasten 18 0 9 1 77 49 93 49;
#P connect 22 0 14 0;
#P connect 14 0 15 0;
#P connect 15 0 19 0;
#P connect 15 1 16 0;
#P connect 20 0 2 0;
#P lcolor 1;
#P connect 2 0 6 0;
#P lcolor 1;
#P connect 24 0 23 0;
#P lcolor 1;
#P connect 23 0 4 0;
#P lcolor 1;
#P window clipboard copycount 28;

#34181
Oct 15, 2007 at 6:05pm

you should be able to use a “lumakey” mixer (I think, If I
understand) with a white circular mask and black border. This would
set values to 0 where the mask is black, and pass through anything in
the white?

On Oct 15, 2007, at 1:51 PM, yair reshef wrote:

> hi, i have a “shatter”-based particle system which i would like to
> constrain to a maximum radius (circle).
> did anyone had success with boundary clipping of a matrix?
> i *think* what i need is jit.clip with a second input for matrix. i
> tried using jit.op (

> the distance of each particle from center and constrain it if it is
> longer the allowed.
>
> here is a patch
>
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 338 201 18 9109513 < <;
> #N vpatcher 15 55 615 455;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 50 95 93 9109513 jit.op @op * @val 2.;
> #P objectname jit.matrix[2];
> #P newex 50 72 97 9109513 jit.op @op – @val 0.5;
> #P objectname jit.matrix[1];
> #P newex 50 50 101 9109513 jit.noise 3 float32 10 8;
> #P objectname jit.matrix[6];
> #P inlet 50 30 15 0;
> #P outlet 50 119 15 0;
> #P connect 1 0 2 0;
> #P connect 2 0 3 0;
> #P lcolor 1;
> #P connect 3 0 4 0;
> #P lcolor 1;
> #P connect 4 0 0 0;
> #P pop;
> #P newobj 255 201 82 9109513 p noisy_placment;
> #N vpatcher 15 55 615 455;
> #P window setfont “Sans Serif” 9.;
> #P newex 50 251 32 9109513 jit.clip;
> #P comment 244 222 18 9109513 ??;
> #P newex 50 219 191 9109513 jit.expr @expr “hypot(snorm[0] \,
> snorm[1])”;
> #P window linecount 2;
> #P comment 180 155 227 9109513 and even if there was , this matrix
> wont help as every particle will only be checked against one point;
> #P window linecount 1;
> #P newex 52 99 105 9109513 jit.matrix 3 float32 10 8;
> #P newex 166 91 105 9109513 jit.matrix 3 float32 80 1;
> #P newex 166 114 118 9109513 jit.scanwrap 3 float32 10 8;
> #P newex 52 138 124 9109513 jit.op @op clip;
> #P button 166 50 15 0;
> #P newex 166 70 314 9109513 jit.gl.gridshape @shape circle @dim 80
> 1 @matrixoutput 1 @automatic 1;
> #P comment 185 52 271 9109513 get outer ring and warp to fill all
> matrix;
> #P comment 180 139 100 9109513 but there isnt one…;
> #P connect 7 0 4 0;
> #P connect 3 0 2 0;
> #P connect 2 0 6 0;
> #P connect 6 0 5 0;
> #P connect 5 0 4 1;
> #P pop;
> #P newobj 355 201 54 9109513 p constrain;
> #P newex 255 139 33 9109513 r draw;
> #P newex 255 159 68 9109513 speedlim 1000;
> #P objectname jit.matrix[5];
> #P button 144 36 15 0;
> #P newex 255 224 16 9109513 t l;
> #P objectname jit.matrix[3];
> #N vpatcher 421 64 850 484;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 137 257 191 9109513 < here we force every quad to face
> ceneter;
> #P button 72 52 15 0;
> #P newex 128 286 87 9109513 jit.matrix _distance;
> #B color 4;
> #P objectname jit.matrix[1];
> #P newex 50 71 27 9109513 b 2;
> #P newex 50 50 21 9109513 r l0;
> #P newex 50 159 195 9109513 jit.op @op * * * pass pass @val 0.15
> 0.15 0.;
> #B color 6;
> #P objectname jit.op[2];
> #P newex 285 190 86 9109513 jit.matrix feedback;
> #B color 4;
> #P objectname jit.matrix[4];
> #N vpatcher 370 221 746 385;
> #P origin 0 -10;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 285 29 69 9109513 loadmess 1.57;
> #P objectname jit.expr[1];
> #P flonum 249 32 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 0;
> #P newex 16 49 249 9109513 jit.expr @expr “in[0].p[0]*cos(PI/2.) –
> in[0].p[1]*sin(PI/2.)” “in[0].p[1]*cos(PI/2.) + in[0].p[0]*sin(PI/
> 2.)” in[0] in[0] in[0];
> #P objectname jit.expr;
> #P inlet 16 31 15 0;
> #P outlet 16 121 15 0;
> #P connect 1 0 2 0;
> #P connect 2 0 0 0;
> #P connect 4 0 3 0;
> #P connect 3 0 2 1;
> #P pop;
> #P newobj 50 205 102 9109513 p matrix2rotationZZZZ;
> #B color 5;
> #P newex 118 231 212 9109513 jit.expr @expr 0. 0. “atan2(in[0].p[1]
> \, in[0].p[0])”;
> #P newex 285 158 33 9109513 r draw;
> #P objectname receive[3];
> #N vpatcher 370 221 928 467;
> #P origin 0 -10;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 11 83 467 9109513 jit.expr @expr in[0] “in[0].p[1]*cos(in
> [1])-in[0].p[2]*sin(in[1])” “in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in
> [1])” in[0] in[0];
> #P objectname jit.expr[2];
> #P window linecount 0;
> #P newex 469 56 56 9109513 jit.unpack 3;
> #P objectname jit.unpack;
> #P newex 11 120 469 9109513 jit.expr @expr “in[0].p[0]*cos(in[1])+in
> [0].p[2]*sin(in[1])” in[0] “in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in
> [1])” in[0] in[0];
> #P objectname jit.expr[1];
> #P newex 11 159 480 9109513 jit.expr @expr “in[0].p[0]*cos(in[1]) –
> in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in
> [1])” in[0] in[0] in[0];
> #P objectname jit.expr;
> #P inlet 11 63 15 0;
> #P inlet 467 32 15 0;
> #P outlet 11 181 15 0;
> #P connect 2 0 6 0;
> #P connect 6 0 4 0;
> #P connect 4 0 3 0;
> #P connect 3 0 0 0;
> #P connect 5 0 6 1;
> #P connect 1 0 5 0;
> #P fasten 5 1 4 1 489 119 475 119;
> #P fasten 5 2 3 1 504 150 486 150;
> #P pop;
> #P newobj 50 254 78 9109513 p matrix2rotation;
> #B color 5;
> #P newex 50 183 44 9109513 jit.matrix;
> #P objectname receive[2];
> #N vpatcher 25 70 595 342;
> #P origin 0 -10;
> #P button 75 28 15 0;
> #P window setfont “Sans Serif” 9.;
> #P flonum 152 129 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 0;
> #P newex 50 129 98 9109513 jit.op @op * @val 0.9;
> #P objectname jit.op[4];
> #P newex 50 108 58 9109513 jit.op @op +;
> #P objectname jit.op[3];
> #P window setfont “Sans Serif” 14.;
> #P window linecount 2;
> #P newex 98 73 392 9109518 jit.expr @expr “(cell[0]%4.>0.)*(cell[0]%
> 4.<3.)" "(cell[0]%4>1)” “0.” “(cell[0]%4.>0.)*(cell[0]%4.<3.)*0.1"
> “(cell[0]%4>1)*0.1″;
> #P objectname jit.expr[1];
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 50 50 110 9109513 jit.matrix 5 float32 40 10;
> #B color 4;
> #P objectname jit.matrix[1];
> #P inlet 50 30 15 0;
> #P outlet 50 153 15 0;
> #P comment 191 131 100 9109513 why?!;
> #P connect 2 0 3 0;
> #P connect 8 0 3 0;
> #P connect 3 0 5 0;
> #P connect 5 0 6 0;
> #P connect 6 0 1 0;
> #P connect 7 0 8 0;
> #P fasten 3 0 4 0 55 71 103 71;
> #P connect 4 0 5 1;
> #P connect 7 0 6 1;
> #P pop;
> #P newobj 50 137 61 9109513 p quadMaker;
> #P newex 50 115 203 9109513 jit.expr @expr “-0.5″ “-0.5″ “0.” norm
> [0] norm[1];
> #P objectname jit.expr[2];
> #P newex 50 94 105 9109513 jit.matrix 5 float32 10 8;
> #P objectname jit.matrix[3];
> #P outlet 50 312 15 0;
> #P window linecount 2;
> #P comment 218 287 100 9109513 < use the distance to clip motion to
> circle;
> #P connect 15 0 13 0;
> #P connect 12 0 13 0;
> #P connect 13 0 2 0;
> #P connect 13 1 2 0;
> #P connect 2 0 3 0;
> #P connect 3 0 4 0;
> #P connect 4 0 11 0;
> #P fasten 7 0 5 0 290 180 55 180;
> #P connect 11 0 5 0;
> #P connect 5 0 9 0;
> #P connect 9 0 6 0;
> #P connect 6 0 1 0;
> #P fasten 10 0 8 0 290 226 123 226;
> #P fasten 8 0 6 1 123 251 123 251;
> #P fasten 8 0 14 0 123 252 133 252;
> #P fasten 7 0 10 0 290 183 290 183;
> #P pop;
> #P newobj 145 232 73 9109513 p quad_Prepere;
> #P newex 159 86 23 9109513 s l2;
> #P number 72 30 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P objectname number;
> #P newex 24 27 21 9109513 r l2;
> #P objectname receive;
> #P newex 183 86 23 9109513 s l0;
> #P newex 159 62 34 9109513 t b b;
> #P window setfont “Sans Serif” 14.;
> #P newex 159 34 67 9109518 loadbang;
> #B color 5;
> #P window setfont “Sans Serif” 9.;
> #N vpatcher 530 245 771 446;
> #P origin 64 -4;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 51 84 40 9109513 sel 0 1;
> #P message 51 128 152 9109513 border 1 , size 320 240 , pos 10 463;
> #P message 66 107 160 9109513 border 0 , size 1024 778 , , pos
> 1024 0;
> #P toggle 51 66 15 0;
> #P window linecount 0;
> #P newex 50 44 35 9109513 sel 27;
> #P newex 50 21 40 9109513 key;
> #P outlet 56 154 15 0;
> #P fasten 1 0 2 0 55 42 55 42;
> #P connect 2 0 3 0;
> #P connect 3 0 6 0;
> #P fasten 6 0 5 0 56 106 56 106;
> #P connect 4 0 0 0;
> #P connect 5 0 0 0;
> #P connect 6 1 4 0;
> #P pop;
> #P newobj 9 142 25 9109513 p fs;
> #P window linecount 2;
> #P newex 9 164 131 9109513 jit.window rott @size 320 240 @floating
> 1 @pos 10 450;
> #P objectname jit.window;
> #P newex 48 127 141 9109513 jit.gl.render rott @camera 0 0 3
> @erase_color 0. 0. 0. 1.;
> #P objectname jit.gl.render;
> #P toggle 48 27 20 0;
> #P objectname toggle;
> #P window linecount 1;
> #P newex 48 53 50 9109513 qmetro 20;
> #P newex 72 106 35 9109513 s draw;
> #P newex 48 75 58 9109513 t b b erase;
> #P window linecount 2;
> #P newex 145 293 234 9109513 jit.gl.mesh rott @draw_mode quads
> @color 1. 1. 1. 1. @blend_enable 1 @depth_enable 0 @texture numbers;
> #P objectname jit.gl.mesh;
> #P window linecount 1;
> #P comment 229 40 28 9109513 bang;
> #P button 255 182 15 0;
> #P newex 266 257 86 9109513 jit.matrix feedback;
> #P objectname jit.matrix[4];
> #P newex 145 257 120 9109513 jit.op @op + + + pass pass;
> #P objectname jit.op[2];
> #P window linecount 2;
> #P comment 415 202 83 9109513 how do i constrain position to circle?;
> #P window linecount 1;
> #P comment 357 258 137 9109513 look in quad_prepere for usage;
> #P connect 21 0 2 1;
> #P lcolor 1;
> #P fasten 21 0 3 0 260 250 271 250;
> #P lcolor 1;
> #P connect 4 0 26 0;
> #P connect 26 0 21 0;
> #P connect 13 0 12 0;
> #P connect 17 0 10 0;
> #P connect 10 0 9 0;
> #P fasten 9 0 7 0 53 83 53 83;
> #P fasten 7 2 11 0 101 102 53 102;
> #P connect 7 0 11 0;
> #P connect 7 1 8 0;
> #P fasten 18 0 9 1 77 49 93 49;
> #P connect 22 0 14 0;
> #P connect 14 0 15 0;
> #P connect 15 0 19 0;
> #P connect 15 1 16 0;
> #P connect 20 0 2 0;
> #P lcolor 1;
> #P connect 2 0 6 0;
> #P lcolor 1;
> #P connect 24 0 23 0;
> #P lcolor 1;
> #P connect 23 0 4 0;
> #P lcolor 1;
> #P window clipboard copycount 28;
>

v a d e //

http://www.vade.info
abstrakt.vade.info

#114949
Oct 15, 2007 at 6:31pm

no thats not it.
mybe i didnt explained enough?

On 10/15/07, vade wrote:
>
> you should be able to use a “lumakey” mixer (I think, If I understand)
> with a white circular mask and black border. This would set values to 0
> where the mask is black, and pass through anything in the white?
> On Oct 15, 2007, at 1:51 PM, yair reshef wrote:
>
> hi, i have a “shatter”-based particle system which i would like to
> constrain to a maximum radius (circle).
> did anyone had success with boundary clipping of a matrix?
> i *think* what i need is jit.clip with a second input for matrix. i tried
> using jit.op (

> of each particle from center and constrain it if it is longer the allowed.
>
> here is a patch
>
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 338 201 18 9109513 < <;
> #N vpatcher 15 55 615 455;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 50 95 93 9109513 jit.op @op * @val 2.;
> #P objectname jit.matrix[2];
> #P newex 50 72 97 9109513 jit.op @op – @val 0.5;
> #P objectname jit.matrix[1];
> #P newex 50 50 101 9109513 jit.noise 3 float32 10 8;
> #P objectname jit.matrix[6];
> #P inlet 50 30 15 0;
> #P outlet 50 119 15 0;
> #P connect 1 0 2 0;
> #P connect 2 0 3 0;
> #P lcolor 1;
> #P connect 3 0 4 0;
> #P lcolor 1;
> #P connect 4 0 0 0;
> #P pop;
> #P newobj 255 201 82 9109513 p noisy_placment;
> #N vpatcher 15 55 615 455;
> #P window setfont “Sans Serif” 9.;
> #P newex 50 251 32 9109513 jit.clip;
> #P comment 244 222 18 9109513 ??;
> #P newex 50 219 191 9109513 jit.expr @expr “hypot(snorm[0] \,
> snorm[1])”;
> #P window linecount 2;
> #P comment 180 155 227 9109513 and even if there was , this matrix wont
> help as every particle will only be checked against one point;
> #P window linecount 1;
> #P newex 52 99 105 9109513 jit.matrix 3 float32 10 8;
> #P newex 166 91 105 9109513 jit.matrix 3 float32 80 1;
> #P newex 166 114 118 9109513 jit.scanwrap 3 float32 10 8;
> #P newex 52 138 124 9109513 jit.op @op clip;
> #P button 166 50 15 0;
> #P newex 166 70 314 9109513 jit.gl.gridshape @shape circle @dim 80 1
> @matrixoutput 1 @automatic 1;
> #P comment 185 52 271 9109513 get outer ring and warp to fill all matrix;
> #P comment 180 139 100 9109513 but there isnt one…;
> #P connect 7 0 4 0;
> #P connect 3 0 2 0;
> #P connect 2 0 6 0;
> #P connect 6 0 5 0;
> #P connect 5 0 4 1;
> #P pop;
> #P newobj 355 201 54 9109513 p constrain;
> #P newex 255 139 33 9109513 r draw;
> #P newex 255 159 68 9109513 speedlim 1000;
> #P objectname jit.matrix[5];
> #P button 144 36 15 0;
> #P newex 255 224 16 9109513 t l;
> #P objectname jit.matrix[3];
> #N vpatcher 421 64 850 484;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 137 257 191 9109513 < here we force every quad to face ceneter;
> #P button 72 52 15 0;
> #P newex 128 286 87 9109513 jit.matrix _distance;
> #B color 4;
> #P objectname jit.matrix[1];
> #P newex 50 71 27 9109513 b 2;
> #P newex 50 50 21 9109513 r l0;
> #P newex 50 159 195 9109513 jit.op @op * * * pass pass @val 0.15 0.15 0.;
> #B color 6;
> #P objectname jit.op[2];
> #P newex 285 190 86 9109513 jit.matrix feedback;
> #B color 4;
> #P objectname jit.matrix[4];
> #N vpatcher 370 221 746 385;
> #P origin 0 -10;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 285 29 69 9109513 loadmess 1.57;
> #P objectname jit.expr[1];
> #P flonum 249 32 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 0;
> #P newex 16 49 249 9109513 jit.expr @expr “in[0].p[0]*cos(PI/2.) -
> in[0].p[1]*sin(PI/2.)” “in[0].p[1]*cos(PI/2.) + in[0].p[0]*sin(PI/2.)” in[0]
> in[0] in[0];
> #P objectname jit.expr;
> #P inlet 16 31 15 0;
> #P outlet 16 121 15 0;
> #P connect 1 0 2 0;
> #P connect 2 0 0 0;
> #P connect 4 0 3 0;
> #P connect 3 0 2 1;
> #P pop;
> #P newobj 50 205 102 9109513 p matrix2rotationZZZZ;
> #B color 5;
> #P newex 118 231 212 9109513 jit.expr @expr 0. 0. “atan2(in[0].p[1] \,
> in[0].p[0])”;
> #P newex 285 158 33 9109513 r draw;
> #P objectname receive[3];
> #N vpatcher 370 221 928 467;
> #P origin 0 -10;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 11 83 467 9109513 jit.expr @expr in[0]
> “in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])”
> “in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])” in[0] in[0];
> #P objectname jit.expr[2];
> #P window linecount 0;
> #P newex 469 56 56 9109513 jit.unpack 3;
> #P objectname jit.unpack;
> #P newex 11 120 469 9109513 jit.expr @expr
> “in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])” in[0]
> “in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])” in[0] in[0];
> #P objectname jit.expr[1];
> #P newex 11 159 480 9109513 jit.expr @expr “in[0].p[0]*cos(in[1]) -
> in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])” in[0]
> in[0] in[0];
> #P objectname jit.expr;
> #P inlet 11 63 15 0;
> #P inlet 467 32 15 0;
> #P outlet 11 181 15 0;
> #P connect 2 0 6 0;
> #P connect 6 0 4 0;
> #P connect 4 0 3 0;
> #P connect 3 0 0 0;
> #P connect 5 0 6 1;
> #P connect 1 0 5 0;
> #P fasten 5 1 4 1 489 119 475 119;
> #P fasten 5 2 3 1 504 150 486 150;
> #P pop;
> #P newobj 50 254 78 9109513 p matrix2rotation;
> #B color 5;
> #P newex 50 183 44 9109513 jit.matrix;
> #P objectname receive[2];
> #N vpatcher 25 70 595 342;
> #P origin 0 -10;
> #P button 75 28 15 0;
> #P window setfont “Sans Serif” 9.;
> #P flonum 152 129 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 0;
> #P newex 50 129 98 9109513 jit.op @op * @val 0.9;
> #P objectname jit.op[4];
> #P newex 50 108 58 9109513 jit.op @op +;
> #P objectname jit.op[3];
> #P window setfont “Sans Serif” 14.;
> #P window linecount 2;
> #P newex 98 73 392 9109518 jit.expr @expr
> “(cell[0]%4.>0.)*(cell[0]%4.<3.)" "(cell[0]%4>1)” “0.”
> “(cell[0]%4.>0.)*(cell[0]%4.<3.)*0.1" "(cell[0]%4>1)*0.1″;
> #P objectname jit.expr[1];
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 50 50 110 9109513 jit.matrix 5 float32 40 10;
> #B color 4;
> #P objectname jit.matrix[1];
> #P inlet 50 30 15 0;
> #P outlet 50 153 15 0;
> #P comment 191 131 100 9109513 why?!;
> #P connect 2 0 3 0;
> #P connect 8 0 3 0;
> #P connect 3 0 5 0;
> #P connect 5 0 6 0;
> #P connect 6 0 1 0;
> #P connect 7 0 8 0;
> #P fasten 3 0 4 0 55 71 103 71;
> #P connect 4 0 5 1;
> #P connect 7 0 6 1;
> #P pop;
> #P newobj 50 137 61 9109513 p quadMaker;
> #P newex 50 115 203 9109513 jit.expr @expr “-0.5″ “-0.5″ “0.” norm[0]
> norm[1];
> #P objectname jit.expr[2];
> #P newex 50 94 105 9109513 jit.matrix 5 float32 10 8;
> #P objectname jit.matrix[3];
> #P outlet 50 312 15 0;
> #P window linecount 2;
> #P comment 218 287 100 9109513 < use the distance to clip motion to
> circle;
> #P connect 15 0 13 0;
> #P connect 12 0 13 0;
> #P connect 13 0 2 0;
> #P connect 13 1 2 0;
> #P connect 2 0 3 0;
> #P connect 3 0 4 0;
> #P connect 4 0 11 0;
> #P fasten 7 0 5 0 290 180 55 180;
> #P connect 11 0 5 0;
> #P connect 5 0 9 0;
> #P connect 9 0 6 0;
> #P connect 6 0 1 0;
> #P fasten 10 0 8 0 290 226 123 226;
> #P fasten 8 0 6 1 123 251 123 251;
> #P fasten 8 0 14 0 123 252 133 252;
> #P fasten 7 0 10 0 290 183 290 183;
> #P pop;
> #P newobj 145 232 73 9109513 p quad_Prepere;
> #P newex 159 86 23 9109513 s l2;
> #P number 72 30 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P objectname number;
> #P newex 24 27 21 9109513 r l2;
> #P objectname receive;
> #P newex 183 86 23 9109513 s l0;
> #P newex 159 62 34 9109513 t b b;
> #P window setfont “Sans Serif” 14.;
> #P newex 159 34 67 9109518 loadbang;
> #B color 5;
> #P window setfont “Sans Serif” 9.;
> #N vpatcher 530 245 771 446;
> #P origin 64 -4;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 51 84 40 9109513 sel 0 1;
> #P message 51 128 152 9109513 border 1 , size 320 240 , pos 10 463;
> #P message 66 107 160 9109513 border 0 , size 1024 778 , , pos 1024 0;
> #P toggle 51 66 15 0;
> #P window linecount 0;
> #P newex 50 44 35 9109513 sel 27;
> #P newex 50 21 40 9109513 key;
> #P outlet 56 154 15 0;
> #P fasten 1 0 2 0 55 42 55 42;
> #P connect 2 0 3 0;
> #P connect 3 0 6 0;
> #P fasten 6 0 5 0 56 106 56 106;
> #P connect 4 0 0 0;
> #P connect 5 0 0 0;
> #P connect 6 1 4 0;
> #P pop;
> #P newobj 9 142 25 9109513 p fs;
> #P window linecount 2;
> #P newex 9 164 131 9109513 jit.window rott @size 320 240 @floating 1 @pos
> 10 450;
> #P objectname jit.window;
> #P newex 48 127 141 9109513 jit.gl.render rott @camera 0 0 3 @erase_color
> 0. 0. 0. 1.;
> #P objectname jit.gl.render;
> #P toggle 48 27 20 0;
> #P objectname toggle;
> #P window linecount 1;
> #P newex 48 53 50 9109513 qmetro 20;
> #P newex 72 106 35 9109513 s draw;
> #P newex 48 75 58 9109513 t b b erase;
> #P window linecount 2;
> #P newex 145 293 234 9109513 jit.gl.mesh rott @draw_mode quads @color 1.
> 1. 1. 1. @blend_enable 1 @depth_enable 0 @texture numbers;
> #P objectname jit.gl.mesh;
> #P window linecount 1;
> #P comment 229 40 28 9109513 bang;
> #P button 255 182 15 0;
> #P newex 266 257 86 9109513 jit.matrix feedback;
> #P objectname jit.matrix[4];
> #P newex 145 257 120 9109513 jit.op @op + + + pass pass;
> #P objectname jit.op[2];
> #P window linecount 2;
> #P comment 415 202 83 9109513 how do i constrain position to circle?;
> #P window linecount 1;
> #P comment 357 258 137 9109513 look in quad_prepere for usage;
> #P connect 21 0 2 1;
> #P lcolor 1;
> #P fasten 21 0 3 0 260 250 271 250;
> #P lcolor 1;
> #P connect 4 0 26 0;
> #P connect 26 0 21 0;
> #P connect 13 0 12 0;
> #P connect 17 0 10 0;
> #P connect 10 0 9 0;
> #P fasten 9 0 7 0 53 83 53 83;
> #P fasten 7 2 11 0 101 102 53 102;
> #P connect 7 0 11 0;
> #P connect 7 1 8 0;
> #P fasten 18 0 9 1 77 49 93 49;
> #P connect 22 0 14 0;
> #P connect 14 0 15 0;
> #P connect 15 0 19 0;
> #P connect 15 1 16 0;
> #P connect 20 0 2 0;
> #P lcolor 1;
> #P connect 2 0 6 0;
> #P lcolor 1;
> #P connect 24 0 23 0;
> #P lcolor 1;
> #P connect 23 0 4 0;
> #P lcolor 1;
> #P window clipboard copycount 28;
>
>
>
> *v a d e //*
>
> *www.vade.info*
> *abstrakt.vade.info*
>
>
>
>
>
>

#114950
Oct 15, 2007 at 6:43pm

Your best bet will be to convert the matrix to polar coordinates, apply
your clamp or modulo function on the amplitude, and then convert back to
cartesian coords. Jit.expr should be your best bet with that.

I don’t have time to come up with an example, but I think there have
already been some cartopol/poltocar jit.expr examples posted.

Best of luck,
Andrew B.

#114951
Oct 15, 2007 at 9:31pm

thnx, if u find some optimizing that can be done, please do.

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 233 341 44 9109513 jit.matrix;
#P newex 233 364 181 9109513 jit.matrix 3 float32 10 8 @planemap 1 2 3;
#P newex 233 316 62 9109513 jit.alphablend;
#P newex 301 265 56 9109513 jit.unpack 3;
#P newex 286 287 55 9109513 jit.pack 4;
#P user jit.pwindow 227 272 42 32 0 0 0 0 1 0;
#P newex 255 244 104 9109513 jit.op @op < @val 0.92;
#P window setfont “Sans Serif” 10.;
#P newex 255 220 118 9109514 jit.matrix 1 float32 10 8;
#P objectname jit.matrix[1];
#P newex 255 197 276 9109514 jit.expr @expr “sqrt(pow(in[0].p[1]
\,2)+pow(in[0].p[0] \, 2)”;
#P objectname jit.matrix[2];
#P window setfont “Sans Serif” 9.;
#N vpatcher 15 55 259 206;
#P window setfont “Sans Serif” 9.;
#P flonum 154 77 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 50 95 129 9109513 jit.op @op * * * @val 2. 2. 0.;
#P objectname jit.matrix[2];
#P newex 50 72 97 9109513 jit.op @op – @val 0.5;
#P objectname jit.matrix[1];
#P newex 50 50 101 9109513 jit.noise 3 float32 10 8;
#P objectname jit.matrix[6];
#P inlet 50 30 15 0;
#P outlet 50 119 15 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P lcolor 1;
#P connect 3 0 4 0;
#P lcolor 1;
#P connect 4 0 0 0;
#P connect 5 0 4 1;
#P pop;
#P newobj 255 145 82 9109513 p noisy_placment;
#P newex 255 83 33 9109513 r draw;
#P newex 255 103 68 9109513 speedlim 1000;
#P objectname jit.matrix[5];
#P button 144 36 15 0;
#P newex 255 168 56 9109513 t l l;
#P objectname jit.matrix[3];
#N vpatcher 421 64 850 484;
#P window setfont “Sans Serif” 9.;
#P comment 137 257 191 9109513 < here we force every quad to face ceneter;
#P button 72 52 15 0;
#P newex 50 71 27 9109513 b 2;
#P newex 50 50 21 9109513 r l0;
#P newex 50 159 195 9109513 jit.op @op * * * pass pass @val 0.15 0.15 0.;
#B color 6;
#P objectname jit.op[2];
#P newex 285 190 86 9109513 jit.matrix feedback;
#B color 4;
#P objectname jit.matrix[4];
#N vpatcher 370 221 856 378;
#P origin 0 -10;
#P window setfont “Sans Serif” 14.;
#P newex 16 49 407 9109518 jit.expr @expr “in[0].p[0]*cos(HALFPI) -
in[0].p[1]*sin(HALFPI)” “in[0].p[1]*cos(HALFPI) + in[0].p[0]*sin(HALFPI)”
in[0] in[0] in[0];
#P objectname jit.expr;
#P inlet 16 31 15 0;
#P outlet 16 128 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 50 205 102 9109513 p matrix2rotationZZZZ;
#B color 5;
#P newex 118 231 212 9109513 jit.expr @expr 0. 0. “atan2(in[0].p[1] \,
in[0].p[0])”;
#P newex 285 158 33 9109513 r draw;
#P objectname receive[3];
#N vpatcher 370 221 928 467;
#P origin 0 -10;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 11 83 467 9109513 jit.expr @expr in[0]
“in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])”
“in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])” in[0] in[0];
#P objectname jit.expr[2];
#P window linecount 0;
#P newex 469 56 56 9109513 jit.unpack 3;
#P objectname jit.unpack;
#P newex 11 120 469 9109513 jit.expr @expr
“in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])” in[0]
“in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])” in[0] in[0];
#P objectname jit.expr[1];
#P newex 11 159 480 9109513 jit.expr @expr “in[0].p[0]*cos(in[1]) -
in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])” in[0]
in[0] in[0];
#P objectname jit.expr;
#P inlet 11 63 15 0;
#P inlet 467 32 15 0;
#P outlet 11 181 15 0;
#P connect 2 0 6 0;
#P connect 6 0 4 0;
#P connect 4 0 3 0;
#P connect 3 0 0 0;
#P connect 5 0 6 1;
#P connect 1 0 5 0;
#P fasten 5 1 4 1 489 119 475 119;
#P fasten 5 2 3 1 504 150 486 150;
#P pop;
#P newobj 50 254 78 9109513 p matrix2rotation;
#B color 5;
#P newex 50 183 44 9109513 jit.matrix;
#P objectname receive[2];
#N vpatcher 25 70 595 342;
#P origin 0 -10;
#P button 75 28 15 0;
#P window setfont “Sans Serif” 9.;
#P flonum 152 129 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 0;
#P newex 50 129 98 9109513 jit.op @op * @val 0.9;
#P objectname jit.op[4];
#P newex 50 108 58 9109513 jit.op @op +;
#P objectname jit.op[3];
#P window setfont “Sans Serif” 14.;
#P window linecount 2;
#P newex 98 73 392 9109518 jit.expr @expr “(cell[0]%4.>0.)*(cell[0]%4.<3.)"
“(cell[0]%4>1)” “0.” “(cell[0]%4.>0.)*(cell[0]%4.<3.)*0.1" "(cell[0]%4>1)*
0.1″;
#P objectname jit.expr[1];
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 50 50 110 9109513 jit.matrix 5 float32 40 10;
#B color 4;
#P objectname jit.matrix[1];
#P inlet 50 30 15 0;
#P outlet 50 153 15 0;
#P comment 191 131 100 9109513 why?!;
#P connect 2 0 3 0;
#P connect 8 0 3 0;
#P connect 3 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 1 0;
#P connect 7 0 8 0;
#P fasten 3 0 4 0 55 71 103 71;
#P connect 4 0 5 1;
#P connect 7 0 6 1;
#P pop;
#P newobj 50 137 61 9109513 p quadMaker;
#P newex 50 115 203 9109513 jit.expr @expr “-0.5″ “-0.5″ “0.” norm[0]
norm[1];
#P objectname jit.expr[2];
#P newex 50 94 105 9109513 jit.matrix 5 float32 10 8;
#P objectname jit.matrix[3];
#P outlet 50 312 15 0;
#P connect 13 0 12 0;
#P connect 11 0 12 0;
#P connect 12 0 1 0;
#P connect 12 1 1 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 3 0 10 0;
#P fasten 6 0 4 0 290 180 55 180;
#P connect 10 0 4 0;
#P connect 4 0 8 0;
#P connect 8 0 5 0;
#P connect 5 0 0 0;
#P fasten 9 0 7 0 290 226 123 226;
#P fasten 7 0 5 1 123 251 123 251;
#P fasten 6 0 9 0 290 183 290 183;
#P pop;
#P newobj 145 232 73 9109513 p quad_Prepere;
#P newex 159 86 23 9109513 s l2;
#P number 72 30 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname number;
#P newex 24 27 21 9109513 r l2;
#P objectname receive;
#P newex 183 86 23 9109513 s l0;
#P newex 159 62 34 9109513 t b b;
#P window setfont “Sans Serif” 14.;
#P newex 159 34 67 9109518 loadbang;
#B color 5;
#P window setfont “Sans Serif” 9.;
#N vpatcher 530 245 771 446;
#P origin 64 -4;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 51 84 40 9109513 sel 0 1;
#P message 51 128 152 9109513 border 1 , size 320 240 , pos 10 463;
#P message 66 107 160 9109513 border 0 , size 1024 778 , , pos 1024 0;
#P toggle 51 66 15 0;
#P window linecount 0;
#P newex 50 44 35 9109513 sel 27;
#P newex 50 21 40 9109513 key;
#P outlet 56 154 15 0;
#P fasten 1 0 2 0 55 42 55 42;
#P connect 2 0 3 0;
#P connect 3 0 6 0;
#P fasten 6 0 5 0 56 106 56 106;
#P connect 4 0 0 0;
#P connect 5 0 0 0;
#P connect 6 1 4 0;
#P pop;
#P newobj 9 142 25 9109513 p fs;
#P window linecount 2;
#P newex 9 164 131 9109513 jit.window rott @size 320 240 @floating 1 @pos 10
450;
#P objectname jit.window;
#P newex 48 127 141 9109513 jit.gl.render rott @camera 0 0 3 @erase_color 0.
0. 0. 1.;
#P objectname jit.gl.render;
#P toggle 48 27 20 0;
#P objectname toggle;
#P window linecount 1;
#P newex 48 53 50 9109513 qmetro 20;
#P newex 72 106 35 9109513 s draw;
#P newex 48 75 58 9109513 t b b erase;
#P window linecount 2;
#P newex 145 418 234 9109513 jit.gl.mesh rott @draw_mode quads @color 1. 1.
1. 1. @blend_enable 1 @depth_enable 0 @texture numbers;
#P objectname jit.gl.mesh;
#P window linecount 1;
#P comment 229 40 28 9109513 bang;
#P button 255 126 15 0;
#P newex 145 395 120 9109513 jit.op @op + + + pass pass;
#P objectname jit.op[2];
#P user panel 224 190 314 201;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 542 201 56 9109513 < < distance;
#P connect 12 0 11 0;
#P connect 16 0 9 0;
#P connect 9 0 8 0;
#P fasten 8 0 6 0 53 83 53 83;
#P fasten 6 2 10 0 101 102 53 102;
#P connect 6 0 10 0;
#P connect 6 1 7 0;
#P fasten 17 0 8 1 77 49 93 49;
#P connect 19 0 2 0;
#P lcolor 1;
#P connect 2 0 5 0;
#P lcolor 1;
#P connect 21 0 13 0;
#P connect 13 0 14 0;
#P connect 14 0 18 0;
#P connect 14 1 15 0;
#P fasten 27 0 28 0 260 267 233 267;
#P fasten 29 0 31 0 291 311 238 311;
#P connect 31 0 33 0;
#P connect 33 0 32 0;
#P connect 23 0 22 0;
#P lcolor 1;
#P connect 22 0 3 0;
#P lcolor 1;
#P connect 3 0 24 0;
#P connect 24 0 20 0;
#P connect 20 0 25 0;
#P connect 25 0 26 0;
#P connect 26 0 27 0;
#P connect 32 0 2 1;
#P connect 33 0 31 1;
#P fasten 27 0 29 0 260 267 291 267;
#P connect 20 1 30 0;
#P connect 30 0 29 1;
#P connect 30 1 29 2;
#P connect 30 2 29 3;
#P window clipboard copycount 34;

On 10/15/07, andrew benson wrote:
>
> Your best bet will be to convert the matrix to polar coordinates, apply
> your clamp or modulo function on the amplitude, and then convert back to
> cartesian coords. Jit.expr should be your best bet with that.
>
> I don’t have time to come up with an example, but I think there have
> already been some cartopol/poltocar jit.expr examples posted.
>
> Best of luck,
> Andrew B.
>

#114952
Oct 15, 2007 at 9:37pm

For a distance calculation often it’s enough to just multiply a matrix
by itself. Most of the time you don’t need exact distance and
distance squared is both good enough and cheaper.

wes

On 10/15/07, yair reshef wrote:
> thnx, if u find some optimizing that can be done, please do.
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 233 341 44 9109513 jit.matrix;
> #P newex 233 364 181 9109513 jit.matrix 3 float32 10 8 @planemap 1 2 3;
> #P newex 233 316 62 9109513 jit.alphablend;
> #P newex 301 265 56 9109513 jit.unpack 3;
> #P newex 286 287 55 9109513 jit.pack 4;
> #P user jit.pwindow 227 272 42 32 0 0 0 0 1 0;
> #P newex 255 244 104 9109513 jit.op @op < @val 0.92;
> #P window setfont “Sans Serif” 10.;
> #P newex 255 220 118 9109514 jit.matrix 1 float32 10 8;
> #P objectname jit.matrix[1];
> #P newex 255 197 276 9109514 jit.expr @expr “sqrt(pow(in[0].p[1]
> \,2)+pow(in[0].p[0] \, 2)”;
> #P objectname jit.matrix[2];
> #P window setfont “Sans Serif” 9.;
> #N vpatcher 15 55 259 206;
> #P window setfont “Sans Serif” 9.;
> #P flonum 154 77 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 50 95 129 9109513 jit.op @op * * * @val 2. 2. 0.;
> #P objectname jit.matrix[2];
> #P newex 50 72 97 9109513 jit.op @op – @val 0.5;
> #P objectname jit.matrix[1];
> #P newex 50 50 101 9109513 jit.noise 3 float32 10 8;
> #P objectname jit.matrix[6];
> #P inlet 50 30 15 0;
> #P outlet 50 119 15 0;
> #P connect 1 0 2 0;
> #P connect 2 0 3 0;
> #P lcolor 1;
> #P connect 3 0 4 0;
> #P lcolor 1;
> #P connect 4 0 0 0;
> #P connect 5 0 4 1;
> #P pop;
> #P newobj 255 145 82 9109513 p noisy_placment;
> #P newex 255 83 33 9109513 r draw;
> #P newex 255 103 68 9109513 speedlim 1000;
> #P objectname jit.matrix[5];
> #P button 144 36 15 0;
> #P newex 255 168 56 9109513 t l l;
> #P objectname jit.matrix[3];
> #N vpatcher 421 64 850 484;
> #P window setfont “Sans Serif” 9.;
> #P comment 137 257 191 9109513 < here we force every quad to face ceneter;
> #P button 72 52 15 0;
> #P newex 50 71 27 9109513 b 2;
> #P newex 50 50 21 9109513 r l0;
> #P newex 50 159 195 9109513 jit.op @op * * * pass pass @val 0.15 0.15 0.;
> #B color 6;
> #P objectname jit.op[2];
> #P newex 285 190 86 9109513 jit.matrix feedback;
> #B color 4;
> #P objectname jit.matrix[4];
> #N vpatcher 370 221 856 378;
> #P origin 0 -10;
> #P window setfont “Sans Serif” 14.;
> #P newex 16 49 407 9109518 jit.expr @expr “in[0].p[0]*cos(HALFPI) -
> in[0].p[1]*sin(HALFPI)” “in[0].p[1]*cos(HALFPI) + in[0].p[0]*sin(HALFPI)”
> in[0] in[0] in[0];
> #P objectname jit.expr;
> #P inlet 16 31 15 0;
> #P outlet 16 128 15 0;
> #P connect 1 0 2 0;
> #P connect 2 0 0 0;
> #P pop;
> #P newobj 50 205 102 9109513 p matrix2rotationZZZZ;
> #B color 5;
> #P newex 118 231 212 9109513 jit.expr @expr 0. 0. “atan2(in[0].p[1] \,
> in[0].p[0])”;
> #P newex 285 158 33 9109513 r draw;
> #P objectname receive[3];
> #N vpatcher 370 221 928 467;
> #P origin 0 -10;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 11 83 467 9109513 jit.expr @expr in[0]
> “in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])”
> “in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])” in[0] in[0];
> #P objectname jit.expr [2];
> #P window linecount 0;
> #P newex 469 56 56 9109513 jit.unpack 3;
> #P objectname jit.unpack;
> #P newex 11 120 469 9109513 jit.expr @expr
> “in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])” in[0]
> “in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])” in[0] in[0];
> #P objectname jit.expr[1];
> #P newex 11 159 480 9109513 jit.expr @expr “in[0].p[0]*cos(in[1]) -
> in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])” in[0]
> in[0] in[0];
> #P objectname jit.expr;
> #P inlet 11 63 15 0;
> #P inlet 467 32 15 0;
> #P outlet 11 181 15 0;
> #P connect 2 0 6 0;
> #P connect 6 0 4 0;
> #P connect 4 0 3 0;
> #P connect 3 0 0 0;
> #P connect 5 0 6 1;
> #P connect 1 0 5 0;
> #P fasten 5 1 4 1 489 119 475 119;
> #P fasten 5 2 3 1 504 150 486 150;
> #P pop;
> #P newobj 50 254 78 9109513 p matrix2rotation;
> #B color 5;
> #P newex 50 183 44 9109513 jit.matrix;
> #P objectname receive[2];
> #N vpatcher 25 70 595 342;
> #P origin 0 -10;
> #P button 75 28 15 0;
> #P window setfont “Sans Serif” 9.;
> #P flonum 152 129 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 0;
> #P newex 50 129 98 9109513 jit.op @op * @val 0.9;
> #P objectname jit.op[4];
> #P newex 50 108 58 9109513 jit.op @op +;
> #P objectname jit.op[3];
> #P window setfont “Sans Serif” 14.;
> #P window linecount 2;
> #P newex 98 73 392 9109518 jit.expr @expr
> “(cell[0]%4.>0.)*(cell[0]%4.<3.)" "(cell[0]%4>1)” “0.”
> “(cell[0]%4.>0.)*(cell[0]%4.<3.)*0.1" "(cell[0]%4>1)*0.1″;
> #P objectname jit.expr[1];
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 50 50 110 9109513 jit.matrix 5 float32 40 10;
> #B color 4;
> #P objectname jit.matrix[1];
> #P inlet 50 30 15 0;
> #P outlet 50 153 15 0;
> #P comment 191 131 100 9109513 why?!;
> #P connect 2 0 3 0;
> #P connect 8 0 3 0;
> #P connect 3 0 5 0;
> #P connect 5 0 6 0;
> #P connect 6 0 1 0;
> #P connect 7 0 8 0;
> #P fasten 3 0 4 0 55 71 103 71;
> #P connect 4 0 5 1;
> #P connect 7 0 6 1;
> #P pop;
> #P newobj 50 137 61 9109513 p quadMaker;
> #P newex 50 115 203 9109513 jit.expr @expr “-0.5″ “-0.5″ “0.” norm[0]
> norm[1];
> #P objectname jit.expr[2];
> #P newex 50 94 105 9109513 jit.matrix 5 float32 10 8;
> #P objectname jit.matrix[3];
> #P outlet 50 312 15 0;
> #P connect 13 0 12 0;
> #P connect 11 0 12 0;
> #P connect 12 0 1 0;
> #P connect 12 1 1 0;
> #P connect 1 0 2 0;
> #P connect 2 0 3 0;
> #P connect 3 0 10 0;
> #P fasten 6 0 4 0 290 180 55 180;
> #P connect 10 0 4 0;
> #P connect 4 0 8 0;
> #P connect 8 0 5 0;
> #P connect 5 0 0 0;
> #P fasten 9 0 7 0 290 226 123 226;
> #P fasten 7 0 5 1 123 251 123 251;
> #P fasten 6 0 9 0 290 183 290 183;
>
> #P pop;
> #P newobj 145 232 73 9109513 p quad_Prepere;
> #P newex 159 86 23 9109513 s l2;
> #P number 72 30 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P objectname number;
> #P newex 24 27 21 9109513 r l2;
> #P objectname receive;
> #P newex 183 86 23 9109513 s l0;
> #P newex 159 62 34 9109513 t b b;
> #P window setfont “Sans Serif” 14.;
> #P newex 159 34 67 9109518 loadbang;
> #B color 5;
> #P window setfont “Sans Serif” 9.;
> #N vpatcher 530 245 771 446;
> #P origin 64 -4;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 51 84 40 9109513 sel 0 1;
> #P message 51 128 152 9109513 border 1 , size 320 240 , pos 10 463;
> #P message 66 107 160 9109513 border 0 , size 1024 778 , , pos 1024 0;
> #P toggle 51 66 15 0;
> #P window linecount 0;
> #P newex 50 44 35 9109513 sel 27;
> #P newex 50 21 40 9109513 key;
> #P outlet 56 154 15 0;
> #P fasten 1 0 2 0 55 42 55 42;
> #P connect 2 0 3 0;
> #P connect 3 0 6 0;
> #P fasten 6 0 5 0 56 106 56 106;
> #P connect 4 0 0 0;
> #P connect 5 0 0 0;
> #P connect 6 1 4 0;
> #P pop;
> #P newobj 9 142 25 9109513 p fs;
> #P window linecount 2;
> #P newex 9 164 131 9109513 jit.window rott @size 320 240 @floating 1 @pos 10
> 450;
> #P objectname jit.window;
> #P newex 48 127 141 9109513 jit.gl.render rott @camera 0 0 3 @erase_color 0.
> 0. 0. 1.;
> #P objectname jit.gl.render;
> #P toggle 48 27 20 0;
> #P objectname toggle;
> #P window linecount 1;
> #P newex 48 53 50 9109513 qmetro 20;
> #P newex 72 106 35 9109513 s draw;
> #P newex 48 75 58 9109513 t b b erase;
> #P window linecount 2;
> #P newex 145 418 234 9109513 jit.gl.mesh rott @draw_mode quads @color 1. 1.
> 1. 1. @blend_enable 1 @depth_enable 0 @texture numbers;
> #P objectname jit.gl.mesh;
> #P window linecount 1;
> #P comment 229 40 28 9109513 bang;
> #P button 255 126 15 0;
> #P newex 145 395 120 9109513 jit.op @op + + + pass pass;
> #P objectname jit.op[2];
> #P user panel 224 190 314 201;
> #X brgb 191 191 191;
> #X frgb 0 0 0;
> #X border 1;
> #X rounded 0;
> #X shadow 0;
> #X done;
> #P comment 542 201 56 9109513 < < distance;
> #P connect 12 0 11 0;
> #P connect 16 0 9 0;
> #P connect 9 0 8 0;
> #P fasten 8 0 6 0 53 83 53 83;
> #P fasten 6 2 10 0 101 102 53 102;
> #P connect 6 0 10 0;
> #P connect 6 1 7 0;
> #P fasten 17 0 8 1 77 49 93 49;
> #P connect 19 0 2 0;
> #P lcolor 1;
> #P connect 2 0 5 0;
> #P lcolor 1;
> #P connect 21 0 13 0;
> #P connect 13 0 14 0;
> #P connect 14 0 18 0;
> #P connect 14 1 15 0;
> #P fasten 27 0 28 0 260 267 233 267;
> #P fasten 29 0 31 0 291 311 238 311;
> #P connect 31 0 33 0;
> #P connect 33 0 32 0;
> #P connect 23 0 22 0;
> #P lcolor 1;
> #P connect 22 0 3 0;
> #P lcolor 1;
> #P connect 3 0 24 0;
> #P connect 24 0 20 0;
> #P connect 20 0 25 0;
> #P connect 25 0 26 0;
> #P connect 26 0 27 0;
> #P connect 32 0 2 1;
> #P connect 33 0 31 1;
> #P fasten 27 0 29 0 260 267 291 267;
> #P connect 20 1 30 0;
> #P connect 30 0 29 1;
> #P connect 30 1 29 2;
> #P connect 30 2 29 3;
> #P window clipboard copycount 34;
>
>
>
> On 10/15/07, andrew benson wrote:
> > Your best bet will be to convert the matrix to polar coordinates, apply
> > your clamp or modulo function on the amplitude, and then convert back to
> > cartesian coords. Jit.expr should be your best bet with that.
> >
> > I don’t have time to come up with an example, but I think there have
> > already been some cartopol/poltocar jit.expr examples posted.
> >
> > Best of luck,
> > Andrew B.
> >
>
>
>
>

#114953

You must be logged in to reply to this topic.