function [] = Beam7Display( X, Xo, Ref ) % Observer x = Xo(1); q = Xo(2); dx = Xo(3); dq = Xo(4); % draw the beam x1 = -2*cos(q); y1 = -2*sin(q); x2 = 2*cos(q); y2 = 2*sin(q); clf; plot([-2.5,2.5],[-1,1],'x'); hold on plot([x1,x2],[y1,y2],'g'); plot(0,0,'.'); % draw the ball i = [0:0.1:1]' * 2*pi; xb = x*cos(q) + 0.05*cos(i) - 0.05*sin(q); yb = x*sin(q) + 0.05*sin(i) + 0.05*cos(q); plot(xb,yb,'g'); % draw a line through the ball so you can see it roll Q = -x / 0.05; x1 = x*cos(q) - 0.05*sin(q) + 0.05*cos(Q); y1 = x*sin(q) + 0.05*cos(q) + 0.05*sin(Q); Q = Q + pi; x2 = x*cos(q) - 0.05*sin(q) + 0.05*cos(Q); y2 = x*sin(q) + 0.05*cos(q) + 0.05*sin(Q); plot([x1,x2],[y1,y2],'g-', Ref*cos(q), Ref*sin(q), 'gx'); %--------------------------------------------------------- % plant x = X(1); q = X(2); dx = X(3); dq = X(4); % draw the beam x1 = -2*cos(q); y1 = -2*sin(q); x2 = 2*cos(q); y2 = 2*sin(q); plot([x1,x2],[y1,y2],'b'); plot(0,0,'.'); % draw the ball i = [0:0.1:1]' * 2*pi; xb = x*cos(q) + 0.05*cos(i) - 0.05*sin(q); yb = x*sin(q) + 0.05*sin(i) + 0.05*cos(q); plot(xb,yb,'r'); % draw a line through the ball so you can see it roll Q = -x / 0.05; x1 = x*cos(q) - 0.05*sin(q) + 0.05*cos(Q); y1 = x*sin(q) + 0.05*cos(q) + 0.05*sin(Q); Q = Q + pi; x2 = x*cos(q) - 0.05*sin(q) + 0.05*cos(Q); y2 = x*sin(q) + 0.05*cos(q) + 0.05*sin(Q); plot([x1,x2],[y1,y2],'r-', Ref*cos(q), Ref*sin(q), 'bx'); pause(0.01); hold off end