Mercurial > repos > public > sbplib
comparison +parametrization/Curve.m @ 333:0fd4b259af9e feature/beams
Fixed some bugs in parametrization.Curve.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 04 Oct 2016 11:43:35 +0200 |
parents | 81e0ead29431 |
children | 0776fa4754ff |
comparison
equal
deleted
inserted
replaced
332:875386d0b2ff | 333:0fd4b259af9e |
---|---|
66 set(h,'Color',Color.red); | 66 set(h,'Color',Color.red); |
67 obj.plot(m); | 67 obj.plot(m); |
68 end | 68 end |
69 | 69 |
70 function h= show(obj,name) | 70 function h= show(obj,name) |
71 default_arg('name', '') | |
71 p = obj.g(1/2); | 72 p = obj.g(1/2); |
72 n = obj.normal(1/2); | 73 n = obj.normal(1/2); |
73 p = p + n*0.1; | 74 p = p + n*0.1; |
74 | 75 |
75 % Add arrow | 76 % Add arrow |
76 | 77 |
77 h = text(p(1),p(2),name); | 78 |
78 h.HorizontalAlignment = 'center'; | 79 if ~isempty(name) |
79 h.VerticalAlignment = 'middle'; | 80 h = text(p(1),p(2),name); |
80 | 81 h.HorizontalAlignment = 'center'; |
81 obj.plot(); | 82 h.VerticalAlignment = 'middle'; |
83 end | |
84 | |
85 h = obj.plot(); | |
82 end | 86 end |
83 % Shows curve with name and arrow for direction. | 87 % Shows curve with name and arrow for direction. |
84 | 88 |
85 % Length of arc from parameter t0 to t1 (which may be vectors). | 89 % Length of arc from parameter t0 to t1 (which may be vectors). |
86 % Computed using derivative. | 90 % Computed using derivative. |
264 | 268 |
265 function v = g_fun(t) | 269 function v = g_fun(t) |
266 v(1,:) = p1(1) + t.*(p2(1)-p1(1)); | 270 v(1,:) = p1(1) + t.*(p2(1)-p1(1)); |
267 v(2,:) = p1(2) + t.*(p2(2)-p1(2)); | 271 v(2,:) = p1(2) + t.*(p2(2)-p1(2)); |
268 end | 272 end |
269 g = @g_fun; | 273 |
270 | 274 function v = g_fun_deriv(t) |
271 obj = parametrization.Curve(g); | 275 v(1,:) = t.*0 + (p2(1)-p1(1)); |
276 v(2,:) = t.*0 + (p2(2)-p1(2)); | |
277 end | |
278 | |
279 obj = parametrization.Curve(@g_fun, @g_fun_deriv); | |
272 end | 280 end |
273 | 281 |
274 function obj = circle(c,r,phi) | 282 function obj = circle(c,r,phi) |
275 default_arg('phi',[0; 2*pi]) | 283 default_arg('phi',[0; 2*pi]) |
276 default_arg('c',[0; 0]) | 284 default_arg('c',[0; 0]) |