The angle of incidence can be calculated as the angle between the direction vector and the boundary normal.
Assuming your direction vector is represented by d
and the boundary normal is represented by n
, you can use MATLAB's dot
function to obtain the dot product of these two vectors. The dot product gives you the cosine of the angle between the two vectors. You can then use acos
function to obtain the angle in radians.
Here's the MATLAB code to calculate the incidence angle:
main.m213 chars12 lines
Note that the dot
function assumes that the vectors are column vectors, so you may need to transpose them if they are row vectors.
gistlibby LogSnag