Home > @quaternion > plot.m

plot

PURPOSE ^

PLOT Plot a quaternion object

SYNOPSIS ^

function plot(Q, off, fmt, color)

DESCRIPTION ^

PLOT Plot a quaternion object 

    PLOT(Q)

 Display the quaternion as a rotated coordinate frame.

 SEE ALSO: QUATERNION

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %PLOT Plot a quaternion object
0002 %
0003 %    PLOT(Q)
0004 %
0005 % Display the quaternion as a rotated coordinate frame.
0006 %
0007 % SEE ALSO: QUATERNION
0008 
0009 % Copyright (C) 1999-2008, by Peter I. Corke
0010 %
0011 % This file is part of The Robotics Toolbox for Matlab (RTB).
0012 %
0013 % RTB is free software: you can redistribute it and/or modify
0014 % it under the terms of the GNU Lesser General Public License as published by
0015 % the Free Software Foundation, either version 3 of the License, or
0016 % (at your option) any later version.
0017 %
0018 % RTB is distributed in the hope that it will be useful,
0019 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0020 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021 % GNU Lesser General Public License for more details.
0022 %
0023 % You should have received a copy of the GNU Leser General Public License
0024 % along with RTB.  If not, see <http://www.gnu.org/licenses/>.
0025 
0026 function plot(Q, off, fmt, color)
0027     %axis([-1 1 -1 1 -1 1])
0028 
0029     if nargin < 2,
0030         off = [0 0 0];
0031     end
0032     if nargin < 3,
0033         fmt = '%c';
0034     end
0035     if nargin < 4,
0036         color = 'b';
0037     end
0038     % create unit vectors
0039     o = [0 0 0]';
0040     x1 = Q*[1 0 0]';
0041     y1 = Q*[0 1 0]';
0042     z1 = Q*[0 0 1]';
0043 
0044     get(gca, 'Tag')
0045     if strcmp(get(gca, 'Tag'), 'trplot') == 0,
0046         fprintf('No tag\n');
0047         clf
0048         axes
0049         set(gca, 'Tag', 'trplot')
0050         fprintf('set tag\n');
0051         xlabel( 'X');
0052         ylabel( 'Y');
0053         zlabel( 'Z');
0054     end
0055     ih = ishold;
0056     hold on
0057     plot3([0;x1(1)]+off(1), [0; x1(2)]+off(2), [0; x1(3)]+off(3), color);
0058     h = text(off(1)+x1(1), off(2)+x1(2), off(3)+x1(3), sprintf(fmt, 'X'));
0059     set(h, 'Color', color);
0060 
0061     plot3([0;y1(1)]+off(1), [0; y1(2)]+off(2), [0; y1(3)]+off(3), color);
0062     h = text(off(1)+y1(1), off(2)+y1(2), off(3)+y1(3), sprintf(fmt, 'Y'));
0063     set(h, 'Color', color);
0064 
0065     plot3([0;z1(1)]+off(1), [0; z1(2)]+off(2), [0; z1(3)]+off(3), color);
0066     h = text(off(1)+z1(1), off(2)+z1(2), off(3)+z1(3), sprintf(fmt, 'Z'));
0067     set(h, 'Color', color);
0068     grid on
0069     if ~ishold,
0070         hold off
0071     end
0072     axis equal

Generated on Sun 15-Feb-2009 18:09:29 by m2html © 2003