-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/alouisrogers/MEMs into main
- Loading branch information
Showing
3 changed files
with
168 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
%// Data | ||
xmin = -3; | ||
xmax = 3; %// this piece will get folded into a cylinder | ||
Rc = 5; %// cylinder radius | ||
zmaxc = 5; %// cylinder max z | ||
zminc = -5; %// cylinder min z | ||
|
||
%// Spiral | ||
t = linspace(0,1,1000); | ||
r = 1+2*t; | ||
theta = 2*pi*3*t; | ||
x1 = r.*cos(theta); | ||
y1 = r.*sin(theta); %// example spiral. Defined by x1, y1 | ||
|
||
%// Do the bending | ||
z2 = y1; | ||
phi = (x1-xmin)/(xmax-xmin)*2*pi; | ||
x2 = Rc*cos(phi); | ||
y2 = Rc*sin(phi); | ||
|
||
%// Plot cylinder | ||
[xc yc zc] = cylinder(Rc*ones(1,100),100); | ||
zc = zminc + (zmaxc-zminc)*zc; | ||
surf(xc,yc,zc) | ||
shading flat | ||
hold on | ||
|
||
%// Plot bent spiral | ||
plot3(x2,y2,z2, 'k.-'); |