From 277d1edfa17bf3719d90ddbac8e31f6181e952c3 Mon Sep 17 00:00:00 2001 From: Sandeep Gupta Date: Sun, 18 Jun 2017 23:55:40 +0530 Subject: First commit --- tests/unit_tests/test305_Moebius/Moebius.sci | 66 ++++++++++++++++++++++++++++ tests/unit_tests/test305_Moebius/XYgrid.sci | 32 ++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 tests/unit_tests/test305_Moebius/Moebius.sci create mode 100644 tests/unit_tests/test305_Moebius/XYgrid.sci (limited to 'tests/unit_tests/test305_Moebius') 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 -- cgit