Trouble using diffuse function

3 ビュー (過去 30 日間)
Jennifer
Jennifer 2024 年 3 月 11 日
コメント済み: Jennifer 2024 年 3 月 11 日
Hello, I'm trying to use the diffuse() function to simulate Lamburtian reflectance off a surface and the help page leaves a bit to be desired. I'm having several errors running the function and was just hoping someone could provide me with an example use of the function so that I can confirm the syntax I'm using is correct.
My end goal is to calculate the reflected light off the surface and compare it to the light that continues past the target and reflects off a second surface. Any help would be greatly appreciated.

採用された回答

Florian Bidaud
Florian Bidaud 2024 年 3 月 11 日
編集済み: Florian Bidaud 2024 年 3 月 11 日
The structure is:
R = diffuse(Nx,Ny,Nz,S)
The output R is defined with Lambert's Law by R = cos(psi) where psi is the angle between the surface normal and light source.
If you have a surface on the (x,y) plan, the normal vector is [Nx,Ny,Nz] = [0,0,1].
S = [Theta Phi] is the direction vector of the light source in spherical coordinates (in degrees).
For example
S = [10 45];
R = diffuse(0,0,1,S)
R = 0.7071
You can also define S in the (x,y,z) coordinates. That would give, to have the same output:
S = [sind(45)*cosd(10) sind(45)*sind(10) cosd(45)];
R = diffuse(0,0,1,S)
R = 0.7071
  1 件のコメント
Jennifer
Jennifer 2024 年 3 月 11 日
Thank you for responding so quickly, my issue was in the S direction syntax. Also thank you for posting an example. My code works now. :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by