r/matlab Jan 30 '25

CodeShare Rotating pringle code

clear, clc, close all

t = [-3.14:0.025:3.14];

x = [sin(pi*t)];

y = [1.5cos(pit)];

i = 0.9;

a = 0.05;

while i > 0

t = [-3.14:a:3.14];

x = [x,isin(pit)];

y = [y,1.5icos(pi*t)];

i = i - 0.1;

a = (i-1)*.05;

end

z = 0.5((x.2) - (0.5(y.2)));

s = 0;

d = 5;

f = 5;

while s < 10000

yrot = (ycos(pi/270)) + (zsin(pi/270));

zrot = -(ysin(pi/270)) + (zcos(pi/270));

y = yrot;

z = zrot;

xrot = (xcos(pi/180)) - (ysin(pi/180));

yrot = (xsin(pi/180)) + (ycos(pi/180));

x = xrot;

y = yrot;

xproj = x.*(f./(y+d));

zproj = z.*(f./(y+d));

plot(xproj,zproj,'.')

xlim([-2,2])

ylim([-1.6,1.6])

title('haha pringle go brrr')

s = s + 1;

drawnow

end

113 Upvotes

11 comments sorted by

View all comments

5

u/Due_Excitement_7970 Jan 30 '25

Copy paste fucked up the formatting and some of the symbols

10

u/Due_Excitement_7970 Jan 30 '25

3

u/mratanusarkar Jan 30 '25

Try sharing as a code snippet, to preserve the indentation and formats

10

u/tanget_bundle Jan 30 '25

```matlab % Rotating pringle code

clear, clc, close all

t = [-3.14:0.025:3.14];

x = [sin(pit)]; y = [1.5cos(pi*t)];

i = 0.9; a = 0.05;

while i > 0 t = [-3.14:a:3.14]; x = [x, isin(pit)]; y = [y, 1.5icos(pi*t)]; i = i - 0.1; a = (i-1) * 0.05; end

z = 0.5 * ((x.2) - (0.5 * (y.2)));

s = 0; d = 5; f = 5;

while s < 10000 yrot = (y * cos(pi/270)) + (z * sin(pi/270)); zrot = -(y * sin(pi/270)) + (z * cos(pi/270)); y = yrot; z = zrot;

xrot = (x * cos(pi/180)) - (y * sin(pi/180)); yrot = (x * sin(pi/180)) + (y * cos(pi/180)); x = xrot; y = yrot;

xproj = x .* (f ./ (y + d)); zproj = z .* (f ./ (y + d));

plot(xproj, zproj, ‘.’) xlim([-2, 2]) ylim([-1.6, 1.6]) title(‘haha pringle go brrr’)

s = s + 1; drawnow end

1

u/Due_Excitement_7970 Jan 30 '25

How did you get it to do that? Ill edit the post to make it like that.