Old 7th June 2005, 09:01   #241
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
3 planar rotations are what you might call "3D rotation"

btw you could cache the cosines and sines for optimization, since (co)sine is a very expensive operation

look at that other thread you opened for info on how to optimize the divisions

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 1st April 2006, 15:23   #242
The Earthquaker
Member
 
The Earthquaker's Avatar
 
Join Date: Jan 2006
Location: Environment
Posts: 87
A surrealistic thing: this looks like a star.

init
n=k0*600; tpi=2*acos(-1);

point
d=k1*v+i*tpi; x=x0+pow(cos(d),3)*kx; y=y0+pow(sin(d),3)*ky;

k0, k1, kx, ky, x0, y0 are optional values, they equal to 0 (x0, y0) or 1 (k) by default;

If this is well-known, I post it for reference.
This is a bit oldschool, isn't it?
Thanks
The Earthquaker is offline   Reply With Quote
Old 2nd April 2006, 18:56   #243
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
a bit misplaced maybe, since this is about tips&tricks and not about specific scopes

things like rotation are used in many presets and in many different scopes, texers, DMs and whatnot

in other words: rotation is part of the basics. your scope is not

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 2nd April 2006, 19:02   #244
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
Quote:
Originally posted by UIUC85
int:
x=# of frames you want to run it for;

frame:
enabled=if(above(x,0),1,0);
x=x-1;

dont write things like if(boolean expression,1,0)
the if there is superfluous, since above returns 1 for true and 0 for false (as documented)

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 3rd April 2006, 00:02   #245
StevenRoy
Senior Member
 
StevenRoy's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 129
Send a message via ICQ to StevenRoy Send a message via AIM to StevenRoy
Quote:
Originally posted by Warrior of the Light
Triangular wave for an SSC:

code:
x=i*2-1;
y=asin(sin(i*$pi*2))/asin(1);

Sorry, but I just can't ignore that ugliness anymore. Here, try this instead:
code:
x=i*2-1;
ii=i-.25;
y=abs((ii-floor(ii))*2-1)*2-1;

There. Thank goodness for the floor() function!
StevenRoy is offline   Reply With Quote
Old 24th April 2006, 13:27   #246
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
Raytracing...

I keep teaching people how to raytrace... so this time I made a half decent resource:

http://tutorials.jheriko.kicks-ass.net/

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 3rd May 2006, 08:00   #247
The Earthquaker
Member
 
The Earthquaker's Avatar
 
Join Date: Jan 2006
Location: Environment
Posts: 87
I need an advice on time-based evaluation.

eg set=rand(n) is evaluated approx. every 5 seconds.
m1=equal(set,1);
m2=equal(set,2);... go on after 'set' changes.

I used to make expressions like

change=bor(below(t*k-floor(t*k),deltat*0.5),above(t*k-floor(t*k),1-deltat*0.5));

with t*k-floor(t*k)(main expression), deltat*0.5 cached at the beginning, in timer based on expression timer=t*k-floor(t*k).

It works, but is too approximate, even more: this timer automates one variable, and cannot randomize.

And it seems the best solution is to work on custom BPM:
Skip 7 beats.
The Earthquaker is offline   Reply With Quote
Old 3rd May 2006, 08:48   #248
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
yay random code for the win

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 3rd May 2006, 14:40   #249
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
Quote:
Originally posted by The Earthquaker
I need an advice on time-based evaluation.

eg set=rand(n) is evaluated approx. every 5 seconds.
m1=equal(set,1);
m2=equal(set,2);... go on after 'set' changes.

I used to make expressions like

change=bor(below(t*k-floor(t*k),deltat*0.5),above(t*k-floor(t*k),1-deltat*0.5));

with t*k-floor(t*k)(main expression), deltat*0.5 cached at the beginning, in timer based on expression timer=t*k-floor(t*k).

It works, but is too approximate, even more: this timer automates one variable, and cannot randomize.

And it seems the best solution is to work on custom BPM:
Skip 7 beats.

its like three totally disconnected statements glued together...

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 3rd May 2006, 15:05   #250
Tuggummi
Bin King
 
Tuggummi's Avatar
 
Join Date: Mar 2001
Location: Finland
Posts: 2,173
Wow, when i made this long-long time ago i thought this would bring all neat or often used tricks and whatnot together to a nice package, but now it seems that this is more cluttered than the AVS forums itself

In short, this thread makes little sense anymore

Texer Resources

Im retarded... err i mean retired!
Probably both...
Tuggummi is offline   Reply With Quote
Old 3rd May 2006, 21:19   #251
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,047
it needs a refresh indeed.. .pdf anyone?

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 3rd May 2006, 22:55   #252
fastingaciu
Major Dude
 
fastingaciu's Avatar
 
Join Date: Dec 2005
Location: Canada
Posts: 940
Question: How do you get the liquid effect using a dm?

Those who can do, do; those who can't do, teach.
fastingaciu is offline   Reply With Quote
Old 4th May 2006, 05:59   #253
The Earthquaker
Member
 
The Earthquaker's Avatar
 
Join Date: Jan 2006
Location: Environment
Posts: 87
Quote:
Originally posted by The Earthquaker
I need an advice on time-based evaluation.

...

And it seems the best solution is to work on custom BPM:
Skip 7 beats.
I want to apologize for that though I thought I make a post with intro and outro.

The stuff that is sandwiched beetween is what I meant a general question.
The Earthquaker is offline   Reply With Quote
Old 12th May 2006, 23:50   #254
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
Quote:
Originally posted by The Earthquaker
I want to apologize for that though I thought I make a post with intro and outro.

The stuff that is sandwiched beetween is what I meant a general question.
i still didnt get the idea. there is gettime() if you want something to be dependent on a timer...

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 21st June 2006, 03:09   #255
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
eeltrans macros for HSL -> RGB conversion:
Quote:
// --- HSL ---
// converts from HSL color space to RGB color space
#define HSL2RGB(H,S,L,R,G,B) (var_2=if(below(L,.5),L * ( 1 + S ),( L + S ) - ( S * L ));var_1=2 * L - var_2;R=Hue_2_RGB(var_1,var_2,H+third);G=Hue_2_RGB(var_1,var_2,H);B=Hue_2_RGB(var_1,var_2,H-third))

// initialization macro for HSL2RGB
#define init_HSL2RGB() third=1/3;

// helper macro for HSL2RGB - needs wrap()
#define Hue_2_RGB(v1,v2,invH) (vH=invH;wrap(vH, 0, 1, 1); v6H=6*vH; if(below(v6H, 1), v1+(v2-v1)*v6H, if(below(2*vH, 1), v2, if(below(3*vH, 2), v1+(v2-v1)*(4-v6H), v1))))

// wraps a value between minval and maxval. range should be (maxval-minval)
#define wrap(var,minval,maxval,range) if(below(var,minval),var=var+range,if(above(var,maxval),var=var-range,0));
Usage:
code:
hue=.3;
sat=1;
lum=.5;
HSL2RGB(hue,sat,lum,red,green,blue);


If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 13th July 2006, 06:36   #256
The Earthquaker
Member
 
The Earthquaker's Avatar
 
Join Date: Jan 2006
Location: Environment
Posts: 87
Anybody could they say why the code is so unefficient...
Its purpose was to draw a border with length halfx*2, width halfy*2, and this code is supposed to be optimised. SuperScope, n=535.

//init
halfx=100; halfy=50; opts=0.5/(halfx+halfy); sqd=sqr(opts);
rej1=opts*halfx; rej2=opts*halfy;

//frame
rlw=halfx/w; rlh=halfy/h;

//point
x=if(above(i,rej1),if(above(i,0.5),if(above(i,0.5+rej1),-rlw,(i-0.5)*n*halfx*sqd*2-rlw),rlw),i*n*halfx*sqd*2-rlw);
y=if(above(i,rej1),if(above(i,0.5),if(above(i,0.5+rej1),(i+rej2-1)*n*halfy*sqd*4-rlh,rlh),(i-rej1)*n*halfy*sqd*4-rlh),-rlh);
The Earthquaker is offline   Reply With Quote
Old 13th July 2006, 20:00   #257
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
Quote:
Originally posted by The Earthquaker
Anybody could they say why the code is so unefficient...
I am going to start from the bottom up rather than the top down so that you can fully comprehend the totality of your failure.

1.) Cache some multiplies to remove per point muls:

//frame
rlw=halfx/w; rlh=halfy/h;
opt=2*n*sqd;

//point
x=if(above(i,rej1),if(above(i,0.5),if(above(i,0.5+rej1),-rlw,(i-0.5)*opt*halfx-rlw),rlw),i*opt*halfx-rlw);
y=if(above(i,rej1),if(above(i,0.5),if(above(i,0.5+rej1),(i+rej2-1)*opt*halfy*2-rlh,rlh),(i-rej1)*opt*halfy*2-rlh),-rlh);

2.) Don't use points to draw lines when there is a line tool available. The 'lines' superscope option enables a c++/asm line drawing routine, this is orders of magnitude faster than any evallib routine...

// innit
n=4;
halfx=100; halfy=50;

// frame
rlw=halfx/w; rlh=halfy/h;
c=0;

//point
x=if(c%2,rlw,-rlw);
y=if(above(c,1),rlh,-rlh);
c=c+1;

3.) Make it do what its supposed to, notice how the rectangle resizes in a crazy way when you resize the window, you need aspect ratio correction.

// innit
n=4;
halfx=100; halfy=50;

// frame
asp=h/w;
rlw=halfx/w;
rlh=halfy/h;
c=0;

//point
x=if(c%2,rlw,-rlw);
y=if(above(c,1),rlh,-rlh);
c=c+1;

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 14th July 2006, 18:42   #258
Red Mullet
Banned
 
Red Mullet's Avatar
 
Join Date: Jun 2006
Location: 439 East District, Mount Paozu
Posts: 57
Can I change thses values t=reg11;
e=equal(t,-1);
ym=if(e,(rand(20)-10)*-.1,ym);
xm=if(e,(rand(20)-10)*.1,xm);
reg22=ym;

to: g=abs(getosc(.7,.3,0));
s=if(above(g,s*.5),s+.03,s-.03);
ym=if(below(ym,-1),1,ym-.01);
xt1=xt1+.0277;
xb2=xb2*.98; xt2=xt2+xb2;

For getting trigonometry around together?
Red Mullet is offline   Reply With Quote
Old 17th July 2006, 07:06   #259
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
1. What the HELL is that?
2. trigonometry?
3. What the hell is THAT?
4. Did you read PAK-9's AVS Programming Guide?
5. What the hell IS that?
6. oh and btw, stealing code without crediting is BAAAAD, ok?

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 17th July 2006, 22:31   #260
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
Quote:
Originally posted by Red Mullet
For getting trigonometry around together?
They should put that on a t-shirt... seriously though, can we please refrain from asking random questions on this thread. I shouldn't have encouraged it by answering earthquaker's question. The forum is there for you to post new threads in for things like that.

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 18th July 2006, 08:37   #261
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
almost like those people who join help channels and then query the ops for help
or even worse, some even send channel notices...

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 9th August 2006, 20:49   #262
Nanakiwurkz
Senior Member
 
Nanakiwurkz's Avatar
 
Join Date: Apr 2006
Location: Planet Shintovia
Posts: 383
Help

I've been trying to make a set of code that detects a exact value and resets the variable to value i want. can that be done? its for a annoying dynamove i'm trying to stop from going to far with a zooming effect.

As far as idiots go i'm not sure.
But as far as genius goes again i'm not sure. Now when it comes to imagination now thats another story.
Nanakiwurkz is offline   Reply With Quote
Old 10th August 2006, 19:45   #263
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,047
You should know very well by now that this is not the idea of this thread.

Next time, create a new thread with what you have so far (no matter how little) instead.

but to answer your question and to get this over with:
code:
myvar=if(equal(myvar,value),resetvalue,myvar);


Since you don't want myvar to go to go over a specific value, you could also (or better) use above(a,b) instead of equal(a,b)

But all this are basic operations which you could easially have found yourself in the expression help.

Please don't reply here

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 8th February 2007, 21:04   #264
Nanakiwurkz
Senior Member
 
Nanakiwurkz's Avatar
 
Join Date: Apr 2006
Location: Planet Shintovia
Posts: 383
i'm looking for some useful tricks to making menus in avs.
also i'm very much wanting to know how to make global sliders and junk to control certain aspect of my presets.
anything would be nice.
and WoTL this does comply with the idea of this thread.

As far as idiots go i'm not sure.
But as far as genius goes again i'm not sure. Now when it comes to imagination now thats another story.
Nanakiwurkz is offline   Reply With Quote
Old 8th February 2007, 22:49   #265
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,047
This isn't a discussion thread, which means posting code only. (not requests)

See the attached file, some parts may be unoptimized
Attached Files
File Type: zip wotl - interactivity.zip (912 Bytes, 1033 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 11th February 2007, 14:28   #266
J.Melo
Senior Member
 
J.Melo's Avatar
 
Join Date: Oct 2006
Posts: 328
You can attempt to pull the menu out of this one. The slider is alot simpler.

Note: you need globmgr.ape (included).
Attached Files
File Type: zip jmelo - analyzation.zip (44.4 KB, 882 views)
J.Melo is offline   Reply With Quote
Old 3rd March 2007, 21:19   #267
Anjotedbas86
Banned
 
Join Date: Mar 2007
Posts: 1
*crap removed*
Anjotedbas86 is offline   Reply With Quote
Old 6th June 2007, 13:30   #268
Dfafd
Banned
 
Join Date: Jun 2007
Posts: 6
*crap removed*
Dfafd is offline   Reply With Quote
Old 25th November 2007, 23:41   #269
AJ Sindri
Junior Member
 
AJ Sindri's Avatar
 
Join Date: Nov 2007
Posts: 29
Converting Movement Equations Polar (r,d) to Parametric (x,y)

I've been working for sometime trying to change polar movement equations into parametric. After looking at a few presents, this is what I came up with:

midx=//x pole goes here;
midy=//y pole goes here;
r=atan2((x-midx),(y-midy));
rx=-cos(r);
ry=sin(r);
dx=sin(r);
dy=cos(r);
d=abs(sqrt(pow(y+midy,2)+pow(x+midx,2)))*2;

midx and midy are the x and y cordiants for the pole (equivilant to the origin in parametric), or the center of the polar equation.

r is the angle counterclockwise from the ray starting at the pole and extending right, and d is the distance from the pole.

rx,dx,ry,dy are the direction of the vector. The first letter is what type of direction (distance or radial) and the second letter is what variable goes under (rx would go under the x=, and dy would go under the y=, etc)

The Vector is comprised of a direction times the distance.

This all may be a bit confusing so here are some sample equations: (asume midx and midy equals 0)

CONVERTING:
r=r+.1;
d=d+.1;
TO
x=x+rx*.1+dx*.1;
y=y+ry*.1+dx*.1;

If you want to multiply a direction by the distance or angle use r or d:

CONVERTING:
r=r+.1/(d+.2);
TO
x=x+rx*.1/(d+.2);
y=y+ry*.1/(d+.2);

I like the equation but the converting process can get kind of annoying. feel free to use any of this and please comment!

A fun little program:
in the dynamic movements point box:

midx=getkbmouse(1);
midy=getkbmouse(2);
ang=atan2((x-midx),(y-midy));
rx=-cos(ang);
ry=sin(ang);
dx=sin(ang);
dy=cos(ang);
d=abs(sqrt(pow(y+midy,2)+pow(x+midx,2)))*2;
x=x+rx*.05/(d+.2)*sin(d*6)-dx*.05*sin(r*6);
y=y+ry*.05/(d+.2)*sin(d*6)-dy*.05*sin(r*6);

//move your mouse around and have fun!!
AJ Sindri is offline   Reply With Quote
Old 7th December 2007, 01:19   #270
Grandchild
Senior Member
 
Grandchild's Avatar
 
Join Date: Oct 2005
Location: Germany
Posts: 332
framerate-independent movement

there's been some discussion on and off about how to achieve framerate-independence for variables changing over time. with little result. so i finally sat down and calculated it all out. here's how it goes, a quick tutorial about how to make your SSCs, DMs, Triangles and TexerIIs move with the same speed regardless of the fps [frames per second] AVS runs with:

there's three different kinds of changing a variable's value over time that i use frequently. they are of the shape:
code:
x = x+m;
//linear movement

y = y*s; // with 0 < s < 1 constant
// y aproaches zero, like e.g. decreasing the effect of a beat-responsive value after a beat.

z = z-(z-zd)*s; ;-or-; z = z*(1-s)+zd*s; // with 0 < s < 1 const.
// both are the same and can be used interchangeably! i use the first one in general.
// here, zd is the 'target value' which is approached after time.


well looks good but these above depend on how fast your preset runs.
so the first thing you need to know is how fast your preset actually runs. you can calculate that by using:
code:
t = gettime(0); speed = t-old_t; old_t = t;

this gives you the inverted fps*, here called "speed".

i'll spare you the why's and how's and will just give you the equations. in the first one m is simply multiplied by 'speed' whereas in the other two cases you basically substitute s for a modified 'speed' value [which is the interesting part about this ].
code:
t = gettime(0); speed = t-old_t; old_t = t;
//linear:
x = x+m*speed; // you'll need a bigger m now!

//approaching zero:
speed2 = pow(s,speed*dfps);
y = y*speed2;

//approaching target value [or 'interpolation']:
speed3 = 1-pow(1-s,speed*dfps);
z = z-(z-zd)*speed3;
//or
speed3 = pow(1-s,speed*dfps);
z = z*speed3+zd*(1-speed3);

(1 <- that is a ONE btw. not L)


again s is a constant >0 and <1 which gives the speed of the change:
low s -> faster motion.
high s -> slower motion.
dfps is the desired or simulated framerate set by you. it's a constant, maybe 20 to 50. do not use the actual calculated fps!

have fun,
grandchild
_____________
*)
note that this will give you the raw, fluctuating fps, not the number shown in the editor or fullscreen. but this is usually sufficient to get a decent result. if you need something smoother, try the third equation from above [without fps-correction, mind you!]
...and if you should need it: the fps is now calculated with 1/speed.
Grandchild is offline   Reply With Quote
Old 20th May 2008, 07:02   #271
ok0510
Junior Member
 
Join Date: May 2008
Posts: 1
Re: Two questions...

Quote:
Originally posted by mikm
First order targeting is increasing a value by increments (speed), until it reaches target, right?
Buy Cheap World of Warcraft GoldWOW Goldcheapest wow goldWOW GoldBuy WOW GoldWhat is (bi/tri)linear interpolation?
Bilinear is interpolation linearly in 2D... like zooming on a picture, but instead of blocky pixels you get a blurry, smooth texture.

Trilinear is interpolation linearly in 3D. It's commonly used to interpolate bilinearly between textures and linearly between an MIP-maps on a 3D card.
ok0510 is offline   Reply With Quote
Old 3rd August 2008, 10:27   #272
Mr_Nudge
Major Dude
 
Mr_Nudge's Avatar
 
Join Date: Apr 2004
Location: melbourne, australia
Posts: 655
not sure if anyone comes round here that often anymore, but nevertheless, here's some nifty code i made for mouse control.

//frame

gmx=getkbmouse(2);
gmy=getkbmouse(1);
gmc=getkbmouse(3);
mos=below(abs(gmx),1)*below(abs(gmy),1);
gmc2=if(mos*gmc,1,if(bnot(gmc),0,gmc2));
gmc3=if(bnot(gmc2)*bnot(mos),0,if(bnot(gmc)*mos,1,gmc3));
os=gmc2*gmc3;

--

basically, os returns 1 when you left click on the avs window and will keep returning 1 as long as the left mouse button is held, even if the mouse moves off the window.

os will return 0 at all other times, even if the left mouse button is held then dragged onto the avs window.

Life's a game, break the rules
Click here
Mr_Nudge is offline   Reply With Quote
Old 30th May 2013, 07:53   #273
lincon
Junior Member
 
Join Date: May 2013
Posts: 7
First order targeting is increasing a value by increments (speed), until it reaches target, right?

What is (bi/tri)linear interpolation?
lincon 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