- AVS
- cartesian rotation
Archive: cartesian rotation
Jaheckelsafar
8th February 2002 10:07 UTC
cartesian rotation
Woo! occasional lurker, first post... :D
Any help would be appreciated with this. I'm trying to do rotation in the x,y co-ordinate system in a DM, and as far as I can tell, this should work; but it doesn't.:(
per frame:
rot = rot+.01;
per pixel:
dist=sqrt(sqr(x)+sqr(y));
x=(x+cos(rot)*dist)*2;
y=(y+sin(rot)*dist)*2;
Could someone tell me why this doesn't work, and maybe point me in the right direction?
Magic.X
8th February 2002 11:33 UTC
This is'nt as hard if you try a bit.
First thing, to rotate you need a mix of x and y for every position. The mix should be managed by using sin and cos of an increasing var.
Second, i had troubles with direct assigning of x and y. Assign both to some other var's and work with them when you reassign the mix to x and y. I postet up 2 Prestets to "New Demiurgy Fractals" look at the DM in KaleidoWarpFlash2.avs and you'll find what you search.
Jaheckelsafar
8th February 2002 17:11 UTC
Hmm... got it working, thanks man. :)
The distortion when working with x,y driectly must come from changing the value for x they your using in defining y.
Great.
Jaheckelsafar
8th February 2002 17:53 UTC
I'm baaack...
I stuck the rotation into the preset I want it in in the end, and I noticed something that I didn't in my simple test preset. There is distortion that doesn't seem to be there when the polar system is used. Would coverting polar and back again fix this, and if so, please refer the original post. (it's what I was trying to do anyway)
UnConeD
8th February 2002 23:27 UTC
general rotation works like this (in matrix form):
***91;cos-sin***93;***91;x***93;=***91;x'***93;
***91;sincos***93;***91;y***93;=***91;y'***93;
So that's:
x' = x*cos - y*sin;
y' = x*sin + y*cos;
You should always assign the result to different values, else you'll be using the rotated x-coordinate to calculate the rotated y.
(of course cos/sin means the sine/cosine of the angle to rotate)
Jaheckelsafar
9th February 2002 04:19 UTC
Yeah, that's pretty much what I distilled from Magic.X's preset. The only problem is that there is distortion unless the window is square. There dosen't seem to be any such distortion when using polar. I'd use polar except I'd have a helluva time trying to scroll in it.:)
Maybe a better question would be 'Am I trying to convert to polar correctly?'.
flatmatt
9th February 2002 04:38 UTC
Just use two DM's, one for rotation in polar and a second for x & y movement in rect.
dirkdeftly
9th February 2002 19:00 UTC
Well, the thing is, that's slow. Just enter this into your rect. coor. DM:
Frame:
rt=rt+0.03;
Pixel:
x=x*sin(rt)-y*cos(rt);
y=x*cos(rt)+y*sin(rt);
Jaheckelsafar
11th February 2002 03:05 UTC
Yeah, that's what I'm using now, but like I said earlier, that gets distorted unless the window is square. I'd even go so far as the use 2 DMs, except the the one is scrolling around. If I use 2 DMs the edges don't match.
Ah well, I guess it'll have to do.
For all that helped, I thought I'd share my finished product. (thinking of puting out a pack, this would by my most complicated one (except for a remix of it :) ))
dirkdeftly
11th February 2002 05:18 UTC
Use wrap...
You can get rid of the edges by making your render is smaller in the first place and dividing d by sqrt(2). This would make your end product kind of blocky, but it would get rid of the edges.
Jaheckelsafar
12th February 2002 06:17 UTC
Well, it does work like that perfectly, but I think it needs the detail. Thanks anyway.