📄 plotfig7.m
字号:
function pts = plotFig7(plotOn)% generate a bunch of points on the barrier%% if plotOn == 1 (not default), generates a figure like figure 7 from% A.W.Merz, "The Game of Two Identical Cars", pp.324 -- 343% Journal of Optimization Theory and Applications, 9, 5 (1972)%% Ian Mitchell, 1/21/01if(nargin < 1) plotOn = 0;endpauseOn = 1;% Set up some slices% must offset slice at 0 slightly to avoid going out of level set gridslices = [ -pi:pi/100:-pi/100, -1e-4 ];beta = 1;scale = [ 5, 5, 1 ];offset = [ 0, 0, 2 * pi ];coordinateOrder = [ 2 1 3 ];aspect = scale;%styles = { '-*'; '-*'; '-*' };styles = { '-'; '-'; '-' };%styles = { '-'; '--'; '-.' };%styles = { 'x-'; 's-'; 'o-' };%colors = { 'b'; 'b'; 'b' };colors = { 'b'; 'r'; 'm' };if(plotOn) if(pauseOn) figure; hold off; else %figure; hold on; endendpts = zeros(0, 3);for i = 1:length(slices) [ xp xm xc ] = barrier(slices(i), beta); % line coordinate system up with aircraft3d scalep = repmat(scale, size(xp, 1), 1); scalem = repmat(scale, size(xm, 1), 1); scalec = repmat(scale, size(xc, 1), 1); offsetp = repmat(offset, size(xp, 1), 1); offsetm = repmat(offset, size(xm, 1), 1); offsetc = repmat(offset, size(xc, 1), 1); xp = xp(:, coordinateOrder) .* scalep + offsetp; xm = xm(:, coordinateOrder) .* scalem + offsetm; xc = xc(:, coordinateOrder) .* scalec + offsetc; if(plotOn) plot3(xp(:,1), xp(:,2), xp(:,3), [ colors{1}, styles{1} ], ... xm(:,1), xm(:,2), xm(:,3), [ colors{2}, styles{2} ], ... xc(:,1), xc(:,2), xc(:,3), [ colors{3}, styles{3} ]); if(pauseOn) disp([ 'i = ' num2str(i) ', psi = ' num2str(slices(i)) ]); daspect(aspect); view(2); grid on; xlabel('x'); ylabel('y'); zlabel('\theta'); pause; end end pts = [ pts; xp; xm; xc ];endif(plotOn & ~pauseOn) daspect(aspect); view(2); grid on; xlabel('x'); ylabel('y'); zlabel('\theta');end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -