- /
-
By Order of the Peaky Cosine
on 9 Oct 2024
- 12
- 81
- 1
- 0
- 633
Cite your audio source here (if applicable):
drawframe(96);
Write your drawframe function below
function drawframe(f)
n = 3800;
xPos = 2*rand(n,1) - 1;
yPos = 2*rand(n,1) - 1;
xSpeed = zeros(n,1);
ySpeed = zeros(n,1);
T = 9.6/2;
dt = 0.01;
nSteps = T/dt;
bypass = nSteps/96;
p = 0;
ax = axes('Position',[0,0,1,1]);
col = [ones(n,1), abs(xPos)./max(xPos), abs(yPos)./max(yPos)];
plt = scatter(xPos,yPos,20,col,'filled','Marker','o');
ax.Color = 'k';
xlim([-1.7,1.7])
ylim([-1.7,1.7])
for i = 1:nSteps
% Get Force
xForce = -tan(3*(xPos).*2.*cos(yPos));
yForce = -cos(5*yPos);
% Integrate
xSpeed = xSpeed + xForce*dt;
ySpeed = ySpeed + yForce*dt;
xPos = xPos + xSpeed*dt;
yPos = yPos + ySpeed*dt;
% pick frame
if mod(i,bypass)==0
p = p + 1;
plt.XData = xPos;
plt.YData = yPos;
end
if p == f
drawnow
break
end
end
end
Movie
Audio
This submission does not have audio.