POV-Ray : Newsgroups : povray.newusers : Plotting points on a sphere? : Re: Plotting points on a sphere? Server Time
31 Jul 2024 04:23:35 EDT (-0400)
  Re: Plotting points on a sphere?  
From: Tor Olav Kristensen
Date: 4 Jan 2003 00:55:10
Message: <web.3e16760df926e896b417814a0@news.povray.org>
Jessie K. Blair wrote:
>To better explain what I'm looking for, I'll give you what I am trying to
>do.
>
>I have a sphere shaped object that I wish to place many smaller spheres
>around.  I want the smaller spheres to be plotted on the points of
>intersection of the wireframe that a sphere would consist of, allowing the
>smaller spheres to be placed in a spherical shape around the first sphere
>object.
>
>*coughs* I know that is a bit confusing, so if you need an example drawing
>or something, lemme know.
>
>Any one know how this might be accomplished?


Jessie, I see that others have provided
several suggestions on how to solve your
problem.

So you maybe you don't need yet another
suggestion.

But anyway, the code below is my suggestion.

Feel free to ask if there is anything that
you want me to explain.


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2002 by Tor Olav Kristensen
// Email: t o r _ o l a v _ k [ a t ] h o t m a i l . c o m
// http://home.no/t-o-k
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.5;

#include "colors.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro WireFrameSphere(NrLongitudes, NrLatitudes, Rmaj, Rmin)

  #local dLongitude = 360/NrLongitudes;
  #local dLatitude = 180/NrLatitudes;

  #local Cnt = 0;
  #while (Cnt < NrLongitudes)
    #local Longitude = Cnt*dLongitude;
    difference {
      torus { Rmaj, Rmin }
      plane { -z, 0 }
      rotate -90*z
      rotate Longitude*y
    }
    #local Cnt = Cnt + 1;
  #end // while

  #local Cnt = 1;
  #while (Cnt < NrLatitudes)
    #local Latitude = radians(Cnt*dLatitude - 90);
    torus {
      Rmaj*cos(Latitude), Rmin
      translate Rmaj*sin(Latitude)*y
    }
    #local Cnt = Cnt + 1;
  #end // while

#end // macro WireFrameSphere


#macro SpheresOnSphere(NrLongitudes, NrLatitudes, Rmaj, Rmin)

  #local dLongitude = 360/NrLongitudes;
  #local dLatitude = 180/NrLatitudes;

  sphere { -Rmaj*y, Rmin }
  #local Cnt1 = 0;
  #while (Cnt1 < NrLongitudes)
    #local Longitude = Cnt1*dLongitude;
    #local Cnt2 = 1;
    #while (Cnt2 < NrLatitudes)
      #local Latitude = Cnt2*dLatitude - 90;
      #local pSph = Rmaj*vrotate(-z, <Latitude, Longitude, 0>);
      sphere { pSph, Rmin }
      #local Cnt2 = Cnt2 + 1;
    #end // while
    #local Cnt1 = Cnt1 + 1;
  #end // while
  sphere {  Rmaj*y, Rmin }

#end // macro SpheresOnSphere

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Rglobe = 20;
#declare Rwireframe = 0.08;
#declare Rspheres = Rwireframe*2;

// Number of longitude intervals
#declare Longitudes = 36; // Also try 5

// Number of latitude intervals
#declare Latitudes = 18; // Also try 2

union {
  WireFrameSphere(Longitudes, Latitudes, Rglobe, Rwireframe)
  pigment { color White*1.5 }
}

union {
  SpheresOnSphere(Longitudes, Latitudes, Rglobe, Rspheres)
  pigment { color Red + White }
}

/*
sphere {
  <0, 0, 0>, Rglobe
  pigment { Grey }
}
*/

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

light_source {
  <1, 2, -2>*50
  color White
  shadowless
}

background { color Blue/2 }

camera {
  location <2, 4, -3>*10
  look_at 0*y
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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