Skip to content
Forum Archive

cartesian rotation

11 posts

Jaheckelsafar#

cartesian rotation

Woo! occasional lurker, first post... 😁

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#
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#
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#
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#
general rotation works like this (in matrix form):
[cos -sin] [ x ]  =  [ x' ]
[sin  cos] [ y ]  =  [ y' ] 
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#
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?'.
dirkdeftly#
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#
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#
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#
Well, it does work like that perfectly, but I think it needs the detail. Thanks anyway.