POV-Ray : Newsgroups : povray.general : Still making newbie mistakes Server Time
29 Jul 2024 06:16:39 EDT (-0400)
  Still making newbie mistakes (Message 1 to 10 of 17)  
Goto Latest 10 Messages Next 7 Messages >>>
From: Cousin Ricky
Subject: Still making newbie mistakes
Date: 20 Mar 2013 22:35:01
Message: <web.514a713837a513cd78641e0c0@news.povray.org>
For a while, this one had me wondering if I'd made a disastrous error in
roundedge.inc.

Code excerpt:
____________________________________________________________________

#include "functions.inc"
#include "roundedge.inc" //From lib.povray.org; defines RE_fn_Blob2()

#macro Basic_shape (Rpipe, Rsaddle)
  1 - sqrt
  ( RE_fn_Blob2 (f_sphere (0, y, z, Rpipe), Rsaddle)
  + RE_fn_Blob2 (f_sphere (x, 0, z, Rpipe), Rsaddle)
  - RE_fn_Blob2 (f_sphere (x, y, z, Rpipe), Rsaddle)
  )
#end

#declare Final_shape = isosurface
{ function { max (Basic_shape (0.5, 0.3), -Basic_shape (0.4, 0.4)) }
  max_gradient 1/0.3
  contained_by { box { -<1, 1, 0>, <1, 1, 0.5> } }
}
____________________________________________________________________

POV-Ray veterans and C programmers will spot my error immediately.

However, the first newbie to post what I did wrong gets a 15% discount off
POV-Ray 3.7.0.  (You do not need to know what RE_fn_Blob2() does to figure it
out.)


Post a reply to this message

From: Anthony D  Baye
Subject: Re: Still making newbie mistakes
Date: 21 Mar 2013 15:50:01
Message: <web.514b63d9c4a906bbd97ee2b90@news.povray.org>
"Cousin Ricky" <rickysttATyahooDOTcom> wrote:
> For a while, this one had me wondering if I'd made a disastrous error in
> roundedge.inc.
>
> Code excerpt:
> ____________________________________________________________________
>
> #include "functions.inc"
> #include "roundedge.inc" //From lib.povray.org; defines RE_fn_Blob2()
>
> #macro Basic_shape (Rpipe, Rsaddle)
>   1 - sqrt
>   ( RE_fn_Blob2 (f_sphere (0, y, z, Rpipe), Rsaddle)
>   + RE_fn_Blob2 (f_sphere (x, 0, z, Rpipe), Rsaddle)
>   - RE_fn_Blob2 (f_sphere (x, y, z, Rpipe), Rsaddle)
>   )
> #end
>
> #declare Final_shape = isosurface
> { function { max (Basic_shape (0.5, 0.3), -Basic_shape (0.4, 0.4)) }
>   max_gradient 1/0.3
>   contained_by { box { -<1, 1, 0>, <1, 1, 0.5> } }
> }
> ____________________________________________________________________
>
> POV-Ray veterans and C programmers will spot my error immediately.
>
> However, the first newbie to post what I did wrong gets a 15% discount off
> POV-Ray 3.7.0.  (You do not need to know what RE_fn_Blob2() does to figure it
> out.)


Without knowing what you're trying to accomplish here, I find this:  max
(Basic_shape (0.5, 0.3), -Basic_shape (0.4, 0.4)) slightly suspicious.

Regards,
A.D.B.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Still making newbie mistakes
Date: 22 Mar 2013 22:40:01
Message: <web.514d1583c4a906bb78641e0c0@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> Without knowing what you're trying to accomplish here, I find this:  max
> (Basic_shape (0.5, 0.3), -Basic_shape (0.4, 0.4)) slightly suspicious.

Nope, that's not it.  However, if you do the macro substitution by hand, you
might figure out the problem (again, without having to know what the shape is
supposed to look like).


Post a reply to this message

From: nimda
Subject: Re: Still making newbie mistakes
Date: 23 Mar 2013 10:45:00
Message: <web.514dbfabc4a906bbb0f4b1ca0@news.povray.org>
"Cousin Ricky" <rickysttATyahooDOTcom> wrote:
> For a while, this one had me wondering if I'd made a disastrous error in
> roundedge.inc.
>
> Code excerpt:
> ____________________________________________________________________
>
> #include "functions.inc"
> #include "roundedge.inc" //From lib.povray.org; defines RE_fn_Blob2()
>
> #macro Basic_shape (Rpipe, Rsaddle)
>   1 - sqrt
>   ( RE_fn_Blob2 (f_sphere (0, y, z, Rpipe), Rsaddle)
>   + RE_fn_Blob2 (f_sphere (x, 0, z, Rpipe), Rsaddle)
>   - RE_fn_Blob2 (f_sphere (x, y, z, Rpipe), Rsaddle)
>   )
> #end
>
> #declare Final_shape = isosurface
> { function { max (Basic_shape (0.5, 0.3), -Basic_shape (0.4, 0.4)) }
>   max_gradient 1/0.3
>   contained_by { box { -<1, 1, 0>, <1, 1, 0.5> } }
> }
> ____________________________________________________________________
>
> POV-Ray veterans and C programmers will spot my error immediately.
>
> However, the first newbie to post what I did wrong gets a 15% discount off
> POV-Ray 3.7.0.  (You do not need to know what RE_fn_Blob2() does to figure it
> out.)

It seems to me that it should be verified that a number be tested
to be positive before taking the square root out of it.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Still making newbie mistakes
Date: 24 Mar 2013 00:00:02
Message: <web.514e7996c4a906bb78641e0c0@news.povray.org>
"nimda" <nomail@nomail> wrote:
> "Cousin Ricky" <rickysttATyahooDOTcom> wrote:
> > [snip]
> > #macro Basic_shape (Rpipe, Rsaddle)
> >   1 - sqrt
> >   ( RE_fn_Blob2 (f_sphere (0, y, z, Rpipe), Rsaddle)
> >   + RE_fn_Blob2 (f_sphere (x, 0, z, Rpipe), Rsaddle)
> >   - RE_fn_Blob2 (f_sphere (x, y, z, Rpipe), Rsaddle)
> >   )
> > #end
> > [snip]
>
> It seems to me that it should be verified that a number be tested
> to be positive before taking the square root out of it.

That wasn't it.  As it turns out, RE_fn_Blob2() always returns a non-negative
number, and in this particular example, the value of the third term never
exceeds the sum of the first two.  But you weren't expected to know that, so it
was a good guess anyway.

(A quick test showed that taking the square root of a negative number within an
isosurface does not cause an exception!  That would have been a whole other
source of frustration; I would have expected the render to crash in that case,
and therefore would not have suspected that to be the problem if the render ran
to completion.  Now I have something else to watch out for!)


Post a reply to this message

From: Alain
Subject: Re: Still making newbie mistakes
Date: 24 Mar 2013 15:59:33
Message: <514f5b25$1@news.povray.org>

 > (A quick test showed that taking the square root of a negative number 
within an
 > isosurface does not cause an exception!  That would have been a whole 
other
 > source of frustration; I would have expected the render to crash in 
that case,
 > and therefore would not have suspected that to be the problem if the 
render ran
 > to completion.  Now I have something else to watch out for!)
 >
 >
 >

I've found that a long time ago. I supose that an internal test change 
the negative value to zero, take the absolute value, or there is a trap 
to catch that undefined value.


I suspect that it's the third instance of RE_fn_Blob2...
The first have: (0,y,z, Rpipe)
The second have: (x,0,z, Rpipe)
But the third have: (x,y,z, Rpipe)

It probably should be: (x,y,0, Rpipe)



Alain


Post a reply to this message

From: scott
Subject: Re: Still making newbie mistakes
Date: 25 Mar 2013 07:17:02
Message: <5150322e@news.povray.org>
> Nope, that's not it.  However, if you do the macro substitution by hand, you
> might figure out the problem (again, without having to know what the shape is
> supposed to look like).

I rarely use macros like this (usually just for shapes or groups of 
shapes) but yeh I can imagine that one took a while to figure out.


Post a reply to this message

From: clipka
Subject: Re: Still making newbie mistakes
Date: 25 Mar 2013 09:52:58
Message: <515056ba@news.povray.org>
Am 21.03.2013 03:32, schrieb Cousin Ricky:

> POV-Ray veterans and C programmers will spot my error immediately.

Will they?

Took me a while to figure it out; I won't spoil the party though, so 
happy guessing to everyone else :-P


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Still making newbie mistakes
Date: 25 Mar 2013 10:20:32
Message: <51505d30$1@news.povray.org>
Cousin Ricky wrote:

 > -Basic_shape (0.4, 0.4)

I suspect this was intended to be the negative value
of Basic_shape(0.4,0.4), while it may turn out to only
change 1-sqrt to -1-sqrt.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Still making newbie mistakes
Date: 25 Mar 2013 13:50:00
Message: <web.51508dcec4a906bb78641e0c0@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:
> Cousin Ricky wrote:
>
>  > -Basic_shape (0.4, 0.4)
>
> I suspect this was intended to be the negative value
> of Basic_shape(0.4,0.4), while it may turn out to only
> change 1-sqrt to -1-sqrt.

Bingo.  But you're not a newbie, so the discount goes to the first newbie who
explains why this happens and how to fix it.


Post a reply to this message

Goto Latest 10 Messages Next 7 Messages >>>

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