coordinates convertion

Jul 8, 2008 at 1:32pm

coordinates convertion

hi,

i posted my question on the jitter forum without success (and searched in the forum before).

i put it in the max forum ’cause it’s not only jitter question but also mathematic.

i can’t figure out how to convert some data to other.

i want to make a video player with the possibility to set the coordinates of each corner of the display.

does somebody help me for this math, please ?
thx.

here’s the patche to illustrate what i’m trying to do :

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 249 216 250 196617 jit.window main @floating 1 @rect 715 50 1035 290;
#P newex 494 65 45 196617 jit.qball;
#P toggle 494 29 15 0;
#P newex 494 84 66 196617 t b b b erase;
#P newex 494 46 52 196617 metro 40;
#P newex 250 195 199 196617 jit.gl.render main @erase_color 0. 0. 0. 1;
#P window linecount 2;
#P newex 250 134 238 196617 jit.gl.videoplane main @automatic 1 @blend_enable 1 @scale 1. 1. 1. @color 1. 1. 1. 1. @interp 1;
#P window linecount 1;
#P message 250 65 76 196617 read bball.mov;
#P message 320 88 27 196617 stop;
#P message 286 88 31 196617 start;
#P newex 250 111 207 196617 jit.qt.movie @adapt 1 @loop 1 @autostart 0;
#B color 5;
#P user jit.pwindow 34 89 162 122 0 1 0 0 1 0;
#P objectname main;
#P comment 109 215 14 196617 Y;
#P comment 17 143 14 196617 X;
#P comment 198 143 14 196617 X;
#P flonum 195 195 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 0 195 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 195 90 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 0 90 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 160 210 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 35 210 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 160 75 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 35 75 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 108 70 14 196617 Y;
#N vpatcher 262 44 680 414;
#P window setfont “Sans Serif” 9.;
#P hidden newex 169 357 104 196617 bgcolor 255 230 230;
#P flonum 326 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 290 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 254 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 254 265 95 196617 pak position 0. 0. 0.;
#P flonum 349 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 313 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 277 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 241 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 241 205 102 196617 pak rotate 0. 0. 0. 0.;
#P flonum 301 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 265 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 229 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 229 147 85 196617 pak scale 0. 0. 0.;
#P outlet 19 339 15 0;
#P flonum 205 1 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 205 28 70 196617 lens_angle $1;
#P flonum 289 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 253 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 217 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 217 89 95 196617 pak camera 0. 0. 0.;
#P flonum 142 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 106 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 70 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 70 89 89 196617 pak lookat 0. 0. 0.;
#P toggle 19 10 15 0;
#P message 19 30 45 196617 ortho $1;
#P connect 1 0 0 0;
#P fasten 22 0 12 0 259 308 24 308;
#P fasten 17 0 12 0 246 243 24 243;
#P fasten 13 0 12 0 234 212 24 212;
#P fasten 6 0 12 0 222 183 24 183;
#P fasten 2 0 12 0 75 142 24 142;
#P connect 0 0 12 0;
#P fasten 10 0 12 0 210 156 24 156;
#P fasten 3 0 2 1 75 81 101 81;
#P fasten 4 0 2 2 111 81 127 81;
#P fasten 5 0 2 3 147 81 153 81;
#P connect 11 0 10 0;
#P fasten 7 0 6 1 222 81 250 81;
#P fasten 14 0 13 1 234 139 259 139;
#P fasten 18 0 17 1 246 197 269 197;
#P fasten 8 0 6 2 258 81 278 81;
#P fasten 15 0 13 2 270 139 284 139;
#P fasten 23 0 22 1 259 257 287 257;
#P fasten 19 0 17 2 282 197 292 197;
#P fasten 9 0 6 3 294 81 306 81;
#P fasten 16 0 13 3 306 139 309 139;
#P fasten 20 0 17 3 318 197 315 197;
#P fasten 24 0 22 2 295 257 315 257;
#P fasten 21 0 17 4 354 197 338 197;
#P fasten 25 0 22 3 331 257 343 257;
#P pop;
#P newobj 266 173 108 196617 p viewing_transforms;
#P connect 14 0 13 0;
#P connect 14 0 18 0;
#P fasten 15 0 14 0 291 107 255 107;
#P fasten 16 0 14 0 325 107 255 107;
#P fasten 17 0 14 0 255 107 255 107;
#P fasten 21 2 14 0 535 106 255 106;
#P fasten 21 0 19 0 499 170 255 170;
#P fasten 21 1 18 0 517 131 255 131;
#P fasten 21 3 19 0 553 170 255 170;
#P connect 22 0 20 0;
#P connect 20 0 23 0;
#P connect 23 0 21 0;
#P fasten 0 0 19 0 271 192 255 192;
#P connect 18 0 19 0;
#P window clipboard copycount 25;

#38789
Jul 8, 2008 at 1:41pm

not sure i understand the question, but have u thought of using srcrect / dstrect message to control the output size of jit.qt.movie (see help file)…

although from the patch it looks like you are trying to do that with open gl < ?>

bw,

j

#135609
Jul 8, 2008 at 2:04pm

yes for many reasons i use open gl.
i can’t control each of the ABCD points indepently with srcrect / dstrect.

i suppose it’s possible to do some math to convert xy data of each point to rotation, lookup and other parameters of the jit.gl.render

to be clear :
my display is a rectangle ABCD.
i would like : xy for A, xy for B, etc.
x and y equal to 0 when it’s the normal size.

thx.
f./

#135610
Jul 8, 2008 at 4:20pm

if it’s a rectangle you can’t control each point independently,
because two points always share either the x or y component of the
ccordinate.

one convention used is to define the four edges of the image from
which you can deduce the corners:
left (x1) top (y1) right (x2) bottom (y2)
this gives you the following for the four corners:
left/top (x1,y1)
right/top (x2, y1)
right/bottom (x2, y2)
left bottom (x1, y2)
or you could consider this like the selection rectangle on the desktop
with te top left and botom right corners defined.

in this notation, the x and y’s are the cordinates of the points, not
the distance between sides.
to get these you take x2 -x1 = delta x and y2 – y1 = delta y;

if you would like to scale the image, one other important point is the
center of the image:
(x2 – x1) / 2. = x center
(y2 – y1) / 2. = y center
if you now subtract thses values from each corner, your rectangle will
be itting on the center extending both to positive and negative.

what i don’t quite understand:

> i would like : xy for A, xy for B, etc.
> x and y equal to 0 when it’s the normal size.

wouldn’t normal size be 1. (100%)
in opengl, to move a rectangle you only need to know its center and
its size, and maybe the affine tranforms but not the positions of the
corners.

hth

/*j

#135611
Jul 8, 2008 at 4:40pm

thx a lot for your answer.
yes i noticed i can move edges (with camera, lookup, scale, etc).

when i say xy = 0 for the normal size, it’s because i would like something relative.

for example :
i have 320 x 240 video on a screen.
i want to move only the A corner (left, top) 10 units to the right
i’ll have x = 10 y = 0 for A

etc…

with this method it will be easier to display the movie on my screen from the video projector.

>
> what i don’t quite understand:
>
> > i would like : xy for A, xy for B, etc.
> > x and y equal to 0 when it’s the normal size.
>
> wouldn’t normal size be 1. (100%)
> in opengl, to move a rectangle you only need to know its center and
> its size, and maybe the affine tranforms but not the positions of the
> corners.
>
> hth
>
> /*j
>
—————————————————-

#135612
Jul 8, 2008 at 4:42pm

but yes if you have to show another method relative to the center or
something else, i want to know.
for now i’m totally lost…
:-)

elt@altern.org
http://pan-etc.net

>

#135613
Jul 8, 2008 at 4:45pm

i would say if you woild like to show…
excuse my poor english.

>

#135614
Jul 10, 2008 at 2:17am

I haven’t tried this, but instead of a videoplane with the texture, how about a jit.gl.sketch which draws the shape you want… probably “tri_strip”, poly_mode 0 0, draw the four corners wherever you want (make a rectangle by default), then apply the texture? It would be like using a plane gridshape, but you’d have control over all 4 points (including in the z direction) and could move and warp the shape however you want while the video is playing. 4 points is definitely not the limit, either.

Would look pretty cool if it worked, I imagine it’s totally possible… because any texture can be applied to a gl.sketch, right? Maybe I’m missing something, and don’t have max here to try it, but I bet you can “project” a texture onto any shape you can draw. As far as the points moving relative to a set location, that’s pretty straightforward, though you often need to convert from screen pixels to GL world coordinates. Position, scale, and rotation also work with a sketch object, as does jit.gl.handle, so try these out too.

–CJ

#135615
Jul 14, 2008 at 4:06pm

ok thx. i didn’t think about that.
i will try. i’m quite new t jitter so it’s a little bit difficult to
know how to do “tri_strip”.
if you have time to illustrate with an example, you’re welcome :-)
thx.

elt@altern.org
http://pan-etc.net

>
> how about a jit.gl.sketch which draws the shape you want…

#135616
Jul 14, 2008 at 7:39pm

hi,

so i tried with jit.gl.sketch.
i could get what i want with quad.

i have some questions :

1- why does the movie play with plane and not with quad ?

2- what are points 1 2 3 4 for the quad ? 1 = left bottom ?

3- what is “shapeprim tri_strip” ?
how to use it ? what are the others (quad_strip, etc) ?

thx for your help.

f./

here’s the patch :

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 45 326 89 196617 IT DOESN’T WORK;
#P newex 277 214 50 196617 loadbang;
#P flonum 581 363 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname sc-y2;
#P flonum 546 363 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname sc-x2;
#P flonum 511 363 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname sc-y1;
#P flonum 476 363 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname sc-x1;
#P newex 441 401 153 196617 pak plane 1. -0.72 1. -0.72;
#P newex 293 264 95 196617 jit.gl.handle main;
#B color 5;
#P message 359 40 50 196617 read;
#P newex 471 40 50 196617 autopattr;
#X prestore sc-x1 1 0 1.;
#X prestore sc-x2 1 0 1.;
#X prestore sc-y1 1 0 -0.72;
#X prestore sc-y2 1 0 -0.72;
#X prestore x1 1 0 -1.;
#X prestore x2 1 0 -1.;
#X prestore x3 1 0 1.;
#X prestore x4 1 0 1.;
#X prestore y1 1 0 -0.72;
#X prestore y2 1 0 0.72;
#X prestore y3 1 0 0.72;
#X prestore y4 1 0 -0.72;
#P objectname u022000239;
#P button 25 326 15 0;
#P comment 226 187 14 196617 4;
#P comment 226 51 14 196617 3;
#P comment 50 51 14 196617 2;
#P newex 221 500 50 196617 t l reset;
#P newex 225 382 50 196617 pvar y4;
#P newex 205 361 50 196617 pvar x4;
#P newex 165 382 50 196617 pvar y3;
#P newex 145 361 50 196617 pvar x3;
#P newex 105 382 50 196617 pvar y2;
#P newex 85 361 50 196617 pvar x2;
#P newex 5 401 260 196617 pak quad -1. -0.72 0. -1. 0.72 0. 1. 0.72
0. 1. -0.72 0.;
#P newex 45 382 50 196617 pvar y1;
#P newex 25 361 50 196617 pvar x1;
#P message 277 238 34 196617 reset;
#P window linecount 2;
#P comment 11 420 357 196617 quad
; framequad
;;
#P window linecount 1;
#P newex 280 117 144 196617 prepend texture movie;
#P message 204 238 72 196617 texture movie;
#P message 326 501 99 196617 shapeprim tri_strip;
#P newex 277 534 88 196617 jit.gl.sketch main;
#P newex 280 191 250 196617 jit.window main @floating 1 @rect 715 50
1035 290;
#P newex 524 40 45 196617 jit.qball;
#P toggle 524 4 15 0;
#P newex 524 59 66 196617 t b b b erase;
#P newex 524 21 52 196617 metro 40;
#P newex 280 170 199 196617 jit.gl.render main @erase_color 0. 0. 0. 1;
#P message 280 40 76 196617 read bball.mov;
#P message 350 63 27 196617 stop;
#P message 316 63 31 196617 start;
#P newex 280 92 207 196617 jit.qt.movie @adapt 1 @loop 1 @autostart 0;
#B color 5;
#P user jit.pwindow 64 64 162 122 0 1 0 0 1 0;
#P objectname main;
#P comment 139 190 14 196617 Y;
#P comment 47 118 14 196617 X;
#P comment 228 118 14 196617 X;
#P flonum 225 170 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname x4;
#P flonum 30 170 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname x1;
#P flonum 225 65 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname x3;
#P flonum 30 65 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname x2;
#P flonum 190 185 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname y4;
#P flonum 65 185 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname y1;
#P flonum 190 50 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname y3;
#P flonum 65 50 35 9 -1. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname y2;
#P comment 138 45 14 196617 Y;
#N vpatcher 262 44 680 414;
#P window setfont “Sans Serif” 9.;
#P message 54 276 46 196617 axes $1;
#P toggle 54 258 15 0;
#N vpreset 1;
#X append 1 2 1 10 19 toggle int 0 ; 3 58 70 flonum float 0. ; 4 58
106 flonum float 0. ; 5 58 142 flonum float 0. ; 7 58 217 flonum
float 0. ; 8 58 253 flonum float;
#X append 1 2 0. ; 9 58 289 flonum float 2. ; 11 1 205 flonum float
45. ; 14 116 229 flonum float 1. ; 15 116 265 flonum float 1. ; 16
116 301 flonum float 1. ; 18 174 241;
#X append 1 2 flonum float 0. ; 19 174 277 flonum float 0. ; 20 174
313 flonum float 1. ; 21 174 349 flonum float 0. ; 23 234 254
flonum float 0. ; 24 234 290 flonum float 0. ; 25 234 326;
#X append 1 2 flonum float 0. ; 28 258 54 toggle int 1 ;;
#P preset 334 40 47 27;
#P hidden newex 169 357 104 196617 bgcolor 255 230 230;
#P flonum 326 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 290 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 254 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 254 265 95 196617 pak position 0. 0. 0.;
#P flonum 349 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 313 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 277 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 241 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 241 205 104 196617 pak rotate 0. 0. 1. 0.;
#P flonum 301 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 265 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 229 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 229 147 87 196617 pak scale 1. 1. 1.;
#P outlet 19 339 15 0;
#P flonum 205 1 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 205 28 70 196617 lens_angle $1;
#P flonum 289 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 253 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 217 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 217 89 97 196617 pak camera 0. 0. 2.;
#P flonum 142 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 106 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 70 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 70 89 89 196617 pak lookat 0. 0. 0.;
#P toggle 19 10 15 0;
#P message 19 30 45 196617 ortho $1;
#P connect 1 0 0 0;
#P fasten 22 0 12 0 259 308 24 308;
#P fasten 2 0 12 0 75 142 24 142;
#P connect 0 0 12 0;
#P fasten 10 0 12 0 210 156 24 156;
#P fasten 29 0 12 0 59 308 24 308;
#P fasten 6 0 12 0 222 183 24 183;
#P fasten 13 0 12 0 234 212 24 212;
#P fasten 17 0 12 0 246 243 24 243;
#P connect 28 0 29 0;
#P fasten 3 0 2 1 75 81 101 81;
#P fasten 4 0 2 2 111 81 127 81;
#P fasten 5 0 2 3 147 81 153 81;
#P connect 11 0 10 0;
#P fasten 7 0 6 1 222 81 251 81;
#P fasten 14 0 13 1 234 139 259 139;
#P fasten 18 0 17 1 246 197 269 197;
#P fasten 8 0 6 2 258 81 280 81;
#P fasten 15 0 13 2 270 139 284 139;
#P fasten 23 0 22 1 259 257 287 257;
#P fasten 19 0 17 2 282 197 292 197;
#P fasten 9 0 6 3 294 81 309 81;
#P fasten 16 0 13 3 306 139 309 139;
#P fasten 20 0 17 3 318 197 315 197;
#P fasten 24 0 22 2 295 257 315 257;
#P fasten 21 0 17 4 354 197 338 197;
#P fasten 25 0 22 3 331 257 343 257;
#P pop;
#P newobj 296 148 108 196617 p viewing_transforms;
#P comment 450 421 249 196617 plane
;;
#P comment 50 187 14 196617 1;
#P comment 426 502 79 196617 what is it for ?;
#P comment 483 346 54 196617 IT WORKS;
#P connect 47 0 34 0;
#P connect 47 0 35 0;
#P connect 47 0 37 0;
#P connect 47 0 38 0;
#P connect 47 0 39 0;
#P connect 47 0 40 0;
#P connect 47 0 41 0;
#P connect 47 0 42 0;
#P connect 33 0 28 0;
#P fasten 33 0 50 0 282 259 298 259;
#P fasten 56 0 30 0 282 234 209 234;
#P connect 56 0 33 0;
#P connect 55 0 51 4;
#P connect 26 0 24 0;
#P connect 23 0 26 0;
#P connect 25 0 23 0;
#P connect 54 0 51 3;
#P connect 53 0 51 2;
#P connect 52 0 51 1;
#P fasten 24 0 22 0 529 145 285 145;
#P fasten 24 3 22 0 583 145 285 145;
#P fasten 4 0 22 0 301 167 285 167;
#P connect 31 0 22 0;
#P connect 18 0 17 0;
#P connect 18 0 31 0;
#P fasten 49 0 18 0 364 58 285 58;
#P fasten 19 0 18 0 321 82 285 82;
#P fasten 20 0 18 0 355 82 285 82;
#P fasten 21 0 18 0 285 82 285 82;
#P fasten 24 2 18 0 565 82 285 82;
#P connect 42 0 36 11;
#P connect 41 0 36 10;
#P connect 40 0 36 8;
#P connect 39 0 36 7;
#P connect 38 0 36 5;
#P connect 37 0 36 4;
#P fasten 30 0 28 0 209 257 282 257;
#P fasten 29 0 28 0 331 525 282 525;
#P fasten 43 1 28 0 266 525 282 525;
#P fasten 43 0 28 0 226 525 282 525;
#P fasten 50 0 28 0 298 287 282 287;
#P connect 35 0 36 2;
#P connect 34 0 36 1;
#P fasten 36 0 43 0 10 463 226 463;
#P fasten 51 0 43 0 446 463 226 463;
#P window clipboard copycount 58;

#135617

You must be logged in to reply to this topic.