Old 20th October 2003, 10:11   #161
sidd
Major Dude
 
sidd's Avatar
 
Join Date: May 2003
Location: Australia
Posts: 1,353
gaekwad2: what?
sidd is offline   Reply With Quote
Old 13th November 2003, 15:06   #162
OnionRingOfDoom
Member
 
OnionRingOfDoom's Avatar
 
Join Date: Nov 2003
Location: Brookly, NYC
Posts: 72
Send a message via AIM to OnionRingOfDoom
Is there any way I can use rand to generate a random number on each beat, andf be able to use the random numbers in two different scopes? IE,

-Scope 1:

beat:

q=(rand(21)-10)*0.01;

-Scope 2:

q=(random nubmer that was generated in scope 1.

Is this at all possible?
OnionRingOfDoom is offline   Reply With Quote
Old 13th November 2003, 15:16   #163
therealpw2
Junior Member
 
Join Date: Oct 2003
Posts: 3
yeah you can...

I'm not sure how to do it on pre-avs2.7 visualisations...but if you have avs2.7, I'm pretty sure you could just assign the random number to a reg##....eg:

beat (scope 1):

reg01=rand(100)/1000;

frame (scope 2):

x=reg01....or whatever you wanna do with it
therealpw2 is offline   Reply With Quote
Old 13th November 2003, 17:33   #164
OnionRingOfDoom
Member
 
OnionRingOfDoom's Avatar
 
Join Date: Nov 2003
Location: Brookly, NYC
Posts: 72
Send a message via AIM to OnionRingOfDoom
Wow, I didn't know 2.7 could do that! Anyway, I'm gonna stick to 2.5 till Winamp 5 gets offically released. Any other ideas?
OnionRingOfDoom is offline   Reply With Quote
Old 13th November 2003, 18:08   #165
gaekwad2
Foorum King
 
gaekwad2's Avatar
 
Join Date: Jul 2003
Location: bar2000
Posts: 11,352
search for "random", there's an explanation somewhere (I just can't remember where)

Last edited by gaekwad2; 13th November 2003 at 18:24.
gaekwad2 is offline   Reply With Quote
Old 13th November 2003, 20:08   #166
BigBob
Junior Member
 
Join Date: Jun 2003
Location: Washington, PA
Posts: 26
While your using AVS 2.5 you could use an almost fake number generator.

(getosc(0.47,0,0)*8753%100)/500-0.1 - This function will take the sound value and do some modulos division to give you a random number.
Atero showed me this, and its very helpful when you want to syhcnronize ssc or dms.
BigBob is offline   Reply With Quote
Old 13th November 2003, 21:10   #167
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
real hue mod:
red=abs(asin(sin(-hue)))/$pi*4-0.333;
green=abs(asin(sin(-hue+$pi*0.333)))/$pi*4-0.333;
blue=abs(asin(sin(-hue-$pi*0.333)))/$pi*4-0.333;
hue is 0..2pi

i'm not sure about sat and lum yet, anyone care to experiment with this?

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 13th November 2003, 21:56   #168
UIUC85
Senior Member
 
UIUC85's Avatar
 
Join Date: Oct 2003
Posts: 272
I've used sine waves to create hue but then you get large portions that are red, green, or blue... I've also done it with straight interpolation where the values change like this:

Red:
¯\__/¯

Green:
/¯¯\__

Blue:
__/¯¯\


As far as lumination goes, you interpolate all the values from (0,0,0) or black, up to the values of your main color, say (1,1,0), and then interpolate the remains up to (1,1,1) or white.

For saturation you interpolate your color down to (.5,.5,.5) or gray. I haven't really seen any set rules on how to change colors or anything but this is what I've gathered from the palettes they use in photoshop to let you pick colors. Obviously you can add a lot more to these if you want.
UIUC85 is offline   Reply With Quote
Old 14th November 2003, 03:26   #169
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
yar!

hue:
red=min(max(abs(asin(cos(-hue)))/$pi*4-0.333,0),1);
green=min(max(abs(asin(cos(-hue+$pi*0.333)))/$pi*4-0.333,0),1);
blue=min(max(abs(asin(cos(-hue-$pi*0.333)))/$pi*4-0.333,0),1);
sat:
red=red*sat+0.5*(1-sat); blue=blue*sat+0.5*(1-sat); green=green*sat+0.5*(1-sat);
lum:
red=red*min(lum,1-lum)*2+(lum-0.5)*2*above(lum,0.5);
blue=blue*min(lum,1-lum)*2+(lum-0.5)*2*above(lum,0.5);
green=green*min(lum,1-lum)*2+(lum-0.5)*2*above(lum,0.5);

has to be done in that order or else things go fuxery. hue=0..2pi, lum/sat=0..1.

could be sped up/simplified, but i'm too lazy right now....

<edit> fixed the hue filter, before it was -pi..pi

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 14th November 2003, 03:48   #170
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
i made a demonstration preset...forgot to attach it :F

(nPostCount+=1)
Attached Files
File Type: zip atero - hsl.zip (609 Bytes, 752 views)

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 14th November 2003, 04:07   #171
UIUC85
Senior Member
 
UIUC85's Avatar
 
Join Date: Oct 2003
Posts: 272
You mind explaining all that junk? It seems rather excessive to me...
UIUC85 is offline   Reply With Quote
Old 14th November 2003, 08:15   #172
gaekwad2
Foorum King
 
gaekwad2's Avatar
 
Join Date: Jul 2003
Location: bar2000
Posts: 11,352
Apparently there are 2 types of HSL color spaces. Atero's is used by eg Windows whereas eg Gimp uses a different HSV scheme that can be calculated this way:
red=(min(max(abs(asin(cos(-hue)))/$pi*4-0.333,0),1)*sat+1-sat)*lum;
green=(min(max(abs(asin(cos(-hue+$pi*0.333)))/$pi*4-0.333,0),1)*sat+1-sat)*lum;
blue=(min(max(abs(asin(cos(-hue-$pi*0.333)))/$pi*4-0.333,0),1)*sat+1-sat)*lum;
Attached Files
File Type: zip atero_hsl_(gimp_hsv_version).zip (605 Bytes, 789 views)
gaekwad2 is offline   Reply With Quote
Old 15th November 2003, 06:00   #173
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
yarhar!

i fixed the hue thing again. befoe it wasn't scaled right.
red=min(max(abs(asin(cos(-hue)))/$pi*6-1,0),1);
green=min(max(abs(asin(cos(-hue+$pi*0.333)))/$pi*6-1,0),1);
blue=min(max(abs(asin(cos(-hue-$pi*0.333)))/$pi*6-1,0),1);


<edit> i THINK this is the last fix. the hue setting on the luminosity bar wasn't right.
Attached Files
File Type: zip atero - hsl.zip (605 Bytes, 787 views)

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings

Last edited by dirkdeftly; 15th November 2003 at 06:24.
dirkdeftly is offline   Reply With Quote
Old 7th December 2003, 22:33   #174
fragmer
Senior Member
 
fragmer's Avatar
 
Join Date: May 2003
Posts: 101
My particle
code:

>>>>>> ini:
xd=reg00;yd=reg01;xx=rand(50)/100;
yy=rand(50)/100;xa=xx;ya=yy;
sigx=1;sigy=1;n=2;
ff=if(exy,.99-(rand(10)+1)/100,ff);

>>>>>> per-frame:
// render
x=xp;
y=yp;
red=abs(xa)*10;
green=red*.5;
blue=0;
// movement delay
xa=if(exy,xx,if(i,xa,xa*ff));
ya=if(exy,yy,if(i,ya,ya*ff));
// offset
xp=xd+(yy-ya)*sigx;
yp=yd+(xx-xa)*sigy;
// reset
exy=below(xa,.01);
// start
xd=if(exy,reg00,xd);
yd=if(exy,reg01,yd);
// end
xx=if(exy,rand(50)/100,xx);
yy=if(exy,rand(50)/100,yy);
// speed
ff=if(exy,.99-(rand(10)+1)/100,ff);
// direction
sigx=if(exy,above(rand(10),5)*2-1,sigx);
sigy=if(exy,above(rand(10),5)*2-1,sigy);


Make a texer2 like this with a faded particle image between 50x50 and 65x65.
Now copy this Texer2 ~20-30 times, make a couple with smaller images, and you have a firewerk-style!

Than change reg00 and reg01 (better from SSC with n=0) to move the source of particles!

[edit] plese do not use in your pack *directly this piece of code*, I'll be using it in BuggyAVS-2 . Get the idea and make your own [/edit]
Attached Files
File Type: zip avs.zip (7.9 KB, 779 views)
fragmer is offline   Reply With Quote
Old 28th December 2003, 19:46   #175
eXp - Returned
Junior Member
 
Join Date: Dec 2003
Location: Hungary
Posts: 7
Send a message via ICQ to eXp - Returned Send a message via AIM to eXp - Returned Send a message via Yahoo to eXp - Returned
CHESS

I can make my fastest chess!
My old chess is slow, because it was an superscope with w*2 points...

...but now it have two movements, and two points.
Attached Files
File Type: zip chess.zip (284 Bytes, 828 views)
eXp - Returned is offline   Reply With Quote
Old 2nd January 2004, 02:03   #176
fragmer
Senior Member
 
fragmer's Avatar
 
Join Date: May 2003
Posts: 101
oh, and one more, related to 2.8 now:

if you want to switch enable/disable effectlist on mouse click, use this code:
code:
o=m;m=getkbmouse(3);
e=if(m&bnot(equal(o,m)),bnot(e),e);
enabled=e;


...this way even if a user holds a mousebutton down for many frames, the enable state won't change until next click.
fragmer is offline   Reply With Quote
Old 7th January 2004, 10:22   #177
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,047
Want to know the exact value of a "random" number?
The new text offers to write reg## numbers!

example:

SSC:
code:

init:
n=2;
frame:
t=t+$pi*.01;
st=sin(t);
reg01=st;
point:
x=i*2-1;
y=st;


Text:
code:

ypos= $(reg01)

Attached Files
File Type: zip ssc-text reg.zip (293 Bytes, 770 views)

Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever
Warrior of the Light is offline   Reply With Quote
Old 17th January 2004, 10:51   #178
shreyas_potnis
Major Dude
 
shreyas_potnis's Avatar
 
Join Date: Jan 2003
Location: Mumbai, India
Posts: 787
Hey, if you want the number of seconds elapsed after starting the AVS preset, use:
init:
sec=gettime(0);
frame:
t=gettime(sec);

http://home.iitb.ac*****~shreyaspotnis
shreyas_potnis is offline   Reply With Quote
Old 17th January 2004, 20:04   #179
Nic01
Major Dude
 
Nic01's Avatar
 
Join Date: Mar 2002
Location: The Biggest Little City
Posts: 508
Send a message via AIM to Nic01
A guide to Cubic Ligation

For this, d/l the attached file (Cubic Ligation) (It also includes the txt file)
it is NOT the same thing as the one in the forums. do NOT replace.

Prerequisite knowledge : SSC knowledge, 3D SSC knowledge, global variables.

CL is mostly a technical doodle for me, but hey, it turned out sexah :P
It only has two distinct scopes, an assigner and many drones.
By a little coding "magic" I was able to make the cube configure itself when more drones are added... nifty huh?
For tutoring purposes, I will assume that you know the "old" avs functions but has no idea on the new stuffs [namely loop(, gmegabuf(, assign(, and exec3(] Unlikely, but ah well. Read and learn. (please? :P)

/////----------\\\\\

First, the drones (or mindless cubes in this matter). They're any of the scopes after the comment inside the list.

The init only has the n value and a remnant from my SSC template (namely pi=acos(-1). Never deleted that for some reason...). The point part only describes the cube, rotations, and using skip for unnecessant points instead of simple blacking out. Nifty to me, but not sure about you - We won't go into that, but tell me if you think I should...

Anyways, on to the important stuff - The Frame section.
For flexibility, all of the scopes are the same, and yet they correctly fade and resize according to their number. This, people, is the one of the useful uses of global variables.
reg00 is a counter, going by 10s. The first drone increases reg00 by 10 once, so reg00 is 10 for that scope. The second scope adds another 10, so reg00 is 20 for that scope. Once reg00 reaches the last scope, it will pass through the assigner scope again. The assigner does some stuffs with the value and resets reg00 to zero and the cycle starts again. It works like a p-counter in a scope if you've done p2p coding before.

Next is r. It's just the size of the scope - It's simply the counter times "dif" (more on that when we get to the assigner). This is how the scope adjusts itself to the crowd sizewise
Then there's c1. It creates the bw gradient from the first to last. What is reg08, you ask? It is only the final value of reg00 before it is reset. This way, you can get the upper bound of reg00 and a correct gradient can be made.

After that is the recall from the global array (gmegabuf). The assigned value counts down instead of counting up, more on that on the assigner section.
So why was the counting done in tens? Well, for easy recalling. The recalled variable is simply the max number minus the current number plus another number. since the former two are counted in tens, there are 10 possible subvalues for each number. The third number is the subvalue number. x-rotation is 1, y-rotation is 2, z-rotation is 3. Quite a bit easier to code than to have clusters dedicated to each rotation to me
There's also subvalue #6 in the c1 line - It's the onbeat whiting. Now go back to the point section. Scroll all the way down. As you can see, there's another gmegabuf section. The x-movement is subvalue #4, and the y-movement is subvalue #5.

After the gmegabuf(s, there's the rotation sines and cosines and the rgb assignment. If you need any tutoring there, you're looking at the wrong place.

So how does the delay effect happen? That's next, in the assigner.

(end drone section)

///-------\\\

Second, the (pretty huge) [and halfway 1337] assigner. It's the very first scope, if you don't know which one it is.

First thing that you get to see is what most people are meant to see - dif, the distance variable, and reg51, the aspect ratio. Nothing amazing there.

Now scroll down past the first comment block, down to reg01. If reg01 is now in the topmost line, you should be able to see the assigns.
This set of assigns (and any further ones that begin a line) are the initial settings of the rotations. The leader cube (smallest, right after the comment) gets to use this value directly.


Next, scroll until the first loop( is at top.
This is the heart of the delay effect (as are the later loops). This follows p2p assigning quite closely. First, there's reg00 as the amount of times it is repeated. A bit of an overkill, but I don't care :P (Seriously though, if you're using loop yourself, use the amount of loops needed plus one just in case. don't be wasteful and lazy like me. please?)
After the amount of loops, there's the exec3. I know that the help file only shows exec2, but exec3 exists. It's a bit like exec2 except that it executes two things before returning the value (of the third stuff).
First is the p-counter, assigned using - surprise surprise - assign(. Just think of the comma as an equal sign.
Second is the delay effect. It takes a certain part of an array and assigns to it the part of the array ten "steps" forward. (one step if you count the units as a subvalue like me). Because the assignment "sweeps" from zero up, the nth unit before the assigned unit needs n passes to be assigned. Since this is calculated per frame, it also takes n frames to be assigned, and so we have our delay effect. Gotta love niftiness.

A couple lines down is another assigner for x-y movement, then onbeat lighting.
You may notice by now the repeated p=0. Well, p is set to a much higher number at the end of each loop, so it needs to be reset.
Last is a familiar sight - reg00 and reg08/9. As you can see, reg08 is set to reg00 right before reg00 is reset to 0.

There's the onBeat, nothing special there.

//////

And that's... it I guess.
Implement as you will, no direct ripping thank you. Coin me too

Challenge : Fix the delayed start if you wish. It's fixed in the final version
Attached Files
File Type: zip nic01 - cubic ligation.zip (3.7 KB, 736 views)

[soon to leave, sirs]
Nic01 is offline   Reply With Quote
Old 22nd January 2004, 04:46   #180
sidd
Major Dude
 
sidd's Avatar
 
Join Date: May 2003
Location: Australia
Posts: 1,353
Nice work!
Very efficiently coded.

Thanks for the tut nic
sidd is offline   Reply With Quote
Old 30th January 2004, 04:37   #181
Timzone8
Major Dude
 
Timzone8's Avatar
 
Join Date: Sep 2003
Location: Australia
Posts: 569
Send a message via ICQ to Timzone8 Send a message via AIM to Timzone8 Send a message via Yahoo to Timzone8
I too would like a few pointers (not to search the forum) on how to make squares and circles with SSC...ne?
Timzone8 is offline   Reply With Quote
Old 30th January 2004, 05:57   #182
UIUC85
Senior Member
 
UIUC85's Avatar
 
Join Date: Oct 2003
Posts: 272
a=2*$pi*i;
r=1;
x=r*cos(a);
y=r*sin(a);

that'll give you a circle of radius 1.

n=5;
--------------
a=2*$pi*i+$pi/4;
r=1;
x=r*cos(a);
y=r*sin(a);

little change but that'll get you a square in one scope.
Just trig.
UIUC85 is offline   Reply With Quote
Old 30th January 2004, 22:46   #183
Nic01
Major Dude
 
Nic01's Avatar
 
Join Date: Mar 2002
Location: The Biggest Little City
Posts: 508
Send a message via AIM to Nic01
A better square (in some aspects):

r=i*$pi*2;
d=1/abs(cos(asin(sin(r*2))*0.5));
x=sin(r+rot)*d+movex;
y=cos(r+rot)*d+movey;

[soon to leave, sirs]
Nic01 is offline   Reply With Quote
Old 13th February 2004, 22:04   #184
Raz
Forum King
 
Raz's Avatar
 
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
Is using two buffers faster than using an effect list?

Raz is offline   Reply With Quote
Old 13th February 2004, 22:42   #185
Raz
Forum King
 
Raz's Avatar
 
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
by the way, it's for this particularly slow nightmarish thing.
Attached Files
File Type: zip raz - 01.zip (1.0 KB, 812 views)

Raz is offline   Reply With Quote
Old 23rd February 2004, 08:48   #186
VisualAgnosia
Senior Member
 
VisualAgnosia's Avatar
 
Join Date: Nov 2002
Location: Australia
Posts: 190
<Image removed due to size. the content was also not very appropriate, even if it was intended as a joke.
- UnConeD>

Last edited by VisualAgnosia; 23rd February 2004 at 09:07.
VisualAgnosia is offline   Reply With Quote
Old 24th February 2004, 17:19   #187
zamuz
Senior Member
 
zamuz's Avatar
 
Join Date: Nov 2002
Location: santiago, chile
Posts: 152
little question: how can i have an effect list enabled only for a certain amount of frames?
zamuz is offline   Reply With Quote
Old 24th February 2004, 17:29   #188
UIUC85
Senior Member
 
UIUC85's Avatar
 
Join Date: Oct 2003
Posts: 272
use the override feature.
UIUC85 is offline   Reply With Quote
Old 24th February 2004, 18:09   #189
zamuz
Senior Member
 
zamuz's Avatar
 
Join Date: Nov 2002
Location: santiago, chile
Posts: 152
yeah i thought about that too, but any hits on how to code it? i know it's probably easy, but everything i tried didn't work.
zamuz is offline   Reply With Quote
Old 24th February 2004, 18:40   #190
UIUC85
Senior Member
 
UIUC85's Avatar
 
Join Date: Oct 2003
Posts: 272
int:
x=# of frames you want to run it for;

frame:
enabled=if(above(x,0),1,0);
x=x-1;
UIUC85 is offline   Reply With Quote
Old 24th February 2004, 20:45   #191
zamuz
Senior Member
 
zamuz's Avatar
 
Join Date: Nov 2002
Location: santiago, chile
Posts: 152
thanks a lot there
zamuz is offline   Reply With Quote
Old 2nd March 2004, 21:44   #192
fragmer
Senior Member
 
fragmer's Avatar
 
Join Date: May 2003
Posts: 101
what about just
enabled=above(x,0);
Actualy I like version with the smooth alpha fadeout:
code:
-- ini:
s=2;
-- frame:
alphaout=s;
enabled=above(s,0);
s=s-.1;


...where s is (numberofframes+10)/10
Set outpput blend to adjustable for this one
fragmer is offline   Reply With Quote
Old 16th March 2004, 04:32   #193
jheriko
Forum King
 
jheriko's Avatar
 
Join Date: Aug 2002
Location: a twist in the fabric of space
Posts: 2,149
Send a message via ICQ to jheriko
In response to the post about 'making squares and circles' I thought I'd write a little something about creating geometry in general, with some example code of course.

For a start I'll quickly cover the 'point to point' method of creating a wireframe object. The idea is one that I've been using since I came into AVS (remember that dodecahedron anyone?) The basic idea is that you increment a counter every time you draw a point and then use this value with conditional structures to decide what should be drawn for each individual point. Example:

(Lines SSC)

init:
// Square
n=5;

frame:
// Set our point counter to 0
counter = 0;

// Calculate aspect ratio of AVS display (unimportant)
aspectratio = h/w;

beat:
<nothing>

point:
/*
Basically for each point we want to draw we have a section
in this big expresion for x (and also in the later y expression).
For example, when the first point is drawn counter = 0 so the
'first line' sets x = 1 when counter = 0 since 1 is the x coord of
our desired first point for the square. This is repeated for every
possible value of counter until all of the required x-coords have
been assigned. Since nothing is done if counter != 0 for the
'first line' we can add the subsequent expressions without
affecting any of the other points.
*/

x = 1 * equal(counter,0)
+ 1 * equal(counter,1)
+ -1 * equal(counter,2)
+ -1 * equal(counter,3)
+ 1 * equal(counter,4);

y = -1 * equal(counter,0)
+ 1 * equal(counter,1)
+ 1 * equal(counter,2)
+ -1 * equal(counter,3)
+ -1 * equal(counter,4);

// Scale the square so we can see the top and bottom edges (unimportant)
x=x*.5;y=y*.5;

// Increment the point counter
counter = counter + 1;

// Correct aspect ratio (unimportant)
x = x* aspectratio;

(End SSC)

Note that 5 points are used since AVS needs two points to draw a line so the first line goes from counter=0 to counter=1, the second from counter=1 to counter=2, the third from counter=2 to counter=3 and the final one from counter=3 to counter=4 (which is the same as counter=0 for all intents and purposes). You can optimise and tidy this up a lot, I just made a big mess to make everything as clear as possible.

This method is great for a lot of objects and can be extended to 3D wireframes pretty easily (see 'Golden Dodecahedron' from Jheriko - Pack VI for an example of this done with a slightly different implementation (ifs instead of equals)). However we can't draw a circle from it or a sphere either.

When you want to draw curved surfaces in AVS you have to use some maths and typically this can be difficult if you don't already know the answer. Most of us for instance know that x=sin(2*$PI*i);y=cos(2*$PI*i); creates a circle.. but why does this work? Well, you can get this from experimentation (which is how I first figured this out when I started at qbasic.. guesswork) but a much better way is logic. There is no generic way to get an equation for a shape, however some common sense and a good knowledge of maths will help a lot. For instance I can say that

x=sin(t), y=cos(t)

is clearly a circle due to the trig identity

sin(t)^2 + cos(t)^2 = 1

so the hypotenuse of the triangle made by the points (0,0) (x,0) (x,y) is always going to be 1 (draw a diagram if you can't see this), and so this hypotenuse is always going to be the radius of a unit circle about the origin. Make sense?

Lets assume for a moment that we have no idea about how to make a sphere. It would seem logical that we can somehow extend the circle definition into three dimensions to get a sphere. This infact can be done by using the sin(t)^2+cos(t)^2=1 identity.


sin(t)^2 + cos(t)^2 = 1
sin(u)^2 + cos(u)^2 = 1

multiplying these together gives us something which still = 1

sin(t)^2 sin(u)^2 + cos(t)^2 sin(u)^2 + sin(t)^2 cos(u)^2 + cos(t)^2 cos(u)^2 = 1

However this has four 'components' so we must eliminate one of them to get something we can equivalate to the x^2+y^2+z^2=1 which defines a unit sphere.

Noting that sin(t)^2 + cos(t)^2 = 1 and combining the last two 'components' together:

sin(t)^2 sin(u)^2 + cos(t)^2 sin(u)^2 + (sin(t)^2 + cos(t)^2)cos(u)^2 = 1

sin(t)^2 sin(u)^2 + cos(t)^2 sin(u)^2 + cos(u)^2 = 1

taking each of these components and equivalating them to x^2+y^2+z^2=1 we get

x=sin(t)sin(u);
y=cos(t)cos(u);
z=cos(u);

The actual definitions of t and u in code will affect which points are drawn and a simple relation like t=2*u will create a specific curve which looks little like a sphere, using something like t=200*u will create a 'spiral sphere' type shape.

When trying to make a specific shape when you can't find an equation for it the best approach is to start with what you know about that shape and then exploit that with your mathematical knowledge to create a parameterisation. Another good example would be a torus. The idea I used to make 'Space Torus' in Jheriko - Pack VIII was simply to define a circle with the torus minor radius and shift it along an axis by the major radius then to perform a matrix rotation on this to 'sweep out' a torus. All I had to do was use the appropriate rotation matrix out of the 3D transformation from the SSC to multiply with the existing offset circle definition then to use a second parameter to tell it how much to rotate by rather than using a fixed value every frame.

Often once you have found a basic shape that works you can modify it too. Playing around with an equation can create interesting effects, sometimes some logical thought process can help here too, for instance the method I described for the torus above can be easily extended to create other shapes by using different rotations or initial shapes, these shapes will often be a lot more interesting because you decided to try it out for some reason... rather than just blundering upon it by random code changes.

Remember that figuring something out for yourself will often give you a much deeper understanding of it than just 'learning it from a book'.

If you find it really difficult to come up with your own shapes, or to convert your knowledge of a shape into code, then take a look around the internet on math resourse sites and such, you are bound to find some interesting parametric shapes eventually.

Hope this helps someone out.

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 10th April 2004, 04:53   #194
D12
Banned
 
D12's Avatar
 
Join Date: Apr 2004
Location: Blood
Posts: 42
Send a message via ICQ to D12 Send a message via AIM to D12 Send a message via Yahoo to D12
I learned creating AVS from Tips&Tricks.Thanks
D12 is offline   Reply With Quote
Old 29th April 2004, 03:22   #195
Nic01
Major Dude
 
Nic01's Avatar
 
Join Date: Mar 2002
Location: The Biggest Little City
Posts: 508
Send a message via AIM to Nic01
Fastest rectangle similiar to the window, ready to be scaled (maybe rotated) :

INIT: n=5
FRAME: p=0;
PIXEL:
p=p+1;
x=(p-1)&2-1;
y=p&2-1;
linesize=a;
[aspect ratio]
[rotation]

...Where a is the pixel size that you wish.
(Consider multiplying both x and y by 1-{1/[h or w, accordingly]} so that the pixel difference between the top-left and bottom-right is nulled.)

[soon to leave, sirs]
Nic01 is offline   Reply With Quote
Old 29th April 2004, 18:44   #196
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
you forgot some brackets there
and it can still be optimized
x=(p&2)-1;
p=p+1;
y=(p&2)-1;

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 15th May 2004, 07:09   #197
khaalid
Junior Member
 
Join Date: May 2004
Location: south africa
Posts: 3
thanx man
khaalid is offline   Reply With Quote
Old 27th May 2004, 12:45   #198
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
code:

// SuperScope:
// Frame:
x1=-.5; y1=-.5;
x2=.8; y2=-.3;
x3=.1; y3=.6;
n=w+h;
t=gettime(0);

facx1=x2-x1; facy1=y2-y1;
facx2=x3-x2; facy2=y3-y2;
facx3=x1-x3; facy3=y1-y3;


// Point:
i1=i*3; i2=i1-1; i3=i1-2;
i1=min(1,max(0,i1)); i2=min(1,max(0,i2)); i3=min(1,max(0,i3));
x=x1 + i1*facx1 + i2*facx2 + i3*facx3;
y=y1 + i1*facy1 + i2*facy2 + i3*facy3;
red=sin(i*80+t*10)/2+.5;
green=1-red;
blue=red;


this generates a fancy colorcycling triangle without any ifs or equals

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 1st June 2004, 21:36   #199
AvsManDan
Junior Member
 
Join Date: May 2004
Posts: 24
http://functions.wolfram.com/

Just found this. Might be helpful.
AvsManDan is offline   Reply With Quote
Old 2nd June 2004, 23:19   #200
AvsManDan
Junior Member
 
Join Date: May 2004
Posts: 24
Someone might find it useful. Anyone?
AvsManDan is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Visualizations > AVS

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump