summaryrefslogtreecommitdiff
path: root/tests/unit_tests/test305_Moebius/Moebius.sci
blob: cb598c0a32653da0c074dc3540a540accbf4f24d (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//SCI2C: DEFAULT_PRECISION= DOUBLE

function Moebius()

//the program construct moebius
// and klein bottle surface from
//http://www.metlin.org/mathematics/
// topological-constructs/non-orientable-surfaces/


// ---------------------
// --- Moebius strip ---
// ---------------------
num_points = 20;
R          = 20;
a          = -0.4;
b          = 0.4;

step=(b-a)./(num_points-1);
step1=(2*%pi)./num_points;
s=a:step:b;
t=0:step1:2*%pi;

[S, T] =  XYgrid(s, t);
x = [R + (S.*cos(T./2))].*cos(T);
y = [R + (S.*cos(T./2))].*sin(T);
z = S.*sin(T./2);

disp('x(1:10)')
disp(x(1:10))
disp('y(1:10)')
disp(y(1:10))
disp('z(1:10)')
disp(z(1:10))

// ENABLE/DISABLE PLOT
// scf(0); surf(x, y, z);

// -----------------------
// --- Klein Bottle II ---
// -----------------------
num_points = 50;

//u = linspace (0, 2*(%pi), num_points);
//v = linspace (0, 2*(%pi), num_points);
step_u = (2*%pi)./num_points
u = 0:step_u:2*%pi;
v = u;

[U,V] = XYgrid(u,v);

x1 = cos(U).*(cos(U./2).*(sqrt(2)+cos(V))+(sin(U./2).*sin(V).*cos(V)));
y1 = sin(U).*(cos(U./2).*(sqrt(2)+cos(V))+(sin(U./2).*sin(V).*cos(V)));
z1 = -1.*sin(U./2).*(sqrt(2)+cos(V))+cos(U./2).*sin(V).*cos(V);

disp('x1(1:10)');
disp(x1(1:10));
disp('y1(1:10)')
disp(y1(1:10))
disp('z1(1:10)')
disp(z1(1:10))
// ENABLE/DISABLE PLOT
// scf(1) ;surf(x1, y1, z1)

endfunction