-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotcoord3.m
More file actions
40 lines (38 loc) · 1.31 KB
/
Copy pathplotcoord3.m
File metadata and controls
40 lines (38 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function plotcoord3(transform,axis_length,X_colour,Y_colour,Z_colour)
%Plots a 3D coordinate frame given a transform, the axis length and colours
%for each axis
%e.g.
% R = eye(3); t = [0 0 0]';
%plotcoord3([R, t; 0 0 0 1],1,'r','g','b')
%
%this plots a coordinate frame at the origin with a red x-axis, green
%y-axis and a blue z-axis
%
%Tips: other useful functions related to this after plotting...
%
% title('3D View (X-Y-Z)'), xlabel('X displacement')
% ylabel('Y displacement'), zlabel('Z displacement')
% view(3)
% daspect([1 1 1]) % makes axes equal in 3D
% grid on
%
%written by Andrew Razjigaev
%Axis Lengths of the axes on the robot coordinate frame
px = [axis_length; 0; 0; 1]; py = [0; axis_length; 0; 1]; pz = [0; 0; axis_length; 1];
%Homogeneous transform of the axes
x = transform(1,4); y = transform(2,4); z = transform(3,4);
%Computed points of axes:
px_point = transform*px;
py_point = transform*py;
pz_point = transform*pz;
%disp(transform)
%X axis
plot3([x; px_point(1)], [y; px_point(2)], [z; px_point(3)], X_colour)
hold on
%Y axis
plot3([x; py_point(1)], [y; py_point(2)], [z; py_point(3)], Y_colour)
hold on
%Z axis
plot3([x; pz_point(1)], [y; pz_point(2)], [z; pz_point(3)], Z_colour)
hold on
end