PDA

View Full Version : superscope queries

Clinical
23rd November 2002, 14:43
Okay, I've got 2 questions regarding the superscope (the answer to the first one I know for a fact I read on here somewhere, but I can't seem to find it now... isn't that always how it goes?).
1. What is the code to make the SSC stay the same shape no matter what shape the AVS window is? (i.e. when I have the editor window open the AVS window is square, and it looks okay, but when I go fullscreen it stretches the scope out; how do I prevent this?)
2. If you follow the lines of my scope, you'll see that the two endpoints of the line don't meet, and there is an ugly-looking gap. I don't have anywhere near the level of math required to fix this (that, and I pretty much plugged in semi-random numbers :P ), so could one of you math geniuses please give it a shot? Here's the code:
Init:
n=100;t=0;pi=3.1415926535897932384626433832795;

On Beat:
n=64+rand(128)

Per Frame:
t=t-pow((1/pi),2);

Per Point:
r=(i*pi)*(pow(2,10))+t;
x=cos(r/64)*0.7+sin(r*(1/pi))*0.3;
y=sin(r/64)*0.7+cos(r*(1/pi))*0.3
In case you're wondering, yes, I did just take one of the example scopes and change it around a bit. :o

Any help would be greatly appreciated.

jheriko
23rd November 2002, 17:55
firstly to stop the stretching do x=x*h/w; at the end of alll of your code.

secondly i can't see anything wrong with your code except for inefficient code. like pow(2,10) just replace that with 1024 and 1/pi could be calculated at the beginning like pi is. the reason that the ends of the lines don't meet is simply the code that you've used.

x=cos(r/64)*0.7+sin(r*(1/pi))*0.3;
y=sin(r/64)*0.7+cos(r*(1/pi))*0.3;

think about what this code is actually doing... it doesn't draw a closed loop because of the 1/pi which means that the two ends will never meet exactly.

Clinical
23rd November 2002, 20:54
Originally posted by jheriko
firstly to stop the stretching do x=x*h/w; at the end of alll of your code.Cool, thanks.secondly i can't see anything wrong with your code except for inefficient code. like pow(2,10) just replace that with 1024 and 1/pi could be calculated at the beginning like pi is. Thanks for the tip... the 'pow(2,10) is there because when I was tweaking it, I was seeing what different exponents did. I settled on 10, so I guess I should replace it with 1024.the reason that the ends of the lines don't meet is simply the code that you've used.

x=cos(r/64)*0.7+sin(r*(1/pi))*0.3;
y=sin(r/64)*0.7+cos(r*(1/pi))*0.3;

think about what this code is actually doing... it doesn't draw a closed loop because of the 1/pi which means that the two ends will never meet exactly. See, I can't really 'think' about what the code is doing, because it is beyond the scope of my feeble brain. :p So is there, in fact, something I could replace 1/pi with that would produce a similar look, but close up the loop?

Thanks a lot for the help! :D

dirkdeftly
23rd November 2002, 21:30
Faster and more correct shape fix:

init:
xscale=min(h/w,1); yscale=min(w/h,1);

frame:

...
x=x*xscale; y=y*yscale;

uNDefineD
24th November 2002, 00:33
BTW, you can use pi=acos(-1) instead of 3.14159...

jheriko
24th November 2002, 00:36
try replacing your beat and point with:

beat:
n=4*(16+rand(32))

frame:
r=(200*i*pi);
x=cos(r*4+4*t/n)*0.7+sin(r*n)*0.3;
y=sin(r*4+4*t/n)*0.7+cos(r*n)*0.3

play with the 200, but make sure it is divisible by 4 to keep the ends meeting.

Clinical
24th November 2002, 02:38
Thank you so much for the help, everyone! :D

Jheriko, I don't know if I'll use your 'frame' expression... I kinda like the shapes mine produces better, despite the break in the line. But I might use that for a different preset (I already have a preset built around my current superscope... maybe if I ever make enough of 'em I'll post my pack on here).

Thanks again!

dirkdeftly
25th November 2002, 06:20
I think he meant point :igor: