• /
• # Sub-OTOMic motion

on 25 Nov 2023
• 13
• 17
• 0
• 0
• 1186
drawframe(1);
function drawframe(f)
% function drawframe(f)
% Parameters
numPoints = 100;
angles = linspace(0, 2*pi, numPoints);
rotationSpeed = 2*pi/100; % radians per frame
g=gca;
% Create figure
figure;
axis equal;
hold on;
% Plot the circle
theta = linspace(0, 2*pi, 100);
h=plot(x_circle, y_circle, 'LineWidth', 2,'LineStyle','none');
% Initialize point
pointY = 0;
grid off;
fill(x_circle, y_circle, [0.1 0.1 0.1], 'FaceAlpha', 0.3,'EdgeColor','none');
material shiny;
axis off;
set(gcf,'Color','k');
view([0 90]);
axis equal;
L1=light("Style","local","Position",[pointX, pointY, 10],'Color','y');
L2=light("Style","local","Position",[pointY, pointX, 15],'Color','b');
h1=plot(1, 1, 'w*', 'MarkerSize', 10);
h2=plot(1, 1, 'w','LineWidth',0.001,'LineStyle',':');
for ii=1:5
L1.Color=rand(1,3);
L2.Color=rand(1,3);
% Plot and rotate the point
for frame = 1:2:2*f
% numPoints
% Plot the rotating point inside the circle
x_p=[repmat(pointX,[1 numPoints]); x_circle;nan(1 ,numPoints) ];
y_p=[ repmat(pointY,[1 numPoints]);y_circle;nan(1 ,numPoints) ] ;
% Plot a line connecting the point to the circle
h1.XData=pointX;
h1.YData=pointY;
h2.XData=x_p(1:2:end);
h2.YData=y_p(1:2:end);
h.XData=h.XData +pointX/3;
% Rotate the point
pointX = radius/1.6 * cos(angles(frame) + rotationSpeed);
pointY = radius/1.3 * sin(angles(frame) + rotationSpeed);
% light('Position', [pointX, pointY, 10]);
L1.Position=[pointX, pointY, 10];
L2.Position=[pointY, pointX, 15];
% Pause for a short time to make the rotation visible
% pause(0.02);
g.CameraViewAngle=2;
% Clear the previous point and line
if frame < numPoints
% clf;
% hold on;
% % plot(x_circle, y_circle, 'LineWidth', 2);
% fill(x_circle, y_circle, [0.1 0.1 0.1], 'FaceAlpha', 0.3,'EdgeColor','none');
% delete(h1);
% delete(h2);
end
end
end
hold off;
end