%% syntaxe : z0 r0 z1 newcone -> solid
%% syntaxe : z0 r0 z1 {mode} newcone -> solid
%% syntaxe : z0 r0 z1 [n1 n2] newcone -> solid
%% syntaxe : a b {f} {sommet} [n1 n2] newcone -> solid
/newcone {
11 dict begin
[ [/n /N] [1 6] [1 8] [1 10] [3 12] [5 18] ] gestionsolidmode
dup xcheck {
%% cas general
/sommet exch def
/lafonction exch def
/b exch def
/a exch def
/pas b a sub N div def
/S [
sommet
0 1 n 1 sub {
/j exch def
0 1 N {
/i exch def
a i pas mul add lafonction
dupp3d sommet vecteur3d j n div mulv3d addv3d
} for
} for
1 1 n {
/j exch def
0 1 N {
/i exch def
a i pas mul add lafonction
sommet vecteur3d j n div mulv3d sommet addv3d
} for
} for
] def
/F [
%% les etages inferieurs
0 1 n 2 sub {
/j exch def
1 1 N {
/i exch def
[
i j N 1 add mul add
dup 1 add
dup N add 1 add
dup 1 sub
]
} for
} for
%% dernier etage inferieur
1 1 N {
/i exch def
[
i N 1 add n 1 sub mul add
dup 1 add
0
]
} for
%% premier etage superieur
1 1 N {
/i exch def
[
i N 1 add n mul add
dup 1 add
0
exch
]
} for
%% les etages superieurs
n 1 n 2 mul 2 sub {
/j exch def
1 1 N {
/i exch def
[
i j N 1 add mul add
dup 1 add
dup N add 1 add
dup 1 sub
]
} for
} for
] def
S F generesolid
% dup videsolid
} {
%% cylindre de revolution
/z1 exch def
/r0 exch def
/z0 exch def
/dz z1 z0 sub n div def
/dr r0 n div def
/F [
%% la base
[N 1 sub -1 0 {} for]
%% le dernier etage
n 1 sub N mul 1 add 1 n N mul 1 sub {
/i exch def
[i 1 sub i n N mul]
} for
[n N mul 1 sub n 1 sub N mul n N mul]
%% les autres etages
0 1 n 2 sub {
/j exch def
0 N j mul add 1 N N j mul add 2 sub {
/i exch def
[i i 1 add dup N add dup 1 sub]
} for
[N N j mul add 1 sub N j mul dup N add dup N add 1 sub]
} for
] def
%% tableau des sommets
/S [
%% etage no j (in [1; n])
0 1 n 1 sub {
/j exch def
0 1 N 1 sub {
/i exch def
360 N idiv i mul cos r0 dr j mul sub mul
360 N idiv i mul sin r0 dr j mul sub mul
z0 dz j mul add
} for
} for
0 0 z1
] def
S F generesolid
} ifelse
end
} def
%% %% syntaxe : z0 r0 z1 newconecreux -> solid
/newconecreux {
newcone
dup 0 solidrmface
dup videsolid
} def
|