Archive: per point


10th November 2003 15:31 UTC

per point
what is the best way of giveing per point data to a SSC. Is it a tree of ifs or just added ifs?

x=if(above(p,2),if(above(p,3),p4,p3),if(above(p,1),p2,p1);

x=if(equal(p,0),p0,0)+if(equal(p,1),p1,0)+...

i gues the first one would be the anvser because you dont calculate anything but im not sure because AVS's ifs dont skip or something like that. This is quite important for me so any light on this would be great help.


10th November 2003 19:32 UTC

Mind giving an example problem so we can understand what you are trying to do with this?


10th November 2003 19:50 UTC

I doubt it matters much ;). You can try out both methods in an n=10000 scope and compare the speeds.


10th November 2003 22:22 UTC

I don't know if it is the going to be the fastest way, but i use strings of bor(, band(, and bnot( then a multipler by the position of the point you want to draw.
i.e.


x=band(above(p,0),below(p,4))*p1+band(above(p,3),below(p,7))*p2...

One thing I know for sure is that using an if( statement that has one of the answers=0 would most often be a waste, since you could replace the if( statement with equal(point,number)*position

x=if(equal(p,1),p1,0)
x=equal(p,1)*p1

If that is not what you want just ask something more specific.

11th November 2003 00:42 UTC

But a multiplication is a slowdown too...


11th November 2003 01:38 UTC

best thing i've come up with is to fuck ifs because it's slow and cumbersome and a pain in the ass to write. not to mention the fact that with a series of if statements you're adding an extra function call for no reason whatsoever. nested ifs i'm not so sure about, but in a short amount of time it gets hard to count the closing parentheses.
super toast has the right idea imo, cos afaik ifs are a bigger slowdown than multiplication, and they're harder to deal with.


11th November 2003 03:28 UTC

I agree with Atero, my main problem with using ifs is that they are so damn confusing to deal with when you can easily use a bunch of equals to make a nice logical order.


11th November 2003 04:53 UTC

My suggestion, do the easier way first and then optimize to the fastest way in terms of computing. Remember kids, optimizations are your biggest enemy when your code isn't final.

Anyone willing to test?


11th November 2003 11:50 UTC

Yeah I am in agreement here. The first thing I noticed was what S-uper_T-oast posted.

If's are generally bad speedwise but I like them for understanding as that is programming background I was brought up on.

I would like to see a speed comparasion too. We did some ages ago too for MilkDrop.

Otehr points of interest use multiplaction instead of divide as apparent it is 7 times quicker.

i.e 0.01*abc instead of abc/100

avoid % (although better than multiple if's ) as it is slow.


12th November 2003 12:51 UTC

Personally I think the way to do it if you want to use some extremely complicated optimizations, then you need to put a comment right before the SSC/DM/whatever that has the unoptomized version so that people can figure it out.


12th November 2003 15:46 UTC

that's a generous idea. :up:


18th November 2003 11:52 UTC

thanx a bunch for all your input on this. I gues i'll try this method (x=band(above(p,0),below(p,4))*p1+band(above(p,3),below(p,7))*p2...);
because it seems most compact. I need this because i wanna do a very simple modeler which would alow you to model something and export it as ssc code. Im doing this in flash because thats the only whay i know
I already had something made but i started all over again and it looks im gonna have to do it again:D. Im haveing truble with structuring the whole thing so that it would be expandable later.
Im still trying to grasp object oriented programing:). Im also wondering about where is perpoint much slower than calculated shapes because I could code it so that the basic shapes would generate code for the shape not in perpoint. I have a lot of other ideas for it but this will take a lot of time and I dont have much.
Oh and please tell me if you think the project is a bad idea:).


18th November 2003 22:26 UTC

Perpoint is mush slower because for every n number of points it goes through and checks every single true/false function no matter if you are drawing to that location or not. For very small scopes, the slowdown is not that noticable, but for things like my morphing cubes preset, it gets INCREDIBLY slow very fast.