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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
//
// This file is distributed under the same license as the Scilab package.
//
// =============================================================================
// hole3d()
// =============================================================================
function hole3d()
// Holes in surfaces using %inf
t=linspace(-%pi,%pi,40);z=sin(t)'*cos(t);
z1=find(abs(z) > 0.5);
z(z1)=%inf*z1;
plot3d1(t,t,z);
endfunction
// =============================================================================
// hole3d1()
// =============================================================================
function hole3d1()
// Holes in surfaces using %inf
deff('[x,y,z]=sph(alp,tet)',['x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)';
'y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)';
'z=r*sin(alp)+orig(3)*ones(tet)']);
r=1;orig=[0 0 0];
x=linspace(-%pi/2,%pi/2,40);y=linspace(0,%pi*2,20);
x(5:8)=%inf*ones(5:8);
x(30:35)=%inf*ones(30:35);
[x1,y1,z1]=eval3dp(sph,x,y);
plot3d1(x1,y1,z1);
endfunction
// =============================================================================
// sphere()
// =============================================================================
function sphere
u = linspace(-%pi/2,%pi/2,40);
v = linspace(0,2*%pi,20);
x= cos(u)'*cos(v);
y= cos(u)'*sin(v);
z= sin(u)'*ones(v);
plot3d2(x,y,z);
endfunction
// =============================================================================
// shell()
// =============================================================================
function shell
u = linspace(0,2*%pi,40);
v = linspace(0,2*%pi,20);
x= (cos(u).*u)'*(1+cos(v)/2);
y= (u/2)'*sin(v);
z= (sin(u).*u)'*(1+cos(v)/2);
plot3d2(x,y,z);
endfunction
// =============================================================================
// spiral()
// =============================================================================
function spiral
[r,a]=field(0:0.1:1,0:%pi/8:6*%pi);
z=a/8;
x=r.*cos(a).*(1-a/20);
y=r.*sin(a).*(1-a/20);
z=z-1.5;
plot3d2(x,y,z);
endfunction
// =============================================================================
// rings()
// =============================================================================
function rings
rr=0.2;
t=linspace(0,2*%pi,10);
s=linspace(0,2*%pi,41); n=length(s);
r=dup(1+cos(t)*rr,n)'; m=length(t);
x=dup(cos(s),m).*r; y=dup(sin(s),m).*r;
z=dup(sin(t)*rr,n)';
X=[x;(x+1.3);(x-1.3)];
Y=[y;-z;-z];
Z=[z;y;y];
plot3d2(X,Y,Z,[m,2*m]);
endfunction
// =============================================================================
// torus()
// =============================================================================
function torus
// some torus type bodies.
x=linspace(0,2*%pi,40);
y=linspace(0,2*%pi,20)';
// a torus with a thick and a thin side.
my_factor=1.5+cos(y)*(cos(x)/2+0.6);
X=my_factor*diag(cos(x));
Y=my_factor*diag(sin(x));
Z=sin(y)*(cos(x)/2+0.6);
plot3d2(X,Y,Z);
endfunction
// =============================================================================
// torus1()
// =============================================================================
function torus1
// a deformed torus
x=linspace(0,2*%pi,40);
y=linspace(0,2*%pi,20)';
factor=1.5+cos(y);
X=factor*cos(x);
Y=factor*sin(x);
Z=sin(y)*ones(x)+ ones(y)*cos(2*x);
plot3d2(X,Y,Z);
endfunction
// =============================================================================
// moebius()
// =============================================================================
function moebius
// the Moebius band
t=linspace(-1,1,20)';
x=linspace(0,%pi,40);
factor=2+ t*cos(x);
X=factor*diag(cos(2*x));
Y=factor*diag(sin(2*x));
Z=t*sin(x);
plot3d2(X,Y,Z);
endfunction
// =============================================================================
// tube()
// =============================================================================
function tube(nn)
// some tube like bodies.
x=linspace(0,2*%pi,nn);
// atomic modell or so.
y=0.1+[sin(linspace(0,%pi,15)),1.5*sin(linspace(0,%pi,10)),sin(linspace(0,%pi,15))];
cosphi=dup(cos(x),length(y));
sinphi=dup(sin(x),length(y));
f=dup(y',length(x));
x1=f.*cosphi; y1=f.*sinphi;
z=dup(linspace(-2,2,prod(size(y)))',prod(size(x)));
plot3d2(x1,y1,z,-1,35,70);
endfunction
// =============================================================================
// bh()
// =============================================================================
function bh(nn)
// a black hole
x=linspace(0,2*%pi,nn);
t=linspace(0,1,20);
cosphi=dup(cos(x),length(t));
sinphi=dup(sin(x),length(t));
f=dup((t.*t+0.2)',length(x));
plot3d2(f.*cosphi,f.*sinphi,dup(t'.*2-1,length(x)));
endfunction
|