- AVS
- question
Archive: question
cmountford
11th December 2003 02:47 UTC
question
hey, guys...I know it's been a while since I've worked on AVS (not too long, but a while)
Anyways, I was wondering if you could help me with something
What I'm trying to do is create a SSC that I can show to my math teacher and see what I can get in terms of some form of slightly improving my grade (I have an 89.6, and he doesn't round)...possibly extra credit or whatever). It's on honors Pre-Calc class, and we're currently wrapping up the trigonometry section of it.
I know he thinks highly of programming and the like, so he might consider letting me do a project in AVS that will do what I have in mind
What I have in mind is a SSC that will allow a value to be specified (in Init)---or assigned (by the various methods in AVS...like rand, etc.) in degrees, and then have the SSC's math use the degrees to radians formula (you know...radians=degrees*pi/180) and then have that value create two lines to make up the angle in the SSC
I messed around using the absolute value graph's function and buffer saves & effect lists combined with roto-blitters...but it's just being weird.
Here's what I have so far:
Init: n=100;
On Beat: rn=(rand(5)-rand(7))/(rand(5)+.01)
Per Frame: (empty)
Per Point: x=abs(y); y=i-.5; x=rn*x
-----------------------------------
I'm not sure if the absolute value idea can be used to do this given the radian value (currently, it's a random value assigned On Beat...the variable is rn).
One complication that is confusing me is for values that make a small angle, the lines get obnoxiously long. The shortening/lengthening occurs the whole time, but it's just awful to have such big lines.
Also, it's hard to clearly see the angle unless one of the lines stays in the same place, which currently I can only accomplish by changing the roto blitters to make the base line of angle pretty much straight across. This tends to become a problem. Any ideas how I could fix this?
I don't think the teacher will have a problem with getting help from you guys. After all, I came up with my own superscope based on the concept I had in mind---then I ask how to fix some bugs in the AVS forums.
Thanks in advance!
[edit]: Note: I'm aware that currently my SSC won't allow a direct use of a radian value to draw the line...I know it's nowhere near the point where I could use it, but I'm hoping with some tweaking I could get it to where it could be used.
sidd
11th December 2003 05:03 UTC
Well, seeing as its going towards your own progression in life, i dont think it would be right for us to do it all for you, but here's a few tips:
you can specify the points in polar coordinates (d=distance from center, r=radians) if you later convert it back to cartesian using:
x=cos(r)*d;
y=sin(r)*d;
and you dont need to specify all the points in each line; just use three points:
0 degrees, center of circle, desired angle.
And make sure the sscope has 'lines' and not 'dots' selected.
But im not going to tell you how to specify individual points in a scope.. :P
Also, putting more than one random in an arithmatic line wont make it any more 'random', it will change the behaviour and probability of certain results, but it is hard to predict. [ (rand(5)-rand(7))/(rand(5)+.01) ] might as well be something simple rand(5)-2.
Or, if you are trying to get some nice radians, you could use something like rand(100)*0.0628
to get 100 possible results between 0 and 6.28 (2pi).
sidd
11th December 2003 05:21 UTC
i couldnt resist:
init:
n=363;pi=acos(-1);
frame:
pt=0;af=w/h;rad=rad*0.8+radb*0.1;
beat:
deg=rand(360);radb=2*deg*pi/180
point:
r=equal(pt,2)*rad+above(pt,2)*i*pi*2;
d=bnot(equal(pt,1));
pt=pt+1;
x=cos(r)*d*0.5;
y=sin(r)*d*af*0.5;
red=bnot(equal(pt,4));green=red;blue=red
That how i would do it.
Feel free to ask anything about it.
Jaak
11th December 2003 19:13 UTC
shame on you...
i like how you made it out of one ssc :P
[edit]
woops... made bit niftier ssc:
init:
n=100;
accuracy=10;
pi=acos(-1);
frame:
p=0;
asp=w/h;
degrees=degrees*.95+be*.05;
degrees=sign(degrees)*((abs(degrees)*accuracy)%(360*accuracy))/accuracy;
rad=degrees*(pi/180);
beat:
be=2*(rand(360)-180)
point:
p=p+1;
ok=bnot((bor(equal(p,1),equal(p,n))));
j=(p-2)/(n-3);
r=j*rad;
d=.5*ok;
x=cos(r)*d;
y=sin(r)*d*asp
try setting accuracy to 0.1, 0.5 or something like this
cmountford
12th December 2003 01:36 UTC
whoa...okay...I'll just ignore the full blown SSC code until I first try the suggestions in sid's first reply
Many thanks for the help---I'm sure it will be useful though I don't have time to work on it right now.
[edit]: I took a look at one of the codes posted, but wouldn't you want to have some statement that makes degrees actually be value it's supposed to be instead of the negative?
What I tried is putting a statement in Per Frame that says signdeg=-deg
then you substitute signdeg for wherever its value would be used in computation---namely, on beat: radb=2*signdeg*pi/180;
This is assuming I chose not to use the random degree generator so it allowed for user input:
Init: deg=___ (whatever degree you want)
Jaak
12th December 2003 05:35 UTC
if you mean this peace of code:
degrees=sign(degrees)*((abs(degrees)*accuracy)%(360*accuracy))/accuracy;
you can delete this peace of code, but what will happen, if angle goes above 360 degrees or below -360 degrees? Try it out ;)
you can also delete the accuracy, coz its only good to store few decimals, if i would only use the %360 the accuracy would be low, and its cool playing with this varjable.
and why is this sign(degrees)*blablabla
also easy, % statement doesnt work on negative numbers, then i just take the abs(degrees) and then do the %. but laiter i must check when is degrees positive or negativen, thats why I do sign(degrees)
[edit]
I took a look at one of the codes posted, but wouldn't you want to have some statement that makes degrees actually be value it's supposed to be instead of the negative?
d'oh i get it now...
in AVS the Y axis is inverted, thats why it seems the angle is not right.... but its 100% correct... i hope :p
to fix it, just do
y=-sin(r)*d;
If you want to use degrees in init, then delete
degrees=degrees*.95+be*.05; and
be=rand(720)-360;
then you xcan easily use degrees=somenumber; in init
cmountford
12th December 2003 07:19 UTC
That would do the same, I believe as my making the degrees negative in this case...but in this particular project, what realistic differences would the two methods of correcting for the incorrect orientation on y axis? My tweak seemed to fix it in this case, and I'm aware other things would need to be changed in other situations.
sidd
13th December 2003 11:35 UTC
oh.. i see what you mean. Yeah, thats jsut because avs works in pixel order, so x goes -1>1 left to right and y goes -1>1 top to bottom.
If you wanted, you could flip the entire scope by putting in y=-y as your last line, that should fix everything up to be "normal" mathy like.