# rcalc if, else, then

HI Group,

This is bugging me and possibly easy to resolve but I'm struggling. I am testing materials and their reflectance and need to use rcalc to help me identify which materials my ray is hitting.

Using a simple mirror material I have created a blue material with close to 0 red and green. I have fired a ray in the direction of this material and now I need to determine whether it is a hit. Using -ab 0 I get the following result:

5.475634e+01 5.475634e+01 2.737817e+02

My material is below:

void mirror wall
0
0
3 0.2 0.2 1

I'd like to use rcalc to tell me whether I am hitting the material or not. I was thinking of something like

rcalc -e 'if(\$1=\$3,\$1=1,\$1=0)' test.dat > test_res.dat simply to give me a Boolean dat file of either 1 or 0.

But obviously that doesn't work so can someone help me with a possible solution? I've trawled the mailing list to no avail so far.

Many Thanks

Dan

Hi Dan,

I don't know why you wouldn't use the rtrace -om option, but doing it your way, you just need the right syntax:

rcalc -e '\$1=if(\$3-2*\$1-2*\$2,1,0)' test.dat > test_res.dat

I chose these factors based on your material that reflects 5x as much blue as red and green. The above should work for white illumination and assuming you don't have other blue materials in your scene.

Best,
-Greg

···

From: Dan Fitzpatrick <danf@eb7.co.uk>
Date: May 11, 2010 2:15:32 PM PDT

HI Group,

This is bugging me and possibly easy to resolve but I'm struggling. I am testing materials and their reflectance and need to use rcalc to help me identify which materials my ray is hitting.

Using a simple mirror material I have created a blue material with close to 0 red and green. I have fired a ray in the direction of this material and now I need to determine whether it is a hit. Using -ab 0 I get the following result:

5.475634e+01 5.475634e+01 2.737817e+02

My material is below:

void mirror wall
0
3 0.2 0.2 1

I'd like to use rcalc to tell me whether I am hitting the material or not. I was thinking of something like

rcalc -e 'if(\$1=\$3,\$1=1,\$1=0)' test.dat > test_res.dat simply to give me a Boolean dat file of either 1 or 0.

But obviously that doesn't work so can someone help me with a possible solution? I've trawled the mailing list to no avail so far.

Many Thanks

Dan

Hi Greg,

I don't know why you wouldn't use the rtrace -om option

I'm also eventually testing the direct solar reflectance from my trace point so I felt that the rcalc method would answer both questions. It would probably have made it more clear if I explained that originally. Thanks for the quick response, it works like a charm.

Cheers

Dan