target cells

Feb 25, 2009 at 1:02pm

target cells

Hello,

here’s the deal:

I want to apply an expression to (cells in) a geom matrix, only if (cells in) the control matrix are 1.

Can I apply my expression selectively?

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 96 155 68 196617 Geom matrix;
#P newex 445 109 63 196617 jit.op @op >;
#P newex 445 81 130 196617 jit.matrix 1 float32 20 20;
#P window setfont “Sans Serif” 14.;
#P window linecount 3;
#P newex 51 233 509 196622 jit.expr @inputs 2 @expr “in[0].p[0]*(in[1]/sqrt(pow(in[0].p[0]\,2)+(pow(in[0].p[1]\, 2))))” “in[0].p[1]*(in[1]/sqrt(pow(in[0].p[0]\, 2)+(pow(in[0].p[1]\, 2))))”;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 51 327 308 196617 jit.gl.mesh qwe @texture img @draw_mode points @point_size 10;
#P newex 51 174 133 196617 jit.matrix 2 float32 20 20;
#P comment 461 57 77 196617 Control matrix;
#P connect 4 0 5 0;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P window clipboard copycount 7;

#42524
Feb 27, 2009 at 2:33am

One solution:
-multiply your geom matrix by (control matrix -> jit.op @op == @value 1) and apply your expression
-mutiply your geom matrix by (control matrix -> jit.op @op != @value 1)
-add both results

You can do all of this within one jit.expr, instanciating jit.op objects from inside jit.expr.
Jean-François.

#152158
Feb 27, 2009 at 12:33pm

Great help, thank you Jean François.

> You can do all of this within one jit.expr, instanciating jit.op objects from inside jit.expr.

That appears to be harder, could you show me?

________________One solution__________________________

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vpatcher 460 63 588 255;
#P outlet 32 74 15 0;
#P inlet 36 41 15 0;
#P connect 0 0 1 0;
#P pop;
#P newobj 760 290 13 196617 p;
#P user jit.cellblock 455 533 604 570 3 9 3 3 73 17 0 1 1 0 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 2 0 0 0;
#P user jit.cellblock 777 369 926 406 3 9 3 3 73 17 0 1 1 0 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 2 0 0 0;
#P message 792 166 74 196617 setall 0. , bang;
#P user jit.cellblock 705 431 854 468 3 9 3 3 73 17 0 1 1 0 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 2 0 0 0;
#P message 843 67 126 196617 send jit.cellblock plane -1;
#P newex 843 87 52 196617 universal;
#P user jit.cellblock 455 631 604 668 3 9 3 3 73 17 0 1 1 0 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 2 0 0 0;
#P user multiSlider 879 133 72 48 0. 1. 9 2681 47 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P newex 879 184 55 196617 jit.fill asd;
#P message 783 146 77 196617 setall 1. , bang;
#P message 954 418 23 196617 0.5;
#P newex 979 40 48 196617 loadbang;
#P user jit.cellblock 516 370 665 407 3 9 3 3 73 17 0 1 1 0 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 2 0 0 0;
#P user jit.cellblock 463 252 612 289 3 9 3 3 73 17 0 1 1 0 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 2 0 0 0;
#P flonum 954 436 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 4;
#P message 68 468 304 196617 ; max launchbrowser http://www.cycling74.com/forums/index.php?t=msg&th=38261&start=0&rid=3975&S=96124773d5f2fa68e914ce705affdbf5;
#P window linecount 1;
#P newex 444 610 64 196617 jit.op @op +;
#P newex 760 346 104 196617 jit.op @op != @val 1.;
#P newex 705 404 65 196617 jit.op @op *;
#P comment 474 207 68 196617 Geom matrix;
#P newex 444 178 264 196617 jit.gl.gridshape @matrixoutput 1 @shape plane @dim 3 3;
#P newex 499 344 107 196617 jit.op @op == @val 1.;
#P newex 760 230 136 196617 jit.matrix asd 1 float32 3 3;
#P window linecount 3;
#P newex 444 488 326 196617 jit.expr @inputs 2 @expr “in[0].p[0]*(in[1]/sqrt(pow(in[0].p[0]\,2)+(pow(in[0].p[1]\, 2))))” “in[0].p[1]*(in[1]/sqrt(pow(in[0].p[0]\, 2)+(pow(in[0].p[1]\, 2))))”;
#P window linecount 1;
#P newex 444 688 308 196617 jit.gl.mesh qwe @texture img @draw_mode points @point_size 10;
#P newex 444 224 118 196617 jit.matrix 2 float32 3 3;
#P comment 792 214 77 196617 Control matrix;
#P message 148 82 34 196617 reset;
#P toggle 129 103 15 0;
#P newex 129 123 29 196617 gate;
#P message 53 172 121 196617 name qwe , size 320 240;
#P user jit.pwindow 52 198 322 242 0 1 0 0 1 0;
#X name qwe;
#P newex 57 146 176 196617 jit.gl.render qwe @position 0. 0. -3.;
#P newex 57 84 50 196617 t b erase;
#P toggle 57 31 15 0;
#P newex 57 55 57 196617 qmetro 20;
#P newex 148 100 186 196617 jit.gl.handle qwe @inherit_transform 1;
#P user jit.cellblock 453 428 602 465 3 9 3 3 73 17 0 1 1 0 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 2 0 0 0;
#P newex 444 404 65 196617 jit.op @op *;
#P comment 81 546 100 196617 Thanks to JFCharles;
#P fasten 40 0 18 0 765 326 504 326;
#P connect 40 0 22 0;
#P fasten 28 0 30 0 984 107 788 107;
#P fasten 28 0 35 0 984 62 848 62;
#P fasten 28 0 29 0 984 374 959 374;
#P connect 23 0 15 0;
#P connect 23 0 33 0;
#P connect 22 0 21 1;
#P connect 22 0 38 0;
#P connect 21 0 23 1;
#P connect 21 0 36 0;
#P connect 18 0 1 1;
#P connect 18 0 27 0;
#P connect 16 0 23 0;
#P connect 16 0 39 0;
#P connect 14 0 1 0;
#P fasten 14 0 26 0 449 246 468 246;
#P connect 14 0 21 0;
#P connect 4 0 6 0;
#P fasten 4 0 19 0 62 76 449 76;
#P fasten 4 0 17 0 62 76 765 76;
#P connect 1 0 16 0;
#P connect 1 0 2 0;
#P connect 9 0 8 0;
#P connect 5 0 4 0;
#P fasten 10 0 7 0 134 143 62 143;
#P fasten 6 1 7 0 102 105 62 105;
#P connect 6 0 7 0;
#P connect 11 0 10 0;
#P connect 12 0 3 0;
#P connect 3 0 10 1;
#P connect 19 0 14 0;
#P fasten 37 0 17 0 797 207 765 207;
#P fasten 31 0 17 0 884 207 765 207;
#P fasten 30 0 17 0 788 207 765 207;
#P connect 17 0 40 0;
#P fasten 25 0 16 1 959 482 765 482;
#P connect 35 0 34 0;
#P connect 32 0 31 0;
#P connect 29 0 25 0;
#P window clipboard copycount 41;
_____________________________________________

#152159
Feb 27, 2009 at 1:48pm

Thanks for sharing the patch.
Actually, for jit.op, you don’t need to use it as a functor (and it wouldn’t be more efficient). All jit.op operations are accessible directly from jit.expr. You could do everything in one expr. I’m not sure how well this is documented, but here you go:
– expr “eq(in[0], 1.)” is equivalent to @op ==, @val 1.
– expr “neq(in[0], 1.)” is equivalent to op !=, @val 1.
Would you need it, there is also, for instance:
– expr “gt(in[0], 0.5)” for “greater than”
– expr “lt(in[0], 0.5)” for “less than”

With eq(), neq(), and +, you should manage to put everything in one expr.
Something like that, with a third input to jit.expr to host your control matrix:

jit.expr @inputs 3 @expr “eq(in[2], 1.)*in[0].p[0]*(in[1]/sqrt(pow(in[0].p[0],2)+(pow(in[0].p[1], 2))))+neq(in[2], 1.)*in[0].p[0]” “eq(in[2], 1.)*in[0].p[1]*(in[1]/sqrt(pow(in[0].p[0], 2)+(pow(in[0].p[1], 2))))+neq(in[2], 1.)*in[0].p[1]“

Let us know how it goes.
The “problem” in the above expr is that we calculate twice the eq() and neq(), and we add the non-transformed cells twice, once for each plane. Maybe you (or someone else) has a more elegant idea?
Jean-François.

#152160

You must be logged in to reply to this topic.