summaryrefslogtreecommitdiff
path: root/make_beam_trace.m
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-07-07 15:58:24 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2011-07-07 15:58:24 -0400
commite44a0ee9e32819900d1aebaedd938655811b5143 (patch)
treee1e520525e8454df38ba24991ecb8312e31cf907 /make_beam_trace.m
parenteb0b2b4b8c2186f31483f85dfa1d76890b1d6534 (diff)
downloadwgmr-e44a0ee9e32819900d1aebaedd938655811b5143.tar.gz
wgmr-e44a0ee9e32819900d1aebaedd938655811b5143.zip
make image matrix with beam traces
Diffstat (limited to 'make_beam_trace.m')
-rw-r--r--make_beam_trace.m39
1 files changed, 39 insertions, 0 deletions
diff --git a/make_beam_trace.m b/make_beam_trace.m
new file mode 100644
index 0000000..c2257a6
--- /dev/null
+++ b/make_beam_trace.m
@@ -0,0 +1,39 @@
+function img=make_beam_trace(beam, stop_point, border_limits, img)
+ % img so far beam traced part
+ % border_limits has coordinates of left bottom and right top coners
+ xlb=border_limits(1);
+ ylb=border_limits(2);
+ xrt=border_limits(3);
+ yrt=border_limits(4);
+
+ % beam start stop coordinates with respect to lower left border point
+ xb1=beam.origin(1)-xlb;
+ yb1=beam.origin(2)-ylb;
+ xb2=stop_point(1)-xlb;
+ yb2=stop_point(2)-ylb;
+
+ % beam path coordinates
+ Nc=100; % number of coordinate points
+ xb=linspace(xb1,xb2, Nc);
+ yb=linspace(yb1,yb2, Nc);
+
+ % beam coordinate to image pixel coordinate
+
+ [Ny,Nx]=size(img);
+
+ px=round(xb/(xrt-xlb)*(Nx-1) + 1);
+ py=round(yb/(yrt-ylb)*(Ny-1) + 1);
+
+ % truncate to borders
+ py=py( (1<=px) & (px<=Nx) );
+ px=px( (1<=px) & (px<=Nx) );
+
+ px=px( (1<=py) & (py<=Ny) );
+ py=py( (1<=py) & (py<=Ny) );
+
+ for i=1:length(px)
+ img(py(i),px(i))=beam.intensity;
+ end
+end
+
+