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

📄 gmmake_torus.m

📁 matlab有限元分析工具,比经较全面的一个手册,请大家下载呀
💻 M
字号:
function t = gmmake_torus(inner_rad, outer_rad, subdiv)% gmmake_torus: Make a quadratic Bezier approximation to a torus%  t = gmmake_torus(inner_rad, outer_rad, subdiv)% inner_rad is the radius of the 'hole'.% outer_rad is the radius of the entire torus.% The cross-sectional radius is thus .5*(outer_rad-inner_rad).% subdiv is the number of bezier subdivisions in each direction.if outer_rad <= inner_rad | inner_rad <= 0  error('Outer radius must exceed inner radius and both must be positive')endif subdiv < 3  error('Number of subdivisions must be at least 3')endglobal GM_BREP_TYPE_CODE;t = zba({GM_BREP_TYPE_CODE; ...         3; ...         3; ...         {}; ...          zeros(3, 4 * subdiv^2); ...         {}; ...         {}; ...         {'torus_surf'; {}; {}; {}; cell(3,subdiv^2)}; ...         {'torus'; {}; {'torus_surf'}; {}; {}}});tan1 = tan(pi / subdiv);mult = sqrt(1 + tan1^2);rad1 = .5 * (inner_rad + outer_rad);rad2 = .5 * (outer_rad - inner_rad);for j = 0 : 2 * subdiv - 1  cos1 = cos(j * pi / subdiv);  sin1 = sin(j * pi / subdiv);  for k = 0 : 2 * subdiv - 1    cos2 = rad2 * cos(k * pi / subdiv);    sin2 = rad2 * sin(k * pi / subdiv);    x = 0;    if rem(j,2) == 0 & rem(k,2) == 0      y = rad1 + cos2;      z = sin2;    elseif rem(j,2) == 0 & rem(k,2) == 1      y = rad1 + mult*cos2;      z = mult * sin2;    elseif rem(j,2) == 1 & rem(k,2) == 0      y = (rad1 + cos2) * mult;      z = sin2;    else      y = rad1 * mult + cos2 * mult^2;      z = mult * sin2;    end    t{4}(:,j * 2 * subdiv + k) = [cos1*x+sin1*y; -sin1*x+cos1*y; z];  endendfor j = 0 : subdiv - 1  j1 = rem(j + 1, subdiv);  for k = 0 : subdiv - 1     k1 = rem(k + 1, subdiv);    idx = j * subdiv + k;    t{7}{4,0}{0,idx} = 'bezier_quad';    t{7}{4,0}{1,idx} = [2,2];    t{7}{4,0}{2,idx} = [...     j*subdiv*4 + k*2;...     (2*j+1)*subdiv*2 + k*2; ...     j1*subdiv*4 + k*2; ...     j*subdiv*4 + k*2+1;...     (2*j+1)*subdiv*2 + k*2+1; ...     j1*subdiv*4 + k*2+1; ...     j*subdiv*4 + k1*2;...     (2*j+1)*subdiv*2 + k1*2; ...     j1*subdiv*4 + k1*2];   endend				% ------------------------------------------------------------------% Copyright (c) 1999 by Cornell University.  All rights reserved.% See the accompanying file 'Copyright' for authorship information,% the terms of the license governing this software, and disclaimers% concerning this software.% ------------------------------------------------------------------% This file is part of the QMG software.  % Version 2.0 of QMG, release date September 3, 1999% ------------------------------------------------------------------

⌨️ 快捷键说明

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