Rtrace decimal output

Dear all,

I would like to get decimal outputs after running rtrace. The default output is in scientific format like below:

3.304742e+02 3.304742e+02 3.304742e+02
3.304742e+02 3.304742e+02 3.304742e+02
4.516701e+02 4.516701e+02 4.516701e+02

I would like to get 330.4742 instead of 3.304742e+02

Thank you for your support.

I suppose you can feed the output of rtrace into rcalc, which will read and reformat it. This isn’t 100% guaranteed, though, as I think rcalc uses the “%g” formatting, which could still resort to scientific notation for very large or very small numbers:

rtrace -h [options] octree | rcalc -e '$1=$1;$2=$2;$3=$3'

This is more of a C standard library thing than it is a Radiance thing. If you want to control formatting in rtrace, you will need to modify the “puta()” function in ray/src/rtrace.c so it doesn’t use the “%e” formatting.

Cheers,
-Greg

1 Like

Thank you. I will try and let you know.

I have tried your suggestion but got syntax error:

rtrace -h [options] octree | rcalc -e ‘$1=$1;$2=$2;$3=$3’

Here is my syntax without your suggestion:

rtrace -af output\ambientFile [options] output\trial.oct < sensorpoints\subdivided.pts > output\trial.dt

Could you please help me to re-write it?

On the other hand, I have changed the rtrace.c by replacing “%e” with “%d”. However, I couldn’t compile Radiance on Windows OS. I got many errors, solved some of them but still have errors like missing QT5 widgets.

Edit: I have built “headless” with success. New rtrace.exe gives decimal output. But now the values are not matching, they are even completely different. Here are first 3 rows:

3.304742e+002 3.304742e+002 3.304742e+002
3.304742e+002 3.304742e+002 3.304742e+002
4.487080e+002 4.487080e+002 4.487080e+002
1610612736 1610612736 1610612736
1610612736 1610612736 1610612736
0 0 0

Edit2: I have changed the “rtrace.c” by replacing “%e” with “%f” and after CMake, opened the solution in Visual Studio and built only rtrace.exe. Now I am getting float values:

330.474213 330.474213 330.474213
330.474213 330.474213 330.474213
445.688354 445.688354 445.688354

Is there any way to get only integers?

Edit3: replacing “%e” with “%0.0f” solved the issue.

Your syntax error in the rcalc example is because you are running under Windows, which I didn’t know. You can’t use single-quotes on the usual Windows command line, so you have to use double-quotes, instead:
rtrace -h [options] octree | rcalc -e "$1=$1;$2=$2;$3=$3"
Under Unix, you must use single-quotes, which is why I wrote it that way the first time.

Glad you managed to work through the formatting issues in the C code. Now that you know how to alter the code and rebuild the executables, you can do whatever you like!

1 Like

Thank you. I have thought the single quote issue, too. However, later I need more specific output from rtrace. For instance the default code adds “tab” at the end of all lines which is not useful when reading the data with another script. Therefore directly editing the code was much more helpful. Thank you again.

Hi,

this is really a standard conversion task, so instead of modifiying code I recommend to just make use of common text processing tools, e. g. rtrace (...) | awk '{printf "%f %f %f\n", $1, $2, $3}' or rtrace (...) | xargs printf "%f ". Getting used to these will be useful often when processing inputs or resutls.

Best, Lars.

1 Like