-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflybody.m
More file actions
executable file
·49 lines (37 loc) · 1.07 KB
/
flybody.m
File metadata and controls
executable file
·49 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [x,y,z,s,th,X,Frenet] = flybody(p,radius,len,PAR)
%[x,y,z,s,th,Y,Frenet] = modcurvespline(p,eta,wormradius,len)
%This approximates the bend angle of the worm with a bspline. THe
%function parameters are the y coordinates of the bspline.
%warning off MATLAB:quadl:MinStepSize;
%warning off MATLAB:quadl:MaxFcnCount;
c = PAR.c; %4;
knotv = oknotP(length(p),c,len,PAR.etamax);
th = linspace(0,2*pi,10);
s = linspace(-len/2,len/2,PAR.L);
%Calculate Centerline and Frenet Frame
[N,D1,D2] = dbasisP(c,s,npts,knotv);
X = N*p;
X = [X zeros(size(X,1),1)];
Tang = D1*p;
Tang = [Tang zeros(size(Tang,1),1)];
MAG = sqrt(sum(Tang.^2,2));
T = Tang./repmat(MAG,1,3);
skew_z = [0 -1 0
1 0 0
0 0 0];
N = (skew_z*T')';
B = repmat([0 0 1],size(N,1),1);
R = radiusspline1(s',radius,length(s),0,len);
TEMP = zeros(size(X));
for j = 1:length(th)
for i = 1:3
TEMP(:,i) = R.*(-cos(th(j)).*N(:,i) + sin(th(j)).*B(:,i));
end
RR = X + TEMP;
x(:,j) = RR(:,1);
y(:,j) = RR(:,2);
z(:,j) = RR(:,3);
end
Frenet.T = T;
Frenet.N = N;
Frenet.B = B;