 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hi,
I'd like to create a sphere with lines for longitudes and latitudes,
which basically is just a white sphere with thin black lines on horizon
and parallel to the horizon, and lines from north to south.
How would I do this?
I tried to apply a texture with a color map onto the surface of the
sphere, but the gradient is just a linear vector of x,y,z and not
a term (e.g. the angle phi cannot be used).
Another approach would be to mix the sphere with very flat and black
cylinders which are just a little big bigger than the sphere, but then
the sphere is not perfect anymore.
How could I get a sphere with those lines?
regards
Hadmut
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hadmut Danisch napsal(a):
> Hi,
>
> I'd like to create a sphere with lines for longitudes and latitudes,
> which basically is just a white sphere with thin black lines on horizon
> and parallel to the horizon, and lines from north to south.
>
> How would I do this?
>
> I tried to apply a texture with a color map onto the surface of the
> sphere, but the gradient is just a linear vector of x,y,z and not
> a term (e.g. the angle phi cannot be used).
>
> Another approach would be to mix the sphere with very flat and black
> cylinders which are just a little big bigger than the sphere, but then
> the sphere is not perfect anymore.
>
> How could I get a sphere with those lines?
>
> regards
> Hadmut
>
use UV_mapping or warp{spherical}. Both map the <0,0>,<1,1> square onto
the sphere. They do the same in the sphere case.
For the grid, you may use the quilted pattern.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Wasn't it Hadmut Danisch who wrote:
>Hi,
>
>I'd like to create a sphere with lines for longitudes and latitudes,
>which basically is just a white sphere with thin black lines on horizon
>and parallel to the horizon, and lines from north to south.
>
>How would I do this?
>
>I tried to apply a texture with a color map onto the surface of the
>sphere, but the gradient is just a linear vector of x,y,z and not
>a term (e.g. the angle phi cannot be used).
>
>Another approach would be to mix the sphere with very flat and black
>cylinders which are just a little big bigger than the sphere, but then
>the sphere is not perfect anymore.
>
>How could I get a sphere with those lines?
One way to do it is with layered textures.
sphere {0,1
texture{
pigment {gradient y
colour_map{[0 rgb 1][0.1 rgb 0]}
scale 0.15
}
}
texture {
pigment {radial frequency 30
colour_map{[0 rgb 1][0.1 rgbt <0,0,0,1>]}
}
}
}
The bottom layer is a gradient pigment with a small scale.
The upper layer is a radial pigment with a high frequency which is
mostly transparent so you can see the underlying gradient texture.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Wasn't it Hadmut Danisch who wrote:
>Hi,
>
>I'd like to create a sphere with lines for longitudes and latitudes,
>which basically is just a white sphere with thin black lines on horizon
>and parallel to the horizon, and lines from north to south.
>
>How would I do this?
>
>I tried to apply a texture with a color map onto the surface of the
>sphere, but the gradient is just a linear vector of x,y,z and not
>a term (e.g. the angle phi cannot be used).
>
>Another approach would be to mix the sphere with very flat and black
>cylinders which are just a little big bigger than the sphere, but then
>the sphere is not perfect anymore.
>
>How could I get a sphere with those lines?
Another way to do it is to use the phi function "f_ph()". That makes the
lines more even. You could also use the theta function "f_th()" for the
lines of longitude, but there'd be no difference from using the radial
pattern.
#include "functions.inc"
sphere {0,1
texture{
pigment {function {f_ph(x,y,z)*6}
colour_map{[0.1 rgb 1][0.1 rgb 0]}
scale 0.15
}
}
texture {
pigment {radial frequency 30
colour_map{[0.1 rgb 1][0.1 rgbt <0,0,0,1>]}
}
}
}
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Hadmut Danisch" <had### [at] danisch de> wrote in message
news:47374beb$1@news.povray.org...
> Hi,
>
> I'd like to create a sphere with lines for longitudes and latitudes,
> which basically is just a white sphere with thin black lines on horizon
> and parallel to the horizon, and lines from north to south.
>
> How would I do this?
>
> regards
> Hadmut
>
Hi Hadmut,
There's one on http://lib.povray.org/searchcollection/index.php if you
search for 'GridLines'. The lines are green, and the background is
transparent, but you can readily change that.
It uses rotated copies of the gradient pattern to give a constant line
thickness.
Regards,
Chris B
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Hadmut Danisch
Subject: Re: Sphere with longitudes and latitudes?
Date: 11 Nov 2007 16:23:54
Message: <473772ea@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Mike Williams wrote:
> Another way to do it is to use the phi function "f_ph()". That makes the
> lines more even. You could also use the theta function "f_th()" for the
> lines of longitude, but there'd be no difference from using the radial
> pattern.
>
> #include "functions.inc"
>
> sphere {0,1
> texture{
> pigment {function {f_ph(x,y,z)*6}
> colour_map{[0.1 rgb 1][0.1 rgb 0]}
> scale 0.15
> }
> }
> texture {
> pigment {radial frequency 30
> colour_map{[0.1 rgb 1][0.1 rgbt <0,0,0,1>]}
> }
> }
> }
These are exactly the two hints I was looking for.
Thanks, also to the others.
regards
Hadmut
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Hadmut Danisch
Subject: Re: Sphere with longitudes and latitudes?
Date: 11 Nov 2007 16:40:26
Message: <473776ca@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Mike Williams wrote:
> texture {
> pigment {radial frequency 30
> colour_map{[0.1 rgb 1][0.1 rgbt <0,0,0,1>]}
> }
Just a little detail problem:
while this does what I am looking for in principle, there's one
problem: The line is not of constant width. The closer it gets to the
poles, the smaller it gets, like a slice of cake. Becomes highly visible
when the frequence gets lower, e.g. frequency 4
regards
Hadmut
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hadmut Danisch napsal(a):
> Mike Williams wrote:
>
>> texture {
>> pigment {radial frequency 30
>> colour_map{[0.1 rgb 1][0.1 rgbt <0,0,0,1>]}
>> }
>
>
> Just a little detail problem:
>
> while this does what I am looking for in principle, there's one
> problem: The line is not of constant width. The closer it gets to the
> poles, the smaller it gets, like a slice of cake. Becomes highly visible
> when the frequence gets lower, e.g. frequency 4
>
> regards
> Hadmut
in that case you need to invent a pigment to account for this. It might
not be that simple.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Hadmut Danisch" <had### [at] danisch de> a écrit dans le message de news:
47374beb$1@news.povray.org...
> Hi,
>
> I'd like to create a sphere with lines for longitudes and latitudes,
> which basically is just a white sphere with thin black lines on horizon
> and parallel to the horizon, and lines from north to south.
>
> How would I do this?
>
> I tried to apply a texture with a color map onto the surface of the
> sphere, but the gradient is just a linear vector of x,y,z and not
> a term (e.g. the angle phi cannot be used).
>
> Another approach would be to mix the sphere with very flat and black
> cylinders which are just a little big bigger than the sphere, but then
> the sphere is not perfect anymore.
>
> How could I get a sphere with those lines?
>
> regards
> Hadmut
Why not build your lines with some tori and make an object_pattern with
them?
You could keep constant width lines that way.
Marc
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Hadmut Danisch" <had### [at] danisch de> wrote in message
news:473776ca@news.povray.org...
> Mike Williams wrote:
>
>> texture {
>> pigment {radial frequency 30
>> colour_map{[0.1 rgb 1][0.1 rgbt <0,0,0,1>]}
>> }
>
>
> Just a little detail problem:
>
> while this does what I am looking for in principle, there's one
> problem: The line is not of constant width. The closer it gets to the
> poles, the smaller it gets, like a slice of cake. Becomes highly visible
> when the frequence gets lower, e.g. frequency 4
>
> regards
> Hadmut
That's the problem that the one on
http://lib.povray.org/searchcollection/index.php is designed to avoid
(search for 'GridLines').
Regards,
Chris B.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hadmut Danisch <had### [at] danisch de> wrote:
> Mike Williams wrote:
>
> > texture {
> > pigment {radial frequency 30
> > colour_map{[0.1 rgb 1][0.1 rgbt <0,0,0,1>]}
> > }
>
>
> Just a little detail problem:
>
> while this does what I am looking for in principle, there's one
> problem: The line is not of constant width. The closer it gets to the
> poles, the smaller it gets, like a slice of cake. Becomes highly visible
> when the frequence gets lower, e.g. frequency 4
>
> regards
> Hadmut
Try this code, it combines a gradient with a spherical warp for the lat lines
with cylinder-based object pattern for the long lines. The lat and long grid
line widths are constant and definable in width (along the arclength even).
Feel free to pick it apart and modify it as needed.
-tgq
//START
#declare LatDiv=8; //Number of Latitude divisions, used for long too (degrees
= 90/LatDiv)
#declare GRDTHK=0.01; //Line thickness for 1 unit radius sphere
#declare AA=GRDTHK*LatDiv/2/(pi*2/4);
#declare PLat=
pigment{
gradient
y
colour_map{
[AA rgb 0]
[AA rgb 1]
[1-AA rgb 1]
[1-AA rgb 0]
}
frequency LatDiv*2
warp {
spherical
}
}
#declare LONG=
union{
#local i=0;#while(i<180)
cylinder{-z*sin(GRDTHK/2),z*sin(GRDTHK/2),1.1 rotate y*i}
#local i=i+90/LatDiv;#end
}
#declare PGrid=
pigment{
object{
LONG
pigment{PLat}
pigment{rgb 0}
}
}
sphere{0,1
pigment{PGrid}
scale 340
}
//END
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Wasn't it Hadmut Danisch who wrote:
>Mike Williams wrote:
>
>> texture {
>> pigment {radial frequency 30
>> colour_map{[0.1 rgb 1][0.1 rgbt <0,0,0,1>]}
>> }
>
>
>Just a little detail problem:
>
>while this does what I am looking for in principle, there's one
>problem: The line is not of constant width. The closer it gets to the
>poles, the smaller it gets, like a slice of cake. Becomes highly visible
>when the frequence gets lower, e.g. frequency 4
Here's one where the lines are constant width. It's significantly
slower.
#declare Longs =10; // number of longitude lines : should be > 3
#declare Lats = 10; // number of latitude lines : must be even
#declare LongW = Longs/200;
#include "functions.inc"
sphere {0,1
texture{
pigment {function {f_ph(x,y,z)*(Longs-1)/2}
colour_map{[LongW rgb 1][LongW rgb 0]}
}
}
#declare th=0;
#while (th<180)
texture {
pigment {function {abs(x)}
colour_map{[0.01 rgb 1][0.01 rgbt 1]}
scale 1.02
rotate y*th
}
}
#declare th = th+(360/Lats);
#end
}
Watch out for that "scale 1.02" If you don't have it, you sometimes
get some white circles at the edges.
The "function {abs(x)}" looks slightly better than "gradient x". If you
use "gradient x" then the gap next to the line at 180 degrees looks
slightly different from all the others. I'm not sure why.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"M_a_r_c" <jac### [at] wanadoo fr> a écrit dans le message de news:
47377c4d@news.povray.org...
>
> Why not build your lines with some tori and make an object_pattern with
> them?
> You could keep constant width lines that way.
>
> Marc
#include "colors.inc"
#include"math.inc"
global_settings {
assumed_gamma 1.0
}
// ----------------------------------------
camera {
location <0.0, 2, -3.0>
direction 1.5*z
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
}
light_source {
<0, 0, 0> // light's position (translated below)
color rgb <1, 1, 1> // light's color
translate <-30, 30, -30>
}
// ----------------------------------------
#declare Sphere_rad=1;
#declare Line_width=0.0025;
#declare Long_number=24;
#declare Lat_number=12;
//construction of the longitude lines
#declare Line_long=torus{Sphere_rad,Line_width rotate x*90}
#declare Cnt_long=0;
#declare Long=union{
#while(Cnt_long<Long_number)
object{Line_long rotate y*360*Cnt_long/Long_number}
#declare Cnt_long=Cnt_long+1;
#end
}
//construction of the latitude lines
#declare Cnt_lat=0;
#declare Lat=union{
#while (Cnt_lat< Lat_number)
torus{Sphere_rad*cosd(90*Cnt_lat/Lat_number),Line_width translate
y*Sphere_rad*sind(90*Cnt_lat/Lat_number)}
#declare Cnt_lat=Cnt_lat+2;
#end
}
#declare Lines=union{
object{Long}
object{Lat} //North hemisphere
object{Lat scale<1,-1,1>} //South hemisphere
}
sphere {
0.0, Sphere_rad
texture {
pigment{
object {
Lines
color rgb <0,0,0.5>, // outside object
color rgb <0,1,0> // inside object
}
}
finish{
specular 0.6
}
}
}
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"M_a_r_c" <jac### [at] wanadoo fr> a écrit dans le message de news:
47380442$1@news.povray.org...
>
> //construction of the longitude lines
> #declare Line_long=torus{Sphere_rad,Line_width rotate x*90}
> #declare Cnt_long=0;
> #declare Long=union{
> #while(Cnt_long<Long_number)
> object{Line_long rotate y*360*Cnt_long/Long_number}
> #declare Cnt_long=Cnt_long+1;
> #end
> }
ooops should be :
object{Line_long rotate y*180*Cnt_long/Long_number}
Marc
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Chris B" <nom### [at] nomail com> wrote:
> That's the problem that the one on
> http://lib.povray.org/searchcollection/index.php is designed to avoid
> (search for 'GridLines').
>
> Regards,
> Chris B.
Here's a challenge: someone adapt the above code to create gridlines such as the
ones found in this imag (http://en.wikipedia.org/wiki/Image:HSLSphere.svg).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"SharkD" <nomail@nomail> wrote in message
news:web.4783e426a8d0eaae458a4ca0@news.povray.org...
> "Chris B" <nom### [at] nomail com> wrote:
>> That's the problem that the one on
>> http://lib.povray.org/searchcollection/index.php is designed to avoid
>> (search for 'GridLines').
>>
>> Regards,
>> Chris B.
>
> Here's a challenge: someone adapt the above code to create gridlines such
> as the
> ones found in this imag
> (http://en.wikipedia.org/wiki/Image:HSLSphere.svg).
>
I'm not really sure what you're requesting.
The SDL above already generates grid lines similar to the grid lines in the
image you've linked to.
Do you just want the colour or spacing to be different or is it that you
want a colour chart rather than the grid lines themselves, or is it the
inset quadrant in each of the two spheres that you're trying to achieve?
Also, is this just a challenge as some sort of exercise that you're setting,
or do you have some practical use for whatever it is you're asking for?
Regards,
Chris B.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Chris B" <nom### [at] nomail com> wrote:
> "SharkD" <nomail@nomail> wrote in message
> news:web.4783e426a8d0eaae458a4ca0@news.povray.org...
> >
> > Here's a challenge: someone adapt the above code to create gridlines such
> > as the
> > ones found in this imag
> > (http://en.wikipedia.org/wiki/Image:HSLSphere.svg).
> >
>
> I'm not really sure what you're requesting.
>
> The SDL above already generates grid lines similar to the grid lines in the
> image you've linked to.
>
> Do you just want the colour or spacing to be different or is it that you
> want a colour chart rather than the grid lines themselves, or is it the
> inset quadrant in each of the two spheres that you're trying to achieve?
>
> Also, is this just a challenge as some sort of exercise that you're setting,
> or do you have some practical use for whatever it is you're asking for?
>
> Regards,
> Chris B.
I'd like the grid lines to exist /within/ the sphere, as well as on the surface.
Currently, if I cut a corner away from the sphere, the cut-away portion is
completely opaque (dark green in this case, black if I use Trevor G Quayle's
code).
It's a personal request. I'd like to replace the SVG image with a nicely
rendered one, as the SVG image was removed from an article for being "too ugly"
(kind of a stupid reason to remove a diagram from an encyclopedia, but
anyway...).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
SharkD escribió:
> It's a personal request. I'd like to replace the SVG image with a nicely
> rendered one, as the SVG image was removed from an article for being "too ugly"
> (kind of a stupid reason to remove a diagram from an encyclopedia, but
> anyway...).
And a "nicely rendered one" wouldn't be scalable. The only way to keep
both advantages would be rendering it in POV-Ray, then manually
"vectorizing" it.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"SharkD" <nomail@nomail> wrote in message
> ... snip ...
> I'd like the grid lines to exist /within/ the sphere, as well as on the
> surface.
> Currently, if I cut a corner away from the sphere, the cut-away portion is
> completely opaque (dark green in this case, black if I use Trevor G
> Quayle's
> code).
>
Actually I think the grid lines do exist within the sphere and I suspect
that this is why you get a green or black surface in your cut-away. If the
cut surfaces align with a horizontal line (eg. latitude 0 degrees) and two
of the longitudinal lines (e.g. 0 and 90 degrees) then you'll get the colour
of the grid lines (assuming you apply the one texture to the whole object).
One way of resolving that would be to shift the horizontal lines up by half
the current separation and rotate the sphere around the vertical axis by
half a segment. Another would be to specify an appropriate texture of your
choice to the object doing the cutting. e.g. a displaced and rotated
gridline texture combined with an onion texture to give you the concentric
spheres.
> It's a personal request. I'd like to replace the SVG image with a nicely
> rendered one, as the SVG image was removed from an article for being "too
> ugly"
> (kind of a stupid reason to remove a diagram from an encyclopedia, but
> anyway...).
>
If it's an ugliness problem then presumably you don't want to just reproduce
something that's very similar to what you've got. Also, I agree with Nicolas
that a rendered image with grid-lines wouldn't scale as well as a vector
graphics image will, resulting in less clarity and potentially some of the
lines disappearing as it gets scaled down or uneven thickening as it gets
scaled up. You may want to consider keeping the lines from the existing SVG
file overlayed on top of prettier bitmapped spheres.
You could probably do smoothly graded spheres in POV-Ray using orthographic
projection and only ambient lighting, but I thought it was also possible to
do such colour grading in an SVG editor.
Hope there's something in all that that's helpful.
Regards,
Chris B.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Chris B" <nom### [at] nomail com> wrote:
> "SharkD" <nomail@nomail> wrote in message
> > ... snip ...
> > I'd like the grid lines to exist /within/ the sphere, as well as on the
> > surface.
> > Currently, if I cut a corner away from the sphere, the cut-away portion is
> > completely opaque (dark green in this case, black if I use Trevor G
> > Quayle's
> > code).
> >
>
> Actually I think the grid lines do exist within the sphere and I suspect
> that this is why you get a green or black surface in your cut-away. If the
> cut surfaces align with a horizontal line (eg. latitude 0 degrees) and two
> of the longitudinal lines (e.g. 0 and 90 degrees) then you'll get the colour
> of the grid lines (assuming you apply the one texture to the whole object).
>
> One way of resolving that would be to shift the horizontal lines up by half
> the current separation and rotate the sphere around the vertical axis by
> half a segment. Another would be to specify an appropriate texture of your
> choice to the object doing the cutting. e.g. a displaced and rotated
> gridline texture combined with an onion texture to give you the concentric
> spheres.
>
> > It's a personal request. I'd like to replace the SVG image with a nicely
> > rendered one, as the SVG image was removed from an article for being "too
> > ugly"
> > (kind of a stupid reason to remove a diagram from an encyclopedia, but
> > anyway...).
> >
>
> If it's an ugliness problem then presumably you don't want to just reproduce
> something that's very similar to what you've got. Also, I agree with Nicolas
> that a rendered image with grid-lines wouldn't scale as well as a vector
> graphics image will, resulting in less clarity and potentially some of the
> lines disappearing as it gets scaled down or uneven thickening as it gets
> scaled up. You may want to consider keeping the lines from the existing SVG
> file overlayed on top of prettier bitmapped spheres.
>
> You could probably do smoothly graded spheres in POV-Ray using orthographic
> projection and only ambient lighting, but I thought it was also possible to
> do such colour grading in an SVG editor.
>
> Hope there's something in all that that's helpful.
>
> Regards,
> Chris B.
The grid lines do go all the way through. What he is referring to is the
concentric layer lines.
This should be fairly easy to do. A few notes:
1) The Longitudinal lines are fine, they are already a constant thickness
through.
2) The latitude lines are from a spherical map, so they will radiate to the
center as needed, but they aren't constant thickness. better to replace them
with another object pattern made from appropriately sized and offset cones.
3) For the concentric layer lines, a simple onion pattern should suffice.
4) A note on offsetting though. In the image, the lines aren't at the quadrants,
but rather the colour grids are centered on them, all grid lines should be
shifted accordingly. (This is why you get solid black when cutting though the
quadrant)
5) Unfortunately you will get thicker lines at the the center axis from the skew
of the longitudinal lines. This really can't be avoided if you want to maintain
a constant thickness in the planes. Perhaps they could be stopped short of the
center axis to prevent this.
6) Regarding 5), perhaps you don't need the separating grid lines for the
graphic, just the colour stepping alone (or even a constant gradient)would work
best. You could still highlight the cutout edges with black lines though (again
using an object pattern)
7) For the colour gradient, you could use a simple macro for the cells, however
you could also use the HSL->RGB functions I posted in a different thread (look
for the thread regarding colour spaces and colour interpolation). These
functions can be used to create a continous gradient function or modified to
give a stepped gradient.
I already started throwing some of the stuff together and may be able to post
something tomorrow.
-tgq
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |