⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 optf_coshyp.htm

📁 Matlab实现光线跟踪算法
💻 HTM
字号:
<HTML>                                              <HEAD>                                                <TITLE>/</TITLE>                                    <META NAME="GENERATOR" CONTENT="HTML-TOOLBOX ">   </HEAD>                                             <BODY bgcolor="#FFFFF0"> <HR WIDTH="100%"></P> <CENTER><P><FONT COLOR="#000000"><FONT SIZE=+3>Cross-linked m-file</FONT></FONT></P></CENTER> <CENTER><P><FONT COLOR="#000000"><FONT SIZE=+1></FONT></FONT></P></CENTER> <CENTER><P><FONT COLOR="#000000"><FONT SIZE=+2>optf_coshyp.m</FONT></FONT></P></CENTER> <CENTER><P><FONT COLOR="#000000"><FONT SIZE=+1>Located in:</FONT></FONT></P></CENTER> <CENTER><P><FONT COLOR="#000000"><FONT SIZE=+1>/home/bjorn/matlab/Optical_bench</FONT></FONT></P></CENTER> <P><HR WIDTH="100%"></P> <P><FONT COLOR="#000000"><FONT SIZE=+2>Function synopsis</FONT></FONT></P> <P><FONT COLOR="#000000"><FONT SIZE=+1> function out_arg = optf_hyperbolic(r,s_or_n,arglist)                                                                                                </FONT></FONT></P> <P><HR WIDTH="100%"></P> <P><FONT COLOR="#000000"><FONT SIZE=+2>Function comments</FONT></FONT></P> <pre> % % OPTF_HYPERBOLC defines a cosh lens surface % Called with optf_hyperbolic(R,'s',arglist) the function should % return 0 (zero) when R is on the lens surface and monotonically % growing scalars when R deviates. When R is outside the lens area % but on the analytical extension of the lens surface the function % should return a scalar smaller than -2eps or larger than 2eps. % Called with  optf_hyperbolic(R,'n',arglist) the functnion should % return the normal of the lens surface. If you want the surface to % appear in a plot of the optics the function should respond with a % proper surface plot when called with % optf_hyperbolic(R,'p',arglist) ARGLIST will be a struct as % produced by OPT_FCN. </pre> <P><HR WIDTH="100%"></P> <P><FONT COLOR="#000000"><FONT SIZE=+1>All the cross references in the source m-code of optf_coshyp.m</FONT></FONT></P> <pre> function out_arg = optf_coshyp(r,s_or_n_or_p,arglist) % function out_arg = optf_hyperbolic(r,s_or_n,arglist) % % OPTF_HYPERBOLC defines a cosh lens surface % Called with optf_hyperbolic(R,'s',arglist) the function should % return 0 (zero) when R is on the lens surface and monotonically % growing scalars when R deviates. When R is outside the lens area % but on the analytical extension of the lens surface the function % should return a scalar smaller than -2eps or larger than 2eps. % Called with  optf_hyperbolic(R,'n',arglist) the functnion should % return the normal of the lens surface. If you want the surface to % appear in a plot of the optics the function should respond with a % proper surface plot when called with % optf_hyperbolic(R,'p',arglist) ARGLIST will be a struct as % produced by OPT_FCN.    % parsing of the arglist structure. r0 = arglist.r0;                  % The lenssurface reference point lens_rot = arglist.rotmat;        % Rotation matrix of the lens f = arglist.focals;               % The shape parameters lens_diameter = arglist.diameter; % Diameter of the lens.  r = lens_rot'*(r-r0)';  switch s_or_n_or_p  case 's'   % calculate the some distance between r and the surface   % equation for the surface f(x,y,z) = 0   out_arg = abs(f(3)*(cosh((r(2).^2/f(1).^2+r(3).^2/f(2).^2).^.5)-1)-r(1));   if r(1)^2+r(2)^2 > lens_diameter^2/4;     out_arg = out_arg+1;   end  case 'n'   % calculate the surface normal at point r   % The surface normal is -grad(f)   out_arg = [-1 ...              f(3)*r(2)/f(1)^2./((r(2).^2/f(1).^2+r(3).^2/f(2).^2).^.5)*sinh((r(2).^2/f(1).^2+r(3).^2/f(2).^2).^.5) ...              f(3)*r(3)/f(2)^2./((r(2).^2/f(1).^2+r(3).^2/f(2).^2).^.5)*sinh((r(2).^2/f(1).^2+r(3).^2/f(2).^2).^.5)];   out_arg = -out_arg/norm(out_arg);  case 'p'   % plot the surface   y = -lens_diameter/2:lens_diameter/40:lens_diameter/2;   z = -lens_diameter/2:lens_diameter/40:lens_diameter/2;   [y,z] = meshgrid(y,z);   x = f(3)*(cosh((y.^2/f(1).^2+z.^2/f(2)^2).^.5)-1);   R = [x(:) y(:) z(:)];   ii = find(R(:,2).^2+R(:,3).^2>lens_diameter^2/4);   R(ii,1) = nan;   R(ii,2) = nan;   R(ii,3) = nan;   R = lens_rot'*R';    x(:) = R(1,:)+r0(1);   y(:) = R(2,:)+r0(2);   z(:) = R(3,:)+r0(3);   %outarg needs to be set, and what more apropriate then the handle?   out_arg = surf(x,y,z,ones(size(z))*rand(1));   shading faceted;  otherwise   error('Value of s_or_n_or_p (',s_or_n_or_p,') out of range (''s'',''n'',''p'')') end </pre> <P><HR WIDTH="100%"></P> <P><I><FONT COLOR="#0000FF"><FONT SIZE=+1>Written by  B. Gustavsson 13:27 29/1 2003 <IMG SRC = "file:/home/bjorn/matlab/Local/Tools/htmltool/gifs/copyright.gif" ></FONT></FONT></I></P> <P><I><FONT COLOR="#0000FF"><FONT SIZE=+1>E-mail:</B><A HREF = "mailto:bjorn@irf.se">bjorn@irf.se</A></H4></FONT></FONT></I></P> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -