POV-Ray : Newsgroups : povray.newusers : #debug outputs incorrect value Server Time
23 Dec 2024 15:28:20 EST (-0500)
  #debug outputs incorrect value (Message 1 to 4 of 4)  
From: Timwi
Subject: #debug outputs incorrect value
Date: 21 Mar 2009 15:23:51
Message: <49c53ec7$1@news.povray.org>
Hi again :)

Why does str() always return zeroes even for values that aren't zero?

Example:


#include "metals.inc"

#debug "A_GoldD = "
#debug concat(str(A_GoldD.x,5,0), ", ")
#debug concat(str(A_GoldD.y,5,0), ", ")
#debug concat(str(A_GoldD.z,5,0), "\n")

#debug concat("D_GoldD = ", str(D_GoldD, 5, 0), "\n")


This outputs all zeroes, but if I replace "diffuse D_GoldD" and "ambient 
A_GoldD" in the definition of T_Chrome_2D with "diffuse 0" and "ambient 
0", I get a very different material. Therefore I assume the values 
aren't actually zero.

How do I output the correct values?

Thanks
Timwi


Post a reply to this message

From: Warp
Subject: Re: #debug outputs incorrect value
Date: 21 Mar 2009 15:50:37
Message: <49c5450d$1@news.povray.org>
Timwi <tim### [at] gmxnet> wrote:
> Why does str() always return zeroes even for values that aren't zero?

  Because you told it to print 0 decimals (which causes it to round the
value appropriately)?

-- 
                                                          - Warp


Post a reply to this message

From: clipka
Subject: Re: #debug outputs incorrect value
Date: 21 Mar 2009 16:00:00
Message: <web.49c54714cf18ff741685c200@news.povray.org>
Timwi <tim### [at] gmxnet> wrote:
> Why does str() always return zeroes even for values that aren't zero?

Well, simple - because you're using it wrong ;)

The 3rd parameter controls the display precision of the fractional part in
powers of 0.1 (i.e. the number of digits to display after the decimal point);
setting it to zero therefore gives you only the integer part of the value. As
the numbers you intend to display are all quite small, POV will consequently
round them to zero.

Set the 3rd parameter to -1 to have POV automatically pick a (more or less)
suitable precision, or to e.g. 3 to have POV display the numbers to a precision
of 0.001.


Post a reply to this message

From: Timwi
Subject: Re: #debug outputs incorrect value
Date: 21 Mar 2009 19:44:22
Message: <49c57bd6$1@news.povray.org>
clipka wrote:
> Timwi <tim### [at] gmxnet> wrote:
>> Why does str() always return zeroes even for values that aren't
>> zero?
> 
> The 3rd parameter controls the display precision of the fractional
> part in powers of 0.1 (i.e. the number of digits to display after the
> decimal point); setting it to zero therefore gives you only the
> integer part of the value. [...] Set the 3rd parameter to -1 to have
> POV automatically pick a (more or less) suitable precision

Thanks a lot! :)


Post a reply to this message

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