NemoOrange
1st August 2004 02:46 UTC
cannot render perfectly 45 degree lines
This is in reference to the problem I was having this thread:
http://forums.winamp.com/showthread....hreadid=184860
So I'm working on a scope that basically moves in 45 degrees, point by point. So, its at one spot, then moves a certain distance 45 degrees away from that spot.
But, due to what seems to be a rounding error in AVS, every couple of frames, the point will move off by one pixel, & then back to the correct per-pixel path.
& the real kicker is that when you set the width of the AVS window to 284 or 756 (height does not matter), this doesn't happen at all.
I'm quite perplexed & if anyone could help, it would be of great assistance.
vanderphunck
4th August 2004 10:05 UTC
I suppose you do something like this:
[frame]
speed=1/w;
[beat]
rr=rand(8)*$pi/4;
vx=cos(rr);
vy=sin(rr);
x=0;y=0;
[point]
x=x+speed*vx;
y=y+speed*vy;
There's definitely some rounding errors in this... My first suggestion would be to round vx and vy like this:
vx=floor(cos(rr)+.5);
vy=floor(sin(rr)+.5);
That helped for me... But is ofcourse not exactly the same...
vanderphunck
4th August 2004 10:58 UTC
Actually the above does not work... but this does:
[init]
n=1000;rr=1;
[frame]
vx=floor(cos(rr*$pi/4)+.5);
vy=floor(sin(rr*$pi/4)+.5);
[beat]
rr=rr+1;
xp=floor(w/2);yp=floor(h/2);
[point]
xp=xp+vx;
yp=yp+vy;
x=(xp+.5)*2/w-1;
y=(yp+.5)*2/h-1;
---------
here i'm calculating the position in pixels. The weird thing is that it does not work unless i add the .5 as in the last 2 lines. I hope this helps...
Rovastar
5th August 2004 11:21 UTC
Yeah don't worry to much about the .5 thing I have seen similar things in MilkDrop and R4 visualizations among other and I can imagine AVS being no different.
This coudl well be due to a grid like system and positioning the 'centre' point of teh grid. you will have to shift the 'centre' along.
I explain more here
http://www.rabidhamster.org/phpBB2/v...&highlight=map
but it is in a bit of R4 pseudo-code speak though. and talking about mapping....umm I suppose DM's would be a similar thing. MAybe not the same thing but maybe gives some ideas about the theory behind the 0.5 bit. :)
NemoOrange
9th August 2004 16:18 UTC
Thanks so much Phunck!
The pixel positioning solution is exactly what I was looking for. Works perfectly.