POV-Ray : Newsgroups : povray.general : Sphere with longitudes and latitudes? : Re: Sphere with longitudes and latitudes? Server Time
31 Jul 2024 10:21:15 EDT (-0400)
  Re: Sphere with longitudes and latitudes?  
From: SharkD
Date: 8 Jan 2008 23:05:00
Message: <web.47844740a8d0eaae458a4ca0@news.povray.org>
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

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