- AVS Troubleshooting
- Please, explain me this:
Archive: Please, explain me this:
Paufer
21st September 2006 14:25 UTC
Please, explain me this:
I was reading PAK-9's progamming guide, in the superscope section, when realized that this will draw a square:
INIT:
n=6;
x1=0.5; y1=0.5;
x2=0.5; y2=-0.5;
x3=-0.5; y3=-0.5;
x4=-0.5; y4= 0.5;
x5=-0.5; y5=0.5;
x6=0.5; y6=0.5;
FRAME:
curpoint=0;
POINT:
curpoint=curpoint+1;
x=(if(equal(curpoint,1),x1,
if(equal(curpoint,2),x2,
if(equal(curpoint,3),x3,
if(equal(curpoint,4),x4,
if(equal(curpoint,5),x5,x6))))));
y=(if(equal(curpoint,1),y1,
if(equal(curpoint,2),y2,
if(equal(curpoint,3),y3,
if(equal(curpoint,4),y4,
if(equal(curpoint,5),y5,y6))))));
BUT, why this draws a square:
Init
n=5;
Frame
Rot=0;
Point=0;
Beat
Point
x1=-equal(point,0)+equal(point,1)+equal(point,2)-equal(point,3);
y1=equal(point,0)+equal(point,1)-equal(point,2)-equal(point,3);
x1=x1*0.5;
y1=y1*0.5;
x=x1*cos(rot)-y1*sin(rot);
y=x1*sin(rot)+y1*cos(rot);
point=if(equal(point,3),0,point+1);
WHY??????????
ok, I know it's a rotating square, but still is a square...
Thanks in advance.
Warrior of the Light
21st September 2006 18:08 UTC
It'd take me four pages to explain that.. the best suggestion that I can give is that you write an input>output scheme:
if 'point' is 0, then what would happen with all of the values?
etc
Paufer
21st September 2006 20:54 UTC
Well, I tried to think this way already, but I don't see the square in these codes...
Any other sugestion??
Warrior of the Light
21st September 2006 23:21 UTC
Okay, I'll go through it with you:
I'll just handle the postion on the x-axis for the first point of the line.
The formula:
x1=-equal(point,0)+equal(point,1)+equal(point,2)-equal(point,3);
point=0. (since it hasn't been defined yet)
I'll split it in four parts:
the first part: -equal(point,0)
point=0, so this results in: -equal(0,0)
equal(0,0) is true, so equal() returns 1.
There's a "-" in front of it, so here stands "-1" now.
second part: +equal(point,1)
point=0, so this results in: +equal(0,1)
equal(0,1) is false, so equal() returns 0.
There's a "+" in front of it, so here stands "+0" now.
The complete line so far is: -1+0.
Third part: +equal(point,2)
point=0, so this results in: +equal(0,2)
equal(0,2) is false, so equal() returns 0.
There's a "+" in front of it, so here stands "+0" now.
The complete line so far is: -1+0+0.
Fourth part: -equal(point,3);
point=0, so this results in: -equal(0,4);
equal(0,4) is false, so equal() returns 0.
There's a "-" in front of it, so here stands "-0" now.
The complete line so far is: -1+0+0-0.
a ";" ends the line.
-1+0+0-0=-1
So, for the first point, x1=-1
then we find that x1=x1*.5
-1*.5=.5
x1=-.5
x=x1*cos(rot)-y1*sin(rot);
(I'll omit the rotation mumbojumbo as it is not relevant at this time)
point=if(equal(point,3),0,point+1);
if point=3, then point=0. Otherwise point=point+1.
In this case, point was 0, so point becomes 1 now (0+1=1).
This is done for the next point of the square (or better: line) that will be calculated.
(and when the line is finished, point'll be reset to 0)
Paufer
22nd September 2006 00:24 UTC
Okay, now I see a light in the end of the tunnel, but it is very complicated yet...
I must be stupid or something, I get how the codes works, but I still don't see a square. I don't know how to explain it in english but I'll try:
"-1+0+0-0=-1
So, for the first point, x1=-1
then we find that x1=x1*.5
-1*.5=.5
x1=-.5"
ok, thats clear to me, but why or how does it change to 0.5 or the other values??
Sorry for bothering you with that... and thanks!
PAK-9
22nd September 2006 23:35 UTC
Take a simpler example and imagine the code is just this
---
frame:
n=5;
point=0;
point:
x=-equal(point,0)+equal(point,1)+equal(point,2)-equal(point,3);
y=equal(point,0)+equal(point,1)-equal(point,2)-equal(point,3);
point=if(equal(point,3),0,point+1);
---
the point code is executed 5 times because n=5; for each pass of the point code the variable 'point' will be 0,1,2,3,0 in that order.
When point=0:
equal(point,1) = 0
equal(point,2) = 0
equal(point,3) = 0
only 'equal(point,0)' is non-zero, it equals 1. So for this value of point, x=-1 and y=1
When point=1:
equal(point,0) = 0
equal(point,2) = 0
equal(point,3) = 0
only 'equal(point,1)' is non-zero, it equals 1. So for this value of point, x=1 and y=1
if you follow this logic for each execution of the point code you get:
(first pass, point=0) x=-1,y=1
(second pass, point=1) x=1,y=1
(third pass, point=2) x=1,y=-1
(fourth pass, point=3) x=-1,y=-1
(fifth pass, point=0) x=-1,y=1
It should (hopefully) be apparent that this renders a closed square.
Hope this helps
Paufer
23rd September 2006 16:58 UTC
yeah, thanks PAK-9 and Warrior!!!
Now I understand, but still, you have to think quite a bit to draw things in the SSC...
Well, I think that just practicing I'll get it...
Thanks again!!