![]() |
#121 |
Forum King
|
nur ein bisschen spricht deutsch. Ich kann es sehr wenig sprechen.
|
![]() |
![]() |
![]() |
#122 |
Junior Member
|
oh sorry... i didn´t know that, i also can´t speak english so well..
|
![]() |
![]() |
![]() |
#123 |
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
|
Incidentally, which would be quicker for calculating pi:
"acos(-1)" or "6167950454/1963319607" ? ![]() |
![]() |
![]() |
![]() |
#124 |
Forum King
|
well, that depends.
are you idiot enough to be calculating it on a regular basis in any given preset? "guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
![]() |
![]() |
![]() |
#125 |
Major Dude
Join Date: Jan 2003
Location: Estonia.
Posts: 851
|
Pi is calculated just once... i only hope that you do calculate it in init?
fastet way: pi=3.141592654... Phi = (1+sqrt(5))/2 |
![]() |
![]() |
![]() |
#126 |
Major Dude
Join Date: Nov 2002
Location: Arnhem, the Netherlands
Posts: 927
|
though acos(-1) is more accurate.
|
![]() |
![]() |
![]() |
#127 |
Major Dude
Join Date: Jan 2003
Location: Mumbai, India
Posts: 787
|
Not necessarily, acos(-1) would return say about 6 decimal places (dont know exaclt), but you can always use a calculator and obtain that value and write pi=3.14159265.. instead of pi=acos(-1)
http://home.iitb.ac*****~shreyaspotnis |
![]() |
![]() |
![]() |
#128 |
Whacked Moderator
Join Date: Jun 2001
Posts: 2,104
|
Yeah and it wouldn't matter one bit :P. For drawing a (-1,1) circle in a 320x320 window:
r=i*pi*2; x=cos(r);y=sin(r); 1 pixel is 2/320 units = 0.00625 So you only need a precision of 0.003125 (half due to rounding errors) on cos and sin to guarantee a correct result. Error-propagation theory says something like: relative error of f(x) = (error of x)*(df(x)/dx) Because dcos(x)/dx = -sin(x), abs(df(x)/dx) is at most equal to 1. So the relative error of cos(x) will never exceed the relative error on x. It means that you need at most a relative error of 0.003125 for 100% accuracy in AVS. So something like 3.1416 should make no difference from anything more accurate, for drawing circles at least. If you're doing more complicated calculations of course, more accuracy is probably needed. |
![]() |
![]() |
![]() |
#129 |
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
|
Well if more accuracy is needed then would acos(-1) or 6167950454/1963319607 be the quickest? I know it doesn't matter much at all but i might as well have the quickest method of doing so.
![]() |
![]() |
![]() |
![]() |
#130 |
Major Dude
Join Date: May 2001
Location: somewhere else
Posts: 1,278
|
I don't see what speed has to do with it, if you put it into init, it will only calculate once, so speed won't matter.
powered by C₈H₁₀N₄O₂ |
![]() |
![]() |
![]() |
#132 |
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353
|
cmon.. unless avs is a big dum dum, acos(-1) would have to be recognised by the prog. Seeing as acos requires pi anyway.
But then.. after the tidbits that steve uncovered, i wouldnt be suprised if its not. |
![]() |
![]() |
![]() |
#133 |
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
|
Is there any way to mimick the "rand" function but so it can be syncronised between scopes? I've tried a few different test ways and can't seem to come up with anything.
edit: i only need it so it's the quivalent of "rand(3)" but be able to syncronise. ![]() |
![]() |
![]() |
![]() |
#134 |
Forum King
|
Use a pseudo-random number generator. UnConeD's particle engine presets use these.
|
![]() |
![]() |
![]() |
#135 |
Whacked Moderator
Join Date: Jun 2001
Posts: 2,104
|
Or use something based on getosc.
These days I use asin(sin(...)) where ... is a sum of getoscs. If you multiply the ... by a large number, you get a somewhat equal spread (if you don't need that, you can drop the asin too). |
![]() |
![]() |
![]() |
#136 |
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
|
Actually, i just need a syncronisable version of the rand(2) that would work in UnConeDs tweak of my changing tunnel. I've tried and it doesn't seem to work with it.
![]() |
![]() |
![]() |
![]() |
#137 |
Forum King
|
You'll have to apply some translations to it to get it to the range 0-2, and then you'll have to round it.
|
![]() |
![]() |
![]() |
#138 |
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
|
All that time messing with random number generators and the answer was right under my nose. The code had unecessary variables in it that were easily replicated. Without the rand function used.
![]() |
![]() |
![]() |
![]() |
#139 |
Major Dude
Join Date: Jan 2003
Location: Mumbai, India
Posts: 787
|
synched rand(2) would be something like.
no=abs((getosc(something)+getosc(something))*bignumber)%3; http://home.iitb.ac*****~shreyaspotnis |
![]() |
![]() |
![]() |
#140 |
Bin King
Join Date: Mar 2001
Location: Finland
Posts: 2,173
|
Why 2 getosc functions?
![]() [edit] Since it's rand(2) it's clear you want 0&1, so just rnd=above(getosc,0) will do, since getosc can be both negative or positive. It will be either 0 or 1 |
![]() |
![]() |
![]() |
#141 |
Forum King
|
Good point tug.. and shreyas.. you method is rand(3) (prolly a typo).. rand(3) is either 0, 1 or 2 just like n%3. % is definately useful for this sort of thing in the general case though. (getosc(something)*bignumber)%n is probably the easiest way to generate a synchable rand(n). Sometimes a method like rnd=(largeprime*rnd+smallerprime)%n is more useful... like if you want to generate the same sequence of psuedorandom numbers, for example to create a starfield scope. You can use this per point and start with the same rnd every frame. Sometimes I use this method on beat except the rnd inside the statement is replaced with a var that increments every frame... this tends to give a pretty rectangular distribution.
|
![]() |
![]() |
![]() |
#142 |
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
|
Amazing how my mind comes up with all this complex crap and then when it comes to one of the simplest things it just comes out a blank.
![]() |
![]() |
![]() |
![]() |
#143 |
Forum King
|
tug, shreyas
you're both idiots. use %2 not %3. "guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
![]() |
![]() |
![]() |
#144 |
Bin King
Join Date: Mar 2001
Location: Finland
Posts: 2,173
|
Like Jheriko didn't cover that part up already
![]() fucking stupid... asswanker idiot... always groaning about shit... |
![]() |
![]() |
![]() |
#145 |
Forum King
|
...well that was stupid of me...opened this up early afternoon and forgot about it...then came back...>_O
...anyway... ![]() "guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
![]() |
![]() |
![]() |
#146 |
Major Dude
Join Date: Jan 2003
Location: Mumbai, India
Posts: 787
|
Why?
1%3=1 2%3=2 3%3=0! 4%3=1 5%3=2 6%3=0! I think I am right. http://home.iitb.ac*****~shreyaspotnis |
![]() |
![]() |
![]() |
#147 |
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353
|
OOlrighty.. nice way of thnking about it is like this.
n%x = returns the reamainder in real terms. Or, if you prefer, its like "n minus the next lowest mulitple of x, including 0, or the current n if it is a multiple of x." Eg. x%1 = 0... as 1 divides perfectly into any integer. 1%2 = 1... it divides 0 times, with a remainder of 1. 45%13 = 6... 13 goes into 45, 3 times (39), with a remainder of 6. using any form of x%a (such as x%3 in your example) will cycle between 0 and a-1, including all the integers in between (0,1,2,0,1,2,0...). The reason is easy to understand, just follow this. 0%3 = 0... it divides 0 times, and there is no remainder. 1%3 = 1... it divides 0 times, and there is a remainder of 1. 2%3 = 2... it divides 0 times, and there is a remainder of 2. 3%3 = 0... it divides 1 time, and there is no remainder. ... 40%3 = 1... it divides 13 times, and there is a remainder of 1. 41%3 = 2... it divides 13 times, and there is a remainder of 2. make sense? Last edited by sidd; 6th September 2003 at 01:55. |
![]() |
![]() |
![]() |
#148 |
Forum King
|
sidd forgot to mention that % only returns...sensible results for positive numbers on both sides, and integers on the left side.
"guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
![]() |
![]() |
![]() |
#149 |
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
|
And how might i go about making avs spew a zero, then onbeat switch to 1, then onbeat switch to 2, then onbeat switch to 1 again, then onbeat to zero, etc etc. Tried for a while again, no luck.
![]() |
![]() |
![]() |
![]() |
#150 |
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353
|
init:
add=1; btc=0; on beat: add=if(equal(btc,2),-1,if(equal(btc,0),1,add)); btc=btc+add; |
![]() |
![]() |
![]() |
#151 |
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470
|
I love this forum. Many thanks sidd.
![]() ![]() |
![]() |
![]() |
![]() |
#152 |
Banned
|
value = value * (1-speed) + target * speed;
or value = value + (target - value) * speed |
![]() |
![]() |
![]() |
#153 |
Foorum King
Join Date: Jul 2003
Location: bar2000
Posts: 11,455
|
page1
It's not answered there, though. Is that what you wanted to say? Then why don't you say it? Say : There's a question on page1 that hasn't been answered. Else it'll look like you've been randomly cutting&pasting again. |
![]() |
![]() |
![]() |
#154 |
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353
|
im more confused than normal..
|
![]() |
![]() |
![]() |
#155 |
Forum King
Join Date: May 2003
Location: Fnord?!
Posts: 2,657
|
/me agrees with sidhartha
For anyone who doesn't understand ths sign(var) function, it returns 1 when var>0 and -1 when var<0 and returns 0 when var=0. sign(.3)=1;sign(1000)=1; sign(-.4)=-1;sign(-103)=-1; sign(0)=0; I am sure this was mentioned somewere else, but I just finally figured that all out for myself. |
![]() |
![]() |
![]() |
#156 |
Major Dude
Join Date: Nov 2002
Location: Arnhem, the Netherlands
Posts: 927
|
thx, didn't knew that.
![]() |
![]() |
![]() |
![]() |
#157 |
Foorum King
Join Date: Jul 2003
Location: bar2000
Posts: 11,455
|
A few people asked for per pixel code in Color Modifier, this can be done easily by
putting a Buffer Save before Cmod (save&replace) and a "no movement just blend" DM with that buffer as input after it. |
![]() |
![]() |
![]() |
#158 |
Major Dude
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
|
I found an interesting trick with a texer...
Make a greyscale picture that looks like a cloud (I stole a quake3 sky texture and faded out the edges) then make a 3d ssc with an 'n' value of about 10-20, colour it how you like, use the (masked) cloud texture as a texer and tada, easy cool looking fog. Looks impressive over raytraced stuff if you sync the ssc. |
![]() |
![]() |
![]() |
#159 |
Forum King
|
s-t: actually, no it doesn't. it tries really hard but it never works. i used to have a lot of trouble with it cos for some reason it didn't always return the right numbers. i recently realized (thanks to the help of regwatch) that it returns slightly less than 1 or -1, so this sort of thing happens:
equal(sign(1)*10,10)==0 i don't know exactly how to make it work perfectly, but i do know that if you use abs(x)/x it returns the sign of x correctly. "guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
![]() |
![]() |
![]() |
#160 |
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353
|
thanks atero..
thats really useful perhaps you should suggest this to justin while developments are underway. That abs(x)/x will probably come in handy at some stage.. tho i cant think of what for at the moment. |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|