%% syntaxe : r option newsphere -> solid
/newsphere {
2 dict begin
[[/K /N] [6 6] [8 8] [10 12] [16 12] [16 36]] gestionsolidmode
-90 90 [K N] newcalottesphere
end
} def
%% syntaxe : r phi theta option newcalottesphere -> solid
/newcalottesphere {
6 dict begin
[[/K /N] [6 6] [8 8] [10 12] [16 12] [16 36]] gestionsolidmode
%% test de beta (ex-theta)
dup 90 eq {
/beta exch def
/idebut 1 def
} {
/beta exch 80 min -80 max def
/idebut 0 def
} ifelse
%% test de alpha (ex-phi)
dup -90 eq {
/alpha exch def
} {
/alpha exch beta min -80 max def
} ifelse
/r exch def
beta 90 eq {
alpha -90 eq {
/ifin K def
/db alpha beta sub K 1 add div def
} {
/ifin K def
/db alpha beta sub K div def
} ifelse
} {
alpha -90 eq {
/ifin K 1 sub def
/db alpha beta sub K div def
} {
/ifin K 1 sub def
/db alpha beta sub K 1 sub div def
} ifelse
} ifelse
%% nombre de sommets -2
/nb N K mul def
%% tableau des sommets
/S [
idebut 1 ifin {
/j exch def
/phi beta j db mul add def
phi cos r mul /r_tmp exch def
0 1 N 1 sub {
/i exch def
360 N idiv i mul cos r_tmp mul
360 N idiv i mul sin r_tmp mul
phi sin r mul
} for
} for
0 0 r neg
0 0 r
] def
/F [
%% calotte inferieure
alpha -90 eq {
1 1 N 1 sub {
/i exch def
[
nb
nb i sub
nb i 1 add sub
]
} for
[nb nb N sub nb 1 sub]
} {
[nb 1 sub -1 nb N sub {} for ]
} ifelse
%% calotte superieure
beta 90 eq {
0 1 N 1 sub {
/i exch def
[i i 1 add N mod N K mul 1 add]
} for
} {
[0 1 N 1 sub {} for]
} ifelse
1 1 K 1 sub {
/j exch def
[
j N mul
j N mul 1 add
j 1 sub N mul 1 add
j 1 sub N mul
]
N 2 sub {dup {1 add} apply} repeat
[
j 1 add N mul 1 sub
j N mul
j 1 sub N mul
j N mul 1 sub
]
} for
] def
S F generesolid
end
} def
%% syntaxe : r phi theta option newcalottespherecreuse -> solid
/newcalottespherecreuse {
6 dict begin
[[/K /N] [6 6] [8 8] [10 12] [16 12] [16 36]] gestionsolidmode
%% test de beta (ex-theta)
dup 90 eq {
/beta exch def
/idebut 1 def
} {
/beta exch 80 min -80 max def
/idebut 0 def
} ifelse
%% test de alpha (ex-phi)
dup -90 eq {
/alpha exch def
} {
/alpha exch beta min -80 max def
} ifelse
/r exch def
beta 90 eq {
alpha -90 eq {
/ifin K def
/db alpha beta sub K 1 add div def
} {
/ifin K def
/db alpha beta sub K div def
} ifelse
} {
alpha -90 eq {
/ifin K 1 sub def
/db alpha beta sub K div def
} {
/ifin K 1 sub def
/db alpha beta sub K 1 sub div def
} ifelse
} ifelse
%% nombre de sommets -2
/nb N K mul def
%% tableau des sommets
/S [
idebut 1 ifin {
/j exch def
/phi beta j db mul add def
phi cos r mul /r_tmp exch def
0 1 N 1 sub {
/i exch def
360 N idiv i mul cos r_tmp mul
360 N idiv i mul sin r_tmp mul
phi sin r mul
} for
} for
0 0 r neg
0 0 r
] def
/F [
%% calotte inferieure
alpha -90 eq {
1 1 N 1 sub {
/i exch def
[
nb
nb i sub
nb i 1 add sub
]
} for
[nb nb N sub nb 1 sub]
} {
% [nb 1 sub -1 nb N sub {} for ]
} ifelse
%% calotte superieure
beta 90 eq {
0 1 N 1 sub {
/i exch def
[i i 1 add N mod N K mul 1 add]
} for
} {
% [0 1 N 1 sub {} for]
} ifelse
1 1 K 1 sub {
/j exch def
[
j N mul
j N mul 1 add
j 1 sub N mul 1 add
j 1 sub N mul
]
N 2 sub {dup {1 add} apply} repeat
[
j 1 add N mul 1 sub
j N mul
j 1 sub N mul
j N mul 1 sub
]
} for
] def
S F generesolid
dup videsolid
end
} def
|