# What happened when dctimestep convert the BTDF to matrix?

**URL:** <https://discourse.radiance-online.org/t/what-happened-when-dctimestep-convert-the-btdf-to-matrix/6335>\
**Category:** radiance-general\
**Created:** [August 13, 2023, 3:11pm UTC](https://discourse.radiance-online.org/t/what-happened-when-dctimestep-convert-the-btdf-to-matrix/6335 "2023-08-13T15:11:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![1112](https://discourse.radiance-online.org/user_avatar/discourse.radiance-online.org/1112/32/1071_2.png) [@1112](https://discourse.radiance-online.org/u/1112)\
**Post date:** [August 13, 2023, 3:11pm UTC](https://discourse.radiance-online.org/t/what-happened-when-dctimestep-convert-the-btdf-to-matrix/6335/1 "2023-08-13T15:11:52Z")

</div>

When BSDF file was employed in the matrix multiplication by dctimestep, what procedures were conducted to convert the BTDF to matrix? I guess the the BTDF values were multiplied by the projected solid angle to obtain the matrix, however, I found the result is not consistent with the result calculated by dctimestep when I write a python code to validate my thoughts.

The solid angle for klems patch is calculated as following formula:  
(cos(theta1)-cos(theta2))(phi1-phi2)

 ![image](https://discourse.radiance-online.org/uploads/default/original/2X/0/0cb5ae938606e023236486a4984e2357d1e68883.png)

I also read the code of dctimestep, and found the function cm\_loadBTDF, however, I can’t find which file were the ccy2rgb and cm\_bsdf\_recip defined in.

---

<div class="post-metadata">

**Author:** ![Greg\_Ward](https://discourse.radiance-online.org/user_avatar/discourse.radiance-online.org/greg_ward/32/471_2.png) [@Greg\_Ward](https://discourse.radiance-online.org/u/Greg_Ward)\
**Post date:** [August 13, 2023, 4:31pm UTC](https://discourse.radiance-online.org/t/what-happened-when-dctimestep-convert-the-btdf-to-matrix/6335/2 "2023-08-13T16:31:52Z")

</div>

Whenever you can’t find a source routine in Radiance, you can run this from the ray/src directory:

`grep '^routine_name(' */*.c`

The caret (‘^’) matches the beginning of the line, and this is how most routines are defined in Radiance. This will tell you that the cm\_bsdf\_recip() routine is in “util/cmbsdf.c”, along with the cm\_loadBTDF() function you found already. The `ccy2rgb`() function is in “common/ccy2rgb.c”.

You are correct that the BTDF is multiplied by the solid angle for each patch, but I’m not surprised you didn’t get the same result. When using the “Transmission Front” matrix, the cm\_bsdf\_recip() function is called, which converts outgoing indices to incoming patch indices and uses those solid angles as the multipliers.

Cheers,  
-Greg
