![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Here is a layout with stepped gradient and black gridlines.
GRDTHK adjusts the thickness of the gridlines
LatDiv adjust how many steps are in the gradient
Note the thick black line down the middle resulting from cutting through the
skewed longitudinals.
-tgq
//START
camera {
location <5,10,-10>
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
angle 12
}
light_source {
<30, 50, -40>
rgb <1, 1, 1>}
plane {
y, -1
pigment {rgb 1}
}
//HSL to RGB
#declare tHSL=function(H,C){(H/360+C/3)-floor(H/360+C/3)}
#declare qHSL=function(H,S,L){select(L-1/2,L*(1+S),L+S-L*S)}
#declare pHSL=function(H,S,L){2*L-qHSL(H,S,L)}
#declare CHSL=function(H,S,L,C)
{
select(
-S
,//S>0
select(
tHSL(H,C)-1/6
,//tc<1/6
pHSL(H,S,L)+2*(qHSL(H,S,L)-L)*6*tHSL(H,C)
,
select(
tHSL(H,C)-1/2
,//tc<1/2
qHSL(H,S,L)
,
select(
tHSL(H,C)-2/3
,//tc<2/3
pHSL(H,S,L)+2*(qHSL(H,S,L)-L)*6*(2/3-tHSL(H,C))
,//esle
pHSL(H,S,L)
)
)
)
,//S=0
L
)
}
#declare RHSL=function (H,S,L){CHSL(H,S,L,+1)}
#declare GHSL=function (H,S,L){CHSL(H,S,L, 0)}
#declare BHSL=function (H,S,L){CHSL(H,S,L,-1)}
//END HSL to RGB
#declare LatDiv=6; //Number of Latitude divisions, used for long too
(degrees= 90/LatDiv)
#declare GRDTHK=0.01; //Line thickness for 1 unit radius sphere
#declare FX=function(x){360/(LatDiv*4)*int(x*LatDiv*4+0.5)}
#declare FY=function(y){int(y*LatDiv*2+0.5)/(LatDiv*2)}
#declare FZ=function(y){int(y*LatDiv+0.5)/LatDiv}
#declare FR= function(x,y,z){RHSL(FX(x),FZ(z),FY(y))}
#declare FG= function(x,y,z){GHSL(FX(x),FZ(z),FY(y))}
#declare FB= function(x,y,z){BHSL(FX(x),FZ(z),FY(y))}
#declare HSL=
pigment{
average
pigment_map{
[function{ FR(x,y,z) } color_map{[0 rgb 0][1 rgb <3,0,0>]}]
[function{ FG(x,y,z) } color_map{[0 rgb 0][1 rgb <0,3,0>]}]
[function{ FB(x,y,z) } color_map{[0 rgb 0][1 rgb <0,0,3>]}]
}
warp{spherical}
}
#declare AA=sin(GRDTHK/2);
#declare LAT=
union{
#local i=+90/LatDiv/2;#while(i<90)
difference{
cone{0,0,2*y,tan(radians(i))*2 translate -y/sin(radians(i))*AA}
cone{0,0,2*y,tan(radians(i))*2 translate y/sin(radians(i))*AA}
}
difference{
cone{0,0,-2*y,tan(radians(i))*2 translate y/sin(radians(i))*AA}
cone{0,0,-2*y,tan(radians(i))*2 translate -y/sin(radians(i))*AA}
}
#local i=i+90/(LatDiv);#end
}
#declare LONG=
union{
#local i=+90/LatDiv/2;#while(i<180)
cylinder{-z*sin(GRDTHK/2),z*sin(GRDTHK/2),1.1 rotate y*i}
#local i=i+90/(LatDiv);#end
}
#declare PLat=
pigment{
object{
LAT
pigment{onion scale 1/LatDiv
pigment_map{
[0.5-AA*LatDiv HSL scale LatDiv]
[0.5-AA*LatDiv rgb 0]
[0.5+AA*LatDiv rgb 0]
[0.5+AA*LatDiv HSL scale LatDiv]
}
}
pigment{rgb 0}
}
}
#declare PGrid=
pigment{
object{
LONG
pigment{PLat}
pigment{rgb 0}
}
}
difference{
sphere{0,1}
box{0,<1,1,-1>}
pigment{PGrid}
finish{ambient 0 diffuse 0.5}
}
//END
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Again, this time I've cored out the gridlines where not needed. This partly
removes the thick line down the center, but not completely depending on the
settings.
-tgq
//START
camera {
location <5,10,-10>
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
angle 12
}
light_source {
<30, 50, -40>
rgb <1, 1, 1>
}
plane {
y, -1
pigment {rgb 1}
}
//HSL to RGB
#declare tHSL=function(H,C){(H/360+C/3)-floor(H/360+C/3)}
#declare qHSL=function(H,S,L){select(L-1/2,L*(1+S),L+S-L*S)}
#declare pHSL=function(H,S,L){2*L-qHSL(H,S,L)}
#declare CHSL=function(H,S,L,C)
{
select(
-S
,//S>0
select(
tHSL(H,C)-1/6
,//tc<1/6
pHSL(H,S,L)+2*(qHSL(H,S,L)-L)*6*tHSL(H,C)
,
select(
tHSL(H,C)-1/2
,//tc<1/2
qHSL(H,S,L)
,
select(
tHSL(H,C)-2/3
,//tc<2/3
pHSL(H,S,L)+2*(qHSL(H,S,L)-L)*6*(2/3-tHSL(H,C))
,//esle
pHSL(H,S,L)
)
)
)
,//S=0
L
)
}
#declare RHSL=function (H,S,L){CHSL(H,S,L,+1)}
#declare GHSL=function (H,S,L){CHSL(H,S,L, 0)}
#declare BHSL=function (H,S,L){CHSL(H,S,L,-1)}
//END HSL to RGB
#declare LatDiv=6; //Number of Latitude divisions, used for long too
(degrees= 90/LatDiv)
#declare GRDTHK=0.01; //Line thickness for 1 unit radius sphere
#declare FX=function(x){360/(LatDiv*4)*int(x*LatDiv*4+0.5)}
#declare FY=function(y){int(y*LatDiv*2+0.5)/(LatDiv*2)}
#declare FZ=function(y){int(y*LatDiv+0.5)/LatDiv}
#declare FR= function(x,y,z){RHSL(FX(x),FZ(z),FY(y))}
#declare FG= function(x,y,z){GHSL(FX(x),FZ(z),FY(y))}
#declare FB= function(x,y,z){BHSL(FX(x),FZ(z),FY(y))}
#declare HSL=
pigment{
average
pigment_map{
[function{ FR(x,y,z) } color_map{[0 rgb 0][1 rgb <3,0,0>]}]
[function{ FG(x,y,z) } color_map{[0 rgb 0][1 rgb <0,3,0>]}]
[function{ FB(x,y,z) } color_map{[0 rgb 0][1 rgb <0,0,3>]}]
}
warp{spherical}
}
#declare AA=sin(GRDTHK/2);//GRDTHK*LatDiv/2/(pi*2/4);
#declare ABC=pigment{rgb 1}
#declare LAT=
union{
#local i=+90/LatDiv/2;#while(i<90)
difference{
cone{0,0,2*y,tan(radians(i))*2 translate -y/sin(radians(i))*AA}
cone{0,0,2*y,tan(radians(i))*2 translate y/sin(radians(i))*AA}
}
difference{
cone{0,0,-2*y,tan(radians(i))*2 translate y/sin(radians(i))*AA}
cone{0,0,-2*y,tan(radians(i))*2 translate -y/sin(radians(i))*AA}
}
#local i=i+90/(LatDiv);#end
}
#declare LONG=
difference{
union{
#local i=+90/LatDiv/2;#while(i<180)
cylinder{-z*sin(GRDTHK/2),z*sin(GRDTHK/2),1.1 rotate y*i}
#local i=i+90/(LatDiv);#end
}
sphere{0,1/LatDiv/2}
cone{0,0,2*y,tan(radians(90/LatDiv/2))*2}
cone{0,0,-2*y,tan(radians(90/LatDiv/2))*2}
}
#declare LAY=
union{
cone{0,0,2*y,tan(radians(90/LatDiv/2))*2}
cone{0,0,-2*y,tan(radians(90/LatDiv/2))*2}
scale LatDiv
}
#declare PLay=
pigment{
object{
LAY
pigment{rgb 0}
pigment{rgb 1}
}
}
#declare PLat=
pigment{
object{
LAT
pigment{onion scale 1/LatDiv
pigment_map{
[0.5-AA*LatDiv HSL scale LatDiv]
[0.5-AA*LatDiv PLay]
[0.5+AA*LatDiv PLay]
[0.5+AA*LatDiv HSL scale LatDiv]
}
}
pigment{rgb 0}
}
}
#declare PGrid=
pigment{
object{
LONG
pigment{PLat}
pigment{rgb 0}
}
}
difference{
sphere{0,1}
box{0,<1,1,-1>}
pigment{PGrid}
finish{ambient 0 diffuse 0.5}
}
//END
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
I decided to go with an object pattern instead. It's a lot simpler.
Here's what the object looks like:
http://img228.imageshack.us/img228/6177/spheregriddd8.jpg
Here's what the scene looks like so far. I still need to change the colored
pigment so that it uses steps that match the grid, but that should be trivial.
http://img228.imageshack.us/img228/2742/hslspherewithgriday2.jpg
Here's the scene:
//BEGIN
//------------------------------------------------------------------------------Scenery
#include "Axes.inc"
#include "functions.inc"
#include "math.inc"
global_settings
{
assumed_gamma 1.0
ambient_light 1.0
}
light_source
{
<0, 0, -100> // light's position (translated below)
color rgb <1, 1, 1> // light's color
rotate <60,30,0>
parallel
shadowless
}
camera
{
#local CameraDistance = 10;
#local ScreenArea = 2;
#local AspectRatio = image_width/image_height;
// orthographic
location -z*CameraDistance
direction z*CameraDistance
right x*ScreenArea*AspectRatio
up y*ScreenArea
rotate x*asind(tand(30))
// rotate x*90
rotate y*45
}
//------------------------------------------------------------------------------Pigments
#declare Plain_White = pigment
{
color <1, 1, 1>
}
#declare Plain_Gray = pigment
{
color <1/2, 1/2, 1/2>
}
#declare Plain_Black = pigment
{
color <0, 0, 0>
}
#declare Plain_Clear = pigment
{
color rgbt <0, 0, 0, 1,>
}
#declare Hue = pigment
{
function
{
f_th(x,y,z) / pi / 2
}
color_map
{
[0 rgb <1, 0, 0>]
[1/3 rgb <0, 0, 1>]
[2/3 rgb <0, 1, 0>]
[1 rgb <1, 0, 0>]
}
}
#declare Saturation = pigment
{
function
{
f_r(x,y,z)
}
pigment_map
{
[0 Plain_Gray]
[1 Hue]
}
scale 1.0001
}
#declare Luminence = pigment
{
function
{
f_ph(x,y,z) / pi
}
pigment_map
{
[0 Plain_White]
[1/2 Saturation]
[1 Plain_Black]
}
}
//------------------------------------------------------------------------------CSG
objects
#declare sRadius = 1 ;
#declare sCenter = 0 ;
#declare radii = 6;
#declare longt = 12;
#declare lattt = 6;
#declare ObjectRadius = 1;
#declare LineThickness = 0.01;
#declare GridObject = intersection
{
union
{
#local i=ObjectRadius/radii/2;
#while(i<ObjectRadius)
difference
{
sphere
{
0, i + LineThickness/2
}
sphere
{
0, i - LineThickness/2
}
}
#local i=i+ObjectRadius/radii;
#end
#local i=360/longt/2;
#while(i<360)
intersection
{
plane
{
x, LineThickness/2
}
plane
{
-x, LineThickness/2
}
rotate y*i
}
#local i=i+360/longt;
#end
#local i=90/(lattt/2)/2;
#while(i<90)
difference
{
cone
{
0,0,
y,1/tand(i)
translate -y * 1/cosd(i) * LineThickness/2
}
cone
{
0,0,
y,1/tand(i)
translate y * 1/cosd(i) * LineThickness/2
}
}
difference
{
cone
{
0,0,
-y,1/tand(i)
translate y * 1/cosd(i) * LineThickness/2
}
cone
{
0,0,
-y,1/tand(i)
translate -y * 1/cosd(i) * LineThickness/2
}
}
#local i=i+90/(lattt/2);
#end
}
sphere
{
sCenter, ObjectRadius
}
}
#declare GridPigment = pigment
{
object
{
GridObject
color rgbt 1
color rgbt 0
}
scale 1.0001
}
difference
{
sphere
{
sCenter, sRadius
}
box
{
sCenter, <-sRadius,sRadius,-sRadius,> * 2
}
texture
{
Luminence
finish
{
ambient 1
}
}
texture {pigment{GridPigment}}
}
//END
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
No gridlines, stepped gradient, cutout outlined in black.
To remove outline, replace "pigment{PGrid}" with "pigment{HSL}" in the last
object.
//START
camera {
location <5,10,-10>
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
angle 12
}
light_source {
<30, 50, -40>
rgb <1, 1, 1>
}
plane {
y, -1
pigment {rgb 1}
}
//HSL to RGB
#declare tHSL=function(H,C){(H/360+C/3)-floor(H/360+C/3)}
#declare qHSL=function(H,S,L){select(L-1/2,L*(1+S),L+S-L*S)}
#declare pHSL=function(H,S,L){2*L-qHSL(H,S,L)}
#declare CHSL=function(H,S,L,C)
{
select(
-S
,//S>0
select(
tHSL(H,C)-1/6
,//tc<1/6
pHSL(H,S,L)+2*(qHSL(H,S,L)-L)*6*tHSL(H,C)
,
select(
tHSL(H,C)-1/2
,//tc<1/2
qHSL(H,S,L)
,
select(
tHSL(H,C)-2/3
,//tc<2/3
pHSL(H,S,L)+2*(qHSL(H,S,L)-L)*6*(2/3-tHSL(H,C))
,//esle
pHSL(H,S,L)
)
)
)
,//S=0
L
)
}
#declare RHSL=function (H,S,L){CHSL(H,S,L,+1)}
#declare GHSL=function (H,S,L){CHSL(H,S,L, 0)}
#declare BHSL=function (H,S,L){CHSL(H,S,L,-1)}
//END HSL to RGB
#declare LatDiv=6; //Number of Latitude divisions, used for long too
(degrees= 90/LatDiv)
#declare GRDTHK=0.01; //Line thickness for 1 unit radius sphere
#declare FX=function(x){360/(LatDiv*4)*int(x*LatDiv*4+0.5)}
#declare FY=function(y){int(y*LatDiv*2+0.5)/(LatDiv*2)}
#declare FZ=function(y){int(y*LatDiv+0.5)/LatDiv}
#declare FR= function(x,y,z){RHSL(FX(x),FZ(z),FY(y))}
#declare FG= function(x,y,z){GHSL(FX(x),FZ(z),FY(y))}
#declare FB= function(x,y,z){BHSL(FX(x),FZ(z),FY(y))}
#declare HSL=
pigment{
average
pigment_map{
[function{ FR(x,y,z) } color_map{[0 rgb 0][1 rgb <3,0,0>]}]
[function{ FG(x,y,z) } color_map{[0 rgb 0][1 rgb <0,3,0>]}]
[function{ FB(x,y,z) } color_map{[0 rgb 0][1 rgb <0,0,3>]}]
}
warp{spherical}
}
#declare AA=sin(GRDTHK/2);//GRDTHK*LatDiv/2/(pi*2/4);
#declare ABC=pigment{rgb 1}
#declare LONG =
intersection{
union{
torus{1,GRDTHK}
torus{1,GRDTHK rotate x*90}
torus{1,GRDTHK rotate z*90}
cylinder{0,x,GRDTHK}
cylinder{0,y,GRDTHK}
cylinder{0,-z,GRDTHK}
}
box{<-1,-1,1>*GRDTHK,<1,1,-1>}
}
#declare PGrid=
pigment{
object{
LONG
pigment{HSL}
pigment{rgb 0}
}
}
difference{
sphere{0,1}
box{0,<1,1,-1>}
pigment{PGrid}//change to HSL for no black outlines
finish{ambient 0 diffuse 0.5}
}
//END
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
And one more, with continuous smooth gradient instead of stepped.
-tgq
//START
camera {
location <5,10,-10>
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
angle 12
}
light_source {
<30, 50, -40>
rgb <1, 1, 1>
}
plane {
y, -1
pigment {rgb 1}
}
//HSL to RGB
#declare tHSL=function(H,C){(H/360+C/3)-floor(H/360+C/3)}
#declare qHSL=function(H,S,L){select(L-1/2,L*(1+S),L+S-L*S)}
#declare pHSL=function(H,S,L){2*L-qHSL(H,S,L)}
#declare CHSL=function(H,S,L,C)
{
select(
-S
,//S>0
select(
tHSL(H,C)-1/6
,//tc<1/6
pHSL(H,S,L)+2*(qHSL(H,S,L)-L)*6*tHSL(H,C)
,
select(
tHSL(H,C)-1/2
,//tc<1/2
qHSL(H,S,L)
,
select(
tHSL(H,C)-2/3
,//tc<2/3
pHSL(H,S,L)+2*(qHSL(H,S,L)-L)*6*(2/3-tHSL(H,C))
,//esle
pHSL(H,S,L)
)
)
)
,//S=0
L
)
}
#declare RHSL=function (H,S,L){CHSL(H,S,L,+1)}
#declare GHSL=function (H,S,L){CHSL(H,S,L, 0)}
#declare BHSL=function (H,S,L){CHSL(H,S,L,-1)}
//END HSL to RGB
#declare GRDTHK=0.01; //Line thickness for 1 unit radius sphere
#declare FR= function(x,y,z){RHSL(360*x,z,y)}
#declare FG= function(x,y,z){GHSL(360*x,z,y)}
#declare FB= function(x,y,z){BHSL(360*x,z,y)}
#declare HSL=
pigment{
average
pigment_map{
[function{ FR(x,y,z) } color_map{[0 rgb 0][1 rgb <3,0,0>]}]
[function{ FG(x,y,z) } color_map{[0 rgb 0][1 rgb <0,3,0>]}]
[function{ FB(x,y,z) } color_map{[0 rgb 0][1 rgb <0,0,3>]}]
}
warp{repeat z flip z}// to avoid coincident surface problem
warp{spherical}
}
#declare AA=sin(GRDTHK/2);//GRDTHK*LatDiv/2/(pi*2/4);
#declare ABC=pigment{rgb 1}
#declare LONG =
intersection{
union{
torus{1,GRDTHK}
torus{1,GRDTHK rotate x*90}
torus{1,GRDTHK rotate z*90}
cylinder{0,x,GRDTHK}
cylinder{0,y,GRDTHK}
cylinder{0,-z,GRDTHK}
}
box{<-1,-1,1>*GRDTHK,<1,1,-1>}
}
#declare PGrid=
pigment{
object{
LONG
pigment{HSL}
pigment{rgb 0}
}
}
difference{
sphere{0,1}
box{0,<1,1,-1>}
pigment{PGrid}//change to HSL for no black outlines
finish{ambient 0 diffuse 0.5}
}
//END
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"SharkD" <nomail@nomail> wrote:
> I decided to go with an object pattern instead. It's a lot simpler.
>
> Here's what the object looks like:
> http://img228.imageshack.us/img228/6177/spheregriddd8.jpg
>
> Here's what the scene looks like so far. I still need to change the colored
> pigment so that it uses steps that match the grid, but that should be trivial.
> http://img228.imageshack.us/img228/2742/hslspherewithgriday2.jpg
>
Looks good, looks like you got the maths figured out for the grid object. The
only real difference with what put together is you are using sphere objects for
the layers, whereas I used an onion pattern.
For the HSL colour spacing, look at the HSL pigment in my code, you will need to
play with the LatDiv numers in all three to get what you need.
-tgq
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Trevor G Quayle" <Tin### [at] hotmail com> wrote:
> "SharkD" <nomail@nomail> wrote:
> > I decided to go with an object pattern instead. It's a lot simpler.
> >
> > Here's what the object looks like:
> > http://img228.imageshack.us/img228/6177/spheregriddd8.jpg
> >
> > Here's what the scene looks like so far. I still need to change the colored
> > pigment so that it uses steps that match the grid, but that should be trivial.
> > http://img228.imageshack.us/img228/2742/hslspherewithgriday2.jpg
> >
>
> Looks good, looks like you got the maths figured out for the grid object. The
> only real difference with what put together is you are using sphere objects for
> the layers, whereas I used an onion pattern.
>
> For the HSL colour spacing, look at the HSL pigment in my code, you will need to
> play with the LatDiv numers in all three to get what you need.
>
> -tgq
Here's one of the other differences:
http://img442.imageshack.us/img442/1082/hslsphereisometricshowbh1.jpg
I can difference the whole object. It looks pretty cool. It's what I'm going to
use for the final image. I just need to add the labels and arrows and such to
make it a real diagram.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"SharkD" <nomail@nomail> wrote:
> Here's one of the other differences:
>
> http://img442.imageshack.us/img442/1082/hslsphereisometricshowbh1.jpg
>
> I can difference the whole object. It looks pretty cool. It's what I'm going to
> use for the final image. I just need to add the labels and arrows and such to
> make it a real diagram.
I uploaded it to the Object Collection as a macro (search for
"SphereGridMacro"). There were some things I fixed before uploading it, though.
I included a sample file showing three different ways of using the object.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |