## coordinates convertion

Jul 08 2008 | 1:32 pm
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 :

• Jul 08 2008 | 1:41 pm
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
• Jul 08 2008 | 2:04 pm
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./
• Jul 08 2008 | 4:20 pm
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
• Jul 08 2008 | 4:40 pm
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
>
----------------------------------------------------
• Jul 08 2008 | 4:42 pm
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
--
>
• Jul 08 2008 | 4:45 pm
i would say if you woild like to show...
excuse my poor english.
--
>
• Jul 10 2008 | 2:17 am
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
• Jul 14 2008 | 4:06 pm
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...
• Jul 14 2008 | 7:39 pm
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) ?