michjoh

20 Reputation

3 Badges

3 years, 198 days

MaplePrimes Activity


These are replies submitted by michjoh

@Carl Love Thanks again Carl!

@Carl Love Follow up question. The final procedure looks like this:

for i from 1 to M do
    X[i,0]:=0;
     Y[i,0]:=0;
        for j from 1 to N do
          if j=1 then X[i,1]:=1; Y[i,1]:=0;
          elif j>1 then
          r:=R3();
            if r=1 then X[i,j]:=2*X[i,j-1]-X[i,j-2]; Y[i,j]:=2*Y[i,j-1]-Y[i,j-2]
            elif r=2 then X[i,j]:=X[i,j-1]+Y[i,j-1]-Y[i,j-2]; Y[i,j]:=Y[i,j-1]-X[i,j-1]+X[i,j-2];
            elif r=3 then X[i,j]:=X[i,j-1]-Y[i,j-1]+Y[i,j-2]; Y[i,j]:=Y[i,j-1]+X[i,j-1]-X[i,j-2];
          end if;
       end if;
   R[i,j]:=[X[i,j],Y[i,j]];
  end do:
end do:

So now I have my r[i]but I don't want it to cross itself. So I need to add a break that considers r[i]=r[j] for 0<j<i-2. Since it can not go directly back onitself I only need tpo consider up to the 2nd to last step. I have tried multiple ways, creating a for loop outside this one aswell as creating if breaks inside. This is what I am trying now.

for i from 1 to M do
X[i,0]:=0;
Y[i,0]:=0;
for j from 1 to N do
k:=0..j-2;
if j=1 then X[i,1]:=1; Y[i,1]:=0;
elif j>1 then
r:=R3();
if r=1 then X[i,j]:=2*X[i,j-1]-X[i,j-2]; Y[i,j]:=2*Y[i,j-1]-Y[i,j-2]
elif r=2 then X[i,j]:=X[i,j-1]+Y[i,j-1]-Y[i,j-2]; Y[i,j]:=Y[i,j-1]-X[i,j-1]+X[i,j-2];
elif r=3 then X[i,j]:=X[i,j-1]-Y[i,j-1]+Y[i,j-2]; Y[i,j]:=Y[i,j-1]+X[i,j-1]-X[i,j-2];
end if;
end if;
R[i,j]:=[X[i,j],Y[i,j]];
if R[i,j]=R[i,k] then R[i,j]; break; end if;
end do:
end do:

I will continue trying but appreciate any help I get :)

@Carl Love Yeah that is what I was thinking. Thanks! it worked now.

@Rouben Rostamian  Thanks! Helped a bunch!

Page 1 of 1