Mercurial > repos > public > sbplib
comparison +parametrization/Ti.m @ 425:e56dbd9e4196 feature/grids
Merge feature/beams
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 07 Feb 2017 16:09:02 +0100 |
parents | 875386d0b2ff |
children | 433ccb5d2f0f |
comparison
equal
deleted
inserted
replaced
423:a2cb0d4f4a02 | 425:e56dbd9e4196 |
---|---|
34 end | 34 end |
35 | 35 |
36 obj.S = @S_fun; | 36 obj.S = @S_fun; |
37 end | 37 end |
38 | 38 |
39 % Does this funciton make sense? | |
40 % Should it always be eval? | |
39 function [X,Y] = map(obj,u,v) | 41 function [X,Y] = map(obj,u,v) |
40 default_arg('v',u); | 42 default_arg('v',u); |
41 | 43 |
42 if isscalar(u) | 44 if isscalar(u) |
43 u = linspace(0,1,u); | 45 u = linspace(0,1,u); |
60 | 62 |
61 for i = 1:nv | 63 for i = 1:nv |
62 p = S(u,v(i)); | 64 p = S(u,v(i)); |
63 X(i,:) = p(1,:); | 65 X(i,:) = p(1,:); |
64 Y(i,:) = p(2,:); | 66 Y(i,:) = p(2,:); |
67 end | |
68 end | |
69 | |
70 % Evaluate S for each pair of u and v, | |
71 % Return same shape as u | |
72 function [x, y] = eval(obj, u, v) | |
73 x = zeros(size(u)); | |
74 y = zeros(size(u)); | |
75 | |
76 for i = 1:numel(u) | |
77 p = obj.S(u(i), v(i)); | |
78 x(i) = p(1,:); | |
79 y(i) = p(2,:); | |
65 end | 80 end |
66 end | 81 end |
67 | 82 |
68 function h = plot(obj,nu,nv) | 83 function h = plot(obj,nu,nv) |
69 S = obj.S; | 84 S = obj.S; |
117 | 132 |
118 for i = 1:length(gs) | 133 for i = 1:length(gs) |
119 new_gs{i} = gs{i}.translate(a); | 134 new_gs{i} = gs{i}.translate(a); |
120 end | 135 end |
121 | 136 |
122 ti = grid.Ti(new_gs{:}); | 137 ti = parametrization.Ti(new_gs{:}); |
123 end | 138 end |
124 | 139 |
125 % Mirrors the Ti so that the resulting Ti is still left handed. | 140 % Mirrors the Ti so that the resulting Ti is still left handed. |
126 % (Corrected by reversing curves and switching e and w) | 141 % (Corrected by reversing curves and switching e and w) |
127 function ti = mirror(obj, a, b) | 142 function ti = mirror(obj, a, b) |
132 new_gs{1} = gs{1}.mirror(a,b).reverse(); | 147 new_gs{1} = gs{1}.mirror(a,b).reverse(); |
133 new_gs{3} = gs{3}.mirror(a,b).reverse(); | 148 new_gs{3} = gs{3}.mirror(a,b).reverse(); |
134 new_gs{2} = gs{4}.mirror(a,b).reverse(); | 149 new_gs{2} = gs{4}.mirror(a,b).reverse(); |
135 new_gs{4} = gs{2}.mirror(a,b).reverse(); | 150 new_gs{4} = gs{2}.mirror(a,b).reverse(); |
136 | 151 |
137 ti = grid.Ti(new_gs{:}); | 152 ti = parametrization.Ti(new_gs{:}); |
138 end | 153 end |
139 | 154 |
140 function ti = rotate(obj,a,rad) | 155 function ti = rotate(obj,a,rad) |
141 gs = obj.gs; | 156 gs = obj.gs; |
142 | 157 |
143 for i = 1:length(gs) | 158 for i = 1:length(gs) |
144 new_gs{i} = gs{i}.rotate(a,rad); | 159 new_gs{i} = gs{i}.rotate(a,rad); |
145 end | 160 end |
146 | 161 |
147 ti = grid.Ti(new_gs{:}); | 162 ti = parametrization.Ti(new_gs{:}); |
148 end | 163 end |
149 | 164 |
150 function ti = rotate_edges(obj,n); | 165 function ti = rotate_edges(obj,n); |
151 new_gs = cell(1,4); | 166 new_gs = cell(1,4); |
152 for i = 0:3 | 167 for i = 0:3 |
153 new_i = mod(i - n,4); | 168 new_i = mod(i - n,4); |
154 new_gs{new_i+1} = obj.gs{i+1}; | 169 new_gs{new_i+1} = obj.gs{i+1}; |
155 end | 170 end |
156 ti = grid.Ti(new_gs{:}); | 171 ti = parametrization.Ti(new_gs{:}); |
157 end | 172 end |
158 end | 173 end |
159 | 174 |
160 methods(Static) | 175 methods(Static) |
161 function obj = points(p1, p2, p3, p4) | 176 function obj = points(p1, p2, p3, p4) |
162 g1 = grid.Curve.line(p1,p2); | 177 g1 = parametrization.Curve.line(p1,p2); |
163 g2 = grid.Curve.line(p2,p3); | 178 g2 = parametrization.Curve.line(p2,p3); |
164 g3 = grid.Curve.line(p3,p4); | 179 g3 = parametrization.Curve.line(p3,p4); |
165 g4 = grid.Curve.line(p4,p1); | 180 g4 = parametrization.Curve.line(p4,p1); |
166 | 181 |
167 obj = grid.Ti(g1,g2,g3,g4); | 182 obj = parametrization.Ti(g1,g2,g3,g4); |
183 end | |
184 | |
185 % Like the constructor but allows inputing line curves as 2-cell arrays: | |
186 % example: parametrization.Ti.linesAndCurves(g1, g2, {a, b} g4) | |
187 function obj = linesAndCurves(C1, C2, C3, C4) | |
188 C = {C1, C2, C3, C4}; | |
189 c = cell(1,4); | |
190 | |
191 for i = 1:4 | |
192 if ~iscell(C{i}) | |
193 c{i} = C{i}; | |
194 else | |
195 c{i} = parametrization.Curve.line(C{i}{:}); | |
196 end | |
197 end | |
198 | |
199 obj = parametrization.Ti(c{:}); | |
168 end | 200 end |
169 | 201 |
170 function label(varargin) | 202 function label(varargin) |
171 if nargin == 2 && ischar(varargin{2}) | 203 if nargin == 2 && ischar(varargin{2}) |
172 label_impl(varargin{:}); | 204 label_impl(varargin{:}); |
188 ps = S( 0.5, margin); | 220 ps = S( 0.5, margin); |
189 pn = S( 0.5, 1-margin); | 221 pn = S( 0.5, 1-margin); |
190 | 222 |
191 | 223 |
192 ti.show(2,2); | 224 ti.show(2,2); |
193 grid.place_label(pc,str); | 225 parametrization.place_label(pc,str); |
194 grid.place_label(pw,'w'); | 226 parametrization.place_label(pw,'w'); |
195 grid.place_label(pe,'e'); | 227 parametrization.place_label(pe,'e'); |
196 grid.place_label(ps,'s'); | 228 parametrization.place_label(ps,'s'); |
197 grid.place_label(pn,'n'); | 229 parametrization.place_label(pn,'n'); |
198 end | 230 end |
199 end | 231 end |
200 end | 232 end |
201 end | 233 end |