POV-Ray : Newsgroups : povray.newusers : help Error? Server Time
24 Nov 2024 17:54:08 EST (-0500)
  help Error? (Message 1 to 6 of 6)  
From: Katherina
Subject: help Error?
Date: 8 Aug 2007 05:05:01
Message: <web.46b986e59ab1292ad7b596fc0@news.povray.org>
I'm new at Povray.

I use the following code in order to find intersection of 30 planes and 19
quadratics, plane normals and points are given in 2-dimensional array p and
q, coefficients of quadratics given in 2-dimensional array qq.

But I got the following error message: in qq[j]: "array subscript out of
range"

Maybe it is trivial but I didn't understand why? Can somebody help me?

  #declare i=0;
  #declare j=0;


  #while (i<31)


  intersection{

  plane
{<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]
}


  quadric
  {

<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]

  }

  }


  #declare i=i+1;

    #if (j<20)
      #declare j=j+1;
  #end

  #end


Post a reply to this message

From: Alain
Subject: Re: help Error?
Date: 8 Aug 2007 06:03:51
Message: <46b99507$1@news.povray.org>
Katherina nous apporta ses lumieres en ce 2007/08/08 05:03:
> 
> I'm new at Povray.
> 
> I use the following code in order to find intersection of 30 planes and 19
> quadratics, plane normals and points are given in 2-dimensional array p and
> q, coefficients of quadratics given in 2-dimensional array qq.
> 
> But I got the following error message: in qq[j]: "array subscript out of
> range"
> 
> Maybe it is trivial but I didn't understand why? Can somebody help me?
> 
>   #declare i=0;
>   #declare j=0;
> 
> 
>   #while (i<31)
> 
> 
>   intersection{
> 
>   plane
> {<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]
> }
> 
> 
>   quadric
>   {
> 
>
<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]
> 
>   }
> 
>   }
> 
> 
>   #declare i=i+1;
> 
>     #if (j<20)
>       #declare j=j+1;
>   #end
> 
>   #end
> 
> 
After the last time your test on "j" succeede, j = 20. Your array's last element 
is 19, you want to access element 20 whitch don't exist.
Solution:
Use 2 successive #while loops. The first one been only for the planes, the 
second only for the quadrics.

The order of the elements of the intersection have no impact: All components 
after the first are intersected from the first one.

-- 
Alain
-------------------------------------------------
You know you've been raytracing too long when you were ever dragged out of a 
theater for yelling "Cheap rasterized graphics!!!" in the middle of Toy Story.
Stephan Ahonen


Post a reply to this message

From: Katherina
Subject: Re: help Error?
Date: 8 Aug 2007 06:50:01
Message: <web.46b99ef42d937f37d7b596fc0@news.povray.org>
Alain <ele### [at] netscapenet> wrote:
> Katherina nous apporta ses lumieres en ce 2007/08/08 05:03:
> >
> > I'm new at Povray.
> >
> > I use the following code in order to find intersection of 30 planes and 19
> > quadratics, plane normals and points are given in 2-dimensional array p and
> > q, coefficients of quadratics given in 2-dimensional array qq.
> >
> > But I got the following error message: in qq[j]: "array subscript out of
> > range"
> >
> > Maybe it is trivial but I didn't understand why? Can somebody help me?
> >
> >   #declare i=0;
> >   #declare j=0;
> >
> >
> >   #while (i<31)
> >
> >
> >   intersection{
> >
> >   plane
> > {<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]
> > }
> >
> >
> >   quadric
> >   {
> >
> >
<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]
> >
> >   }
> >
> >   }
> >
> >
> >   #declare i=i+1;
> >
> >     #if (j<20)
> >       #declare j=j+1;
> >   #end
> >
> >   #end
> >
> >
> After the last time your test on "j" succeede, j = 20. Your array's last element
> is 19, you want to access element 20 whitch don't exist.
> Solution:
> Use 2 successive #while loops. The first one been only for the planes, the
> second only for the quadrics.
>
> The order of the elements of the intersection have no impact: All components
> after the first are intersected from the first one.
>
> --
> Alain
> -------------------------------------------------
> You know you've been raytracing too long when you were ever dragged out of a
> theater for yelling "Cheap rasterized graphics!!!" in the middle of Toy Story.
> Stephan Ahonen

Now I changed my code and put 2 successive #while loops here is my new code,
but still it gives same error message, I really do not understand why?




  #declare i=0;
  #declare j=0;


  #while (i<31)


    #while (j<20)


  intersection{

  plane
{<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]
}


  quadric
  {

<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]

  }

  }


  #declare i=i+1;
  #declare j=j+1;

  #end

  #end


Post a reply to this message

From: Katherina
Subject: Re: help Error?
Date: 8 Aug 2007 07:10:00
Message: <web.46b9a4232d937f37d7b596fc0@news.povray.org>
"Katherina" <nomail@nomail> wrote:
> Alain <ele### [at] netscapenet> wrote:
> > Katherina nous apporta ses lumieres en ce 2007/08/08 05:03:
> > >
> > > I'm new at Povray.
> > >
> > > I use the following code in order to find intersection of 30 planes and 19
> > > quadratics, plane normals and points are given in 2-dimensional array p and
> > > q, coefficients of quadratics given in 2-dimensional array qq.
> > >
> > > But I got the following error message: in qq[j]: "array subscript out of
> > > range"
> > >
> > > Maybe it is trivial but I didn't understand why? Can somebody help me?
> > >
> > >   #declare i=0;
> > >   #declare j=0;
> > >
> > >
> > >   #while (i<31)
> > >
> > >
> > >   intersection{
> > >
> > >   plane
> > > {<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]
> > > }
> > >
> > >
> > >   quadric
> > >   {
> > >
> > >
<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]
> > >
> > >   }
> > >
> > >   }
> > >
> > >
> > >   #declare i=i+1;
> > >
> > >     #if (j<20)
> > >       #declare j=j+1;
> > >   #end
> > >
> > >   #end
> > >
> > >
> > After the last time your test on "j" succeede, j = 20. Your array's last element
> > is 19, you want to access element 20 whitch don't exist.
> > Solution:
> > Use 2 successive #while loops. The first one been only for the planes, the
> > second only for the quadrics.
> >
> > The order of the elements of the intersection have no impact: All components
> > after the first are intersected from the first one.
> >
> > --
> > Alain
> > -------------------------------------------------
> > You know you've been raytracing too long when you were ever dragged out of a
> > theater for yelling "Cheap rasterized graphics!!!" in the middle of Toy Story.
> > Stephan Ahonen
>
> Now I changed my code and put 2 successive #while loops here is my new code,
> but still it gives same error message, I really do not understand why?
>
>
>
>
>   #declare i=0;
>   #declare j=0;
>
>
>   #while (i<31)
>
>
>     #while (j<20)
>
>
>   intersection{
>
>   plane
> {<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]
> }
>
>
>   quadric
>   {
>
>
<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]
>
>   }
>
>   }
>
>
>   #declare i=i+1;
>   #declare j=j+1;
>
>   #end
>
>   #end

I saw a mistake of mine, the rows of arrays p,q are from 0 to 29, and for qq
0 to 18, so I changed thses numbers in #while loops as 30 for planes and 19
for quadratics, but still I couldn't see any image after even 5 minutes, is
this normal in Povray?

It is written

Parsed ..... tokens


and number of tokens is changing and very big numbers,

what does this mean?

why I can not see the image?

what can I do to see my image?


Post a reply to this message

From: Chris B
Subject: Re: help Error?
Date: 8 Aug 2007 08:11:08
Message: <46b9b2dc$1@news.povray.org>
"Katherina" <nomail@nomail> wrote in message 
news:web.46b9a4232d937f37d7b596fc0@news.povray.org...
> "Katherina" <nomail@nomail> wrote:
>> Now I changed my code and put 2 successive #while loops here is my new 
>> code,
>> but still it gives same error message, I really do not understand why?
>>
>>   #declare i=0;
>>   #declare j=0;
>>
>>
>>   #while (i<31)
>>
>>
>>     #while (j<20)
>>
>>
>>   intersection{
>>
>>   plane
>> {<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]
>> }
>>
>>
>>   quadric
>>   {
>>
>>
<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]
>>
>>   }
>>
>>   }
>>
>>
>>   #declare i=i+1;
>>   #declare j=j+1;
>>
>>   #end
>>
>>   #end
>
> I saw a mistake of mine, the rows of arrays p,q are from 0 to 29, and for 
> qq
> 0 to 18, so I changed thses numbers in #while loops as 30 for planes and 
> 19
> for quadratics, but still I couldn't see any image after even 5 minutes, 
> is
> this normal in Povray?
>
> It is written
>
> Parsed ..... tokens
>
>
> and number of tokens is changing and very big numbers,
>
> what does this mean?
>
> why I can not see the image?
>
> what can I do to see my image?
>

You've got two nested loops, so you're in danger of intersecting all 18 
quadrics 30 times, at the moment though you'll be looping forever because 
the 'i' increment is in the inner loop, so once 'j' reaches 18, the inner 
loop ends and 'i' stays at 18 for the rest of eternity, never reaching the 
required value of 30 to break out of the outer loop.
I think what you're aiming at is probably just to intersect everything once, 
so you want something more like the following code.
I haven't tested this, so it might contain typos.

Regards,
Chris B.

  intersection {
    #declare i=0;
    #while (i<30)
       plane 
{<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]}
       #declare i=i+1;
    #end
    #declare j=0;
    #while (j<19)
      quadric 
{<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]}
      #declare j=j+1;
    #end
  }


Post a reply to this message

From: Alain
Subject: Re: help Error?
Date: 8 Aug 2007 17:35:24
Message: <46ba371c@news.povray.org>
Katherina nous apporta ses lumieres en ce 2007/08/08 06:46:

> Now I changed my code and put 2 successive #while loops here is my new code,
> but still it gives same error message, I really do not understand why?
> 
> 
> 
> 
>   #declare i=0;
>   #declare j=0;
The declaretion of the indexing MUST ALWAYS immediately precede the coresponding 
#while statement.
> 
> 
>   #while (i<31)
> 
> 
>     #while (j<20)
> 
> 
>   intersection{
> 
>   plane
> {<p[i][0],p[i][1],p[i][2]>,p[i][0]*q[i][0]+p[i][1]*q[i][1]+p[i][2]*q[i][2]
> }
> 
> 
>   quadric
>   {
> 
>
<qq[j][2],qq[j][4],qq[j][6]>,<qq[j][7],qq[j][8],qq[j][9]>,<qq[j][1],qq[j][3],qq[j][5]>,qq[j][0]
> 
>   }
> 
>   }
> 
> 
>   #declare i=i+1;
You must NEVER alter any indexing variable inside any loop but it's own. Here, 
you increase both in the inner loop.
>   #declare j=j+1;
> 
>   #end
> 
>   #end
>

You need to start with the intersection and put the loops inside the 
intersection. Secondly, put the 2 loops one after the other, not one inside the 
other.

intersection{
#declare I = 0;
#while(I < 31)
Your_planes
#declare I = I + 1;
#end// terminate the intersection of planes
#declare I = 0;// you can reuse the same variable
#while(I < 20)
Your_quadrics
#declare I = I + 1;
#end// terminate the intersection of quartics
texture{Your_texture}// unless you need each part to provide it's own texture
}// End of the intersection


-- 
Alain
-------------------------------------------------
'hAS ANYONE SEEN MY cAPSLOCK KEY?'


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.