aboutsummaryrefslogtreecommitdiff
path: root/example.m
blob: 0b1e85550c03035b870fe7c20b0bd40ee9428b17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
beam.k=[1,-.5];
beam.origin=[0,0];
beam.face=NA;

face.vertex1=[1.1,-1];
face.vertex2=[2.7,1];
face.n_right = 1;
face.n_left= 2.5;

face2.vertex1=[-.1,-3];
face2.vertex2=[-.1,3];
face2.n_right = 1;
face2.n_left= 1;

face3.vertex1=[2.1,-3];
face3.vertex2=[2.1,3];
face3.n_right = 1.5;
face3.n_left= 1;

faces={face,face2,face3};

[is_face_hit, hit_position, hit_distance, new_beams] =  face_beam_interaction(beam, faces);
beam_reflected=new_beams{1};
beam_refracted=new_beams{2};


[is_face_hit, hit_position, hit_distance, new_beams] =  face_beam_interaction(beam_reflected, faces);

[is_face_hit, hit_position, hit_distance, new_beams] =  face_beam_interaction(beam_refracted, faces);