summaryrefslogtreecommitdiff
path: root/tests/unit_tests/test305_Moebius
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests/test305_Moebius')
-rw-r--r--tests/unit_tests/test305_Moebius/Moebius.sci66
-rw-r--r--tests/unit_tests/test305_Moebius/XYgrid.sci32
2 files changed, 98 insertions, 0 deletions
diff --git a/tests/unit_tests/test305_Moebius/Moebius.sci b/tests/unit_tests/test305_Moebius/Moebius.sci
new file mode 100644
index 0000000..cb598c0
--- /dev/null
+++ b/tests/unit_tests/test305_Moebius/Moebius.sci
@@ -0,0 +1,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
+
diff --git a/tests/unit_tests/test305_Moebius/XYgrid.sci b/tests/unit_tests/test305_Moebius/XYgrid.sci
new file mode 100644
index 0000000..0957237
--- /dev/null
+++ b/tests/unit_tests/test305_Moebius/XYgrid.sci
@@ -0,0 +1,32 @@
+//SCI2C: NIN= 2
+//SCI2C: NOUT= 2
+//SCI2C: OUT(1).TP= IN(1).TP
+//SCI2C: OUT(1).SZ(1)= IN(2).SZ(2)
+//SCI2C: OUT(1).SZ(2)= IN(1).SZ(2)
+//SCI2C: OUT(2).TP= IN(1).TP
+//SCI2C: OUT(2).SZ(1)= IN(2).SZ(2)
+//SCI2C: OUT(2).SZ(2)= IN(1).SZ(2)
+//SCI2C: DEFAULT_PRECISION= DOUBLE
+
+// ------------------------------------
+// this script emulate the matlab meshgrid
+// only for bidimensional mesh.
+// ------------------------------------
+
+function [X,Y] = XYgrid(x,y)
+
+n = length(x);
+m = length(y);
+
+X=zeros(m,n);
+Y=zeros(m,n);
+
+for k=1:m
+ X(k,1:n)=x;
+end
+
+for h=1:n
+ Y(1:m,h)=y';
+end
+
+endfunction