POV-Ray : Newsgroups : povray.general : Sphere with longitudes and latitudes? Server Time
31 Jul 2024 10:24:05 EDT (-0400)
  Sphere with longitudes and latitudes? (Message 9 to 18 of 28)  
<<< Previous 8 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: M a r c
Subject: Re: Sphere with longitudes and latitudes?
Date: 11 Nov 2007 17:03:57
Message: <47377c4d@news.povray.org>

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

From: Chris B
Subject: Re: Sphere with longitudes and latitudes?
Date: 11 Nov 2007 17:09:00
Message: <47377d7c@news.povray.org>
"Hadmut Danisch" <had### [at] danischde> 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

From: Trevor G Quayle
Subject: Re: Sphere with longitudes and latitudes?
Date: 11 Nov 2007 21:30:01
Message: <web.4737b997a8d0eaa2ae8612c0@news.povray.org>
Hadmut Danisch <had### [at] danischde> 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

From: Mike Williams
Subject: Re: Sphere with longitudes and latitudes?
Date: 11 Nov 2007 22:46:24
Message: <v7AYRBAIu8NHFwId@econym.demon.co.uk>
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

From: M a r c
Subject: Re: Sphere with longitudes and latitudes?
Date: 12 Nov 2007 02:44:02
Message: <47380442$1@news.povray.org>

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

From: M a r c
Subject: Re: Sphere with longitudes and latitudes?
Date: 12 Nov 2007 03:09:27
Message: <47380a37@news.povray.org>

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

From: SharkD
Subject: Re: Sphere with longitudes and latitudes?
Date: 8 Jan 2008 16:00:00
Message: <web.4783e426a8d0eaae458a4ca0@news.povray.org>
"Chris B" <nom### [at] nomailcom> 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

From: Chris B
Subject: Re: Sphere with longitudes and latitudes?
Date: 8 Jan 2008 17:54:03
Message: <4783ff0b$1@news.povray.org>
"SharkD" <nomail@nomail> wrote in message 
news:web.4783e426a8d0eaae458a4ca0@news.povray.org...
> "Chris B" <nom### [at] nomailcom> 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

From: SharkD
Subject: Re: Sphere with longitudes and latitudes?
Date: 8 Jan 2008 18:15:00
Message: <web.4784037aa8d0eaae458a4ca0@news.povray.org>
"Chris B" <nom### [at] nomailcom> 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

From: Nicolas Alvarez
Subject: Re: Sphere with longitudes and latitudes?
Date: 8 Jan 2008 18:21:21
Message: <47840571$1@news.povray.org>

> 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

<<< Previous 8 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.