Differences between revisions 5 and 7 (spanning 2 versions)
Revision 5 as of 2003-08-28 16:32:40
Size: 822
Editor: velociraptor
Comment:
Revision 7 as of 2003-09-24 23:20:23
Size: 1069
Editor: yakko
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Given a line in one dimension from p1 to p2, we can find the line of length 1/2 (p2-p1) centered around the midpoint of the first line in MLPQ as follows:
Line 3: Line 2:
begin%RECURSIVE% begin%Boxes%
Line 5: Line 4:
/*
     First we must build the diff relation. It is interesting
     to note that this relation is what will limit the other
     relations
*/
 
diff(x,y,z) :- x-y>=0, -x+y>=0, z>=0, -z>=0.
diff(x,y,z) :- diff(x1,y,z1), x-x1<=1, x-x1>=1, z-z1<=1, z-z1>=1.
diff(x,y,z) :- diff(x,y1,z1), y-y1<=1, y-y1>=1, z1-z<=1, z1-z>=1.
Choice(m,n) :- m=0, n=0.
Choice(m,n) :- m=0, n=1.
Choice(m,n) :- m=0, n=2.
Choice(m,n) :- m=1, n=0.
Choice(m,n) :- m=1, n=2.
Choice(m,n) :- m=2, n=0.
Choice(m,n) :- m=2, n=1.
Choice(m,n) :- m=2, n=2.
Line 15: Line 13:
/* Our initial line */
line(0,6, 0).
D(x,y,z) :- x-y=0, z=0.
D(x,y,z) :- D(x1,y,z1), x-x1=1, z-z1=1.
Line 18: Line 16:
/* Recursive line definition */
line(x,y,d) :- line(p1,p2,d1),
               diff(p,p1,z1), diff(p2,p,z),
               diff(x,p1,z2), diff(p,x,z2),
               diff(p2,y,z3), diff(y,p,z3),
               d-d1 = 1.
Line 25: Line 17:
end%RECURSIVE% M(x,y,z) :- x=0, y=0, z=0.
M(x,y,z) :- M(x1,y,z1), D(z,z1,y), x-x1=1.
M(x,y,z) :- M(x,y1,z1), D(z,z1,x), y-y1=1.

/* Creates the first set of base lines length=1,3,9... */

BaseLine(x1,x2):- x1=0, x2=1.
BaseLine(a1,d3):- BaseLine(a1,d1), l=3, M(l,d1,d3).

Box(x,y,s) :- BaseLine(x,b), y-x=0, b-s=0.

Box(x,y,s) :- Box(a,b,l), k=3, M(k,s,l), Choice(m,n),
               M(s,m,z1), D(x,a,z1),
               M(s,n,z2), D(y,b,z2).

XBox(a1,c1,s) :- Box(a,c,l), k=3, M(k,s,l), D(a1,a,s), D(c1,c,s).

fractal1(id,x,y) :- id=1, Box(a,b,l), x-a>=0, D(x1,l,a), x-x1<=0,
                    y-b>=0, D(y1,l,b), y-y1<=0.

fractal2(id,x,y) :- id=2, XBox(a,b,l), x-a>=0, D(x1,l,a), x-x1<=0,
                    y-b>=0, D(y1,l,b), y-y1<=0.

end%Boxes%

begin%Boxes%

Choice(m,n) :- m=0, n=0.
Choice(m,n) :- m=0, n=1.
Choice(m,n) :- m=0, n=2.
Choice(m,n) :- m=1, n=0.
Choice(m,n) :- m=1, n=2.
Choice(m,n) :- m=2, n=0.
Choice(m,n) :- m=2, n=1.
Choice(m,n) :- m=2, n=2.

D(x,y,z) :- x-y=0, z=0.
D(x,y,z) :- D(x1,y,z1), x-x1=1, z-z1=1.


M(x,y,z) :- x=0, y=0, z=0.
M(x,y,z) :- M(x1,y,z1), D(z,z1,y), x-x1=1.
M(x,y,z) :- M(x,y1,z1), D(z,z1,x), y-y1=1.

/* Creates the first set of base lines length=1,3,9...  */

BaseLine(x1,x2):- x1=0, x2=1.
BaseLine(a1,d3):- BaseLine(a1,d1), l=3, M(l,d1,d3).

Box(x,y,s) :- BaseLine(x,b), y-x=0, b-s=0.

Box(x,y,s) :- Box(a,b,l), k=3, M(k,s,l), Choice(m,n),
               M(s,m,z1), D(x,a,z1),
               M(s,n,z2), D(y,b,z2).

XBox(a1,c1,s) :- Box(a,c,l), k=3, M(k,s,l), D(a1,a,s), D(c1,c,s).

fractal1(id,x,y) :- id=1, Box(a,b,l), x-a>=0, D(x1,l,a), x-x1<=0,
                    y-b>=0, D(y1,l,b), y-y1<=0.

fractal2(id,x,y) :- id=2, XBox(a,b,l), x-a>=0, D(x1,l,a), x-x1<=0,
                    y-b>=0, D(y1,l,b), y-y1<=0.

end%Boxes%

MlpqFractalProgram (last edited 2003-09-24 23:23:42 by yakko)