POV-Ray : Newsgroups : povray.general : Surface of a sphere Server Time
12 Aug 2024 13:14:47 EDT (-0400)
  Surface of a sphere (Message 1 to 4 of 4)  
From: Andrew Cocker
Subject: Surface of a sphere
Date: 21 Feb 1999 15:34:47
Message: <36d06de7.0@news.povray.org>
Hi all,

I'm not sure how to describe what I want to be able to do, but I'll try.
Lets say that I create, by CSG, a shape that can be described thus:
Start with a sphere. On the surface, describe a square equivalent to 18 degrees of the
entire sphere, then narrow it until at the centre it becomes zero. What I'm trying to
describe is a segment or wedge.
What I want to know is..what is the math that would allow me to reconstruct a sphere
out
of these pieces. I could type each rotation by hand, but I want to be able to apply
random
scaling with regards to the radius of the sphere that each segment originates from. By
that I mean that one segment could have come from a sphere with radius 1, while
another
could have come from a sphere with radius 1.4 etc...so the end result would be a
sphere
made up of segments varying in height, but all being 18 degrees of the entire surface.

I apologise if my explanation is unclear. If you don't understand, then let me know
and
I'll try again. This sounds to me like a candidate for a macro ( but I don't at the
moment
know where to begin ). My main problem is that I can't work out how to make sure every
space is occupied by a segment. Although it would probably look good if not every
space
*was* occupied.

Thanks in advance if anyone can come up with any suggestions.

Andy


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Surface of a sphere
Date: 22 Feb 1999 00:09:08
Message: <36D0E686.54B15C64@virginia.edu>
Take a look at my macro for creating a sphere with Torii (in
text.scene-files) it isn't perfect, but should give you a start.  

Steve


Andrew Cocker wrote:
> 
> Hi all,
> 
> I'm not sure how to describe what I want to be able to do, but I'll try.
> Lets say that I create, by CSG, a shape that can be described thus:
> Start with a sphere. On the surface, describe a square equivalent to 18 degrees of
the
> entire sphere, then narrow it until at the centre it becomes zero. What I'm trying
to
> describe is a segment or wedge.
> What I want to know is..what is the math that would allow me to reconstruct a sphere
out
> of these pieces. I could type each rotation by hand, but I want to be able to apply
random
> scaling with regards to the radius of the sphere that each segment originates from.
By
> that I mean that one segment could have come from a sphere with radius 1, while
another
> could have come from a sphere with radius 1.4 etc...so the end result would be a
sphere
> made up of segments varying in height, but all being 18 degrees of the entire
surface.
> 
> I apologise if my explanation is unclear. If you don't understand, then let me know
and
> I'll try again. This sounds to me like a candidate for a macro ( but I don't at the
moment
> know where to begin ). My main problem is that I can't work out how to make sure
every
> space is occupied by a segment. Although it would probably look good if not every
space
> *was* occupied.
> 
> Thanks in advance if anyone can come up with any suggestions.
> 
> Andy


Post a reply to this message

From: Josh English
Subject: Re: Surface of a sphere
Date: 22 Feb 1999 12:44:09
Message: <36D1984D.5F0C7315@spiritone.com>
You can start with a sphere and differnce out boxes rotate 18 degrees apart from one
another
like this:

difference {
  sphere { <0,0,0> 1 }
  box { <-2,-2,0> <2,2,2> rotate 9*x }
  box { <-2,-2,0> <2,2,-2> rotate =9*x }
 texture { foo }
}

If I understand you correctly, this will give you the wedge, but it will go from
horizon to
horizon (looks like an apple slice) If you want to give the top side a squarish shape
add a
third box to the difference statemet like this:

difference {
  sphere { <0,0,0> 1 }
  box { <-2,-2,0> <2,2,2> rotate 9*x }
  box { <-2,-2,0> <2,2,-2> rotate =9*x }
  box { <-2,-2,2> <0,2,2> rotate 9*z }
 texture { foo }
}

That should give the top a squarish shape that covers one quarter of the circumference
of the
sphere (give or take)

Throw of that into one object:

#declare MySlice =
  all that code above (I hate retyping and cutting and pasting)

Then put in objects :
object {MySlice}
object { MySlice rotate 18*x scale 1.2 }
ojbect { MySlice rotate 36*x scale 0.6 }

ad nauseum... this will let you adjsut each one, and scaling should work because taken
as a
whole, the original sphere was centered at the origin.

This does mean that all the slices are rotating around the x axis. If you want the
small
points of the slice to land on the y axis (which may be what you wanted in the first
place)
try this:

difference {
  sphere { <0,0,0> 1 }
  box { <-2,0,0> <2,-4,-4> rotate 9*x translate 1*y }
  box { <-2,0,0> <2,-4,4> rotate -9*x translate 1*y }
  box { <-2,0,-2> <2,-2,2> }
  texture { foo }
}

this should give you one quarter slice. Now, (again, I hope I'm explaining all of the
theory
well enough) if you want the slices to cover a full half of the circumference it gets 
a bit
more complicated:

difference {
  sphere { <0,0,0> 1 }
  box { <-2,0,0> <2,-4,-4> rotate 9*x translate 1*y }
  box { <-2,0,0> <2,-4,4> rotate -9*x translate 1*y }
  box { <-2,0,0> <2,4,-4> rotate -9*x translate -1*y }
  box { <-2,0,0> <2,4,4> rotate 9*x translate -1*y }
  texture { foo }
}

Now that gives you the slice. To place them individually  we would then add them to an
object
(as we did above, please don't make me retype it, I'm getting too verbose as it is)
and call
each ojbect individually:

object {MySlice rotate 18*n*y}

where n is any integer. TO do this automatically and randomize the sizes of each
slice:

#declare R1= seed(some number);
#declare RotationAmount = 0;
#declare MinScale = 0.5;
#declare MaxScale = 2.0;

#while (RotationAmount < 360)
  #declare ThisScale = rand(R1)*(MaxScale-MinScale) + MinScale;
  object { MySlice scale ThisScale  rotate RotationAmount }
  #declare RotationAmount = RotationAmount + 18;
#end

All of this code is untested but should work barring any typos I can't see right now

--
Josh English
eng### [at] spiritonecom
www.spiritone.com/~english


-

Andrew Cocker wrote:

> Hi all,
>
> I'm not sure how to describe what I want to be able to do, but I'll try.
> Lets say that I create, by CSG, a shape that can be described thus:
> Start with a sphere. On the surface, describe a square equivalent to 18 degrees of
the
> entire sphere, then narrow it until at the centre it becomes zero. What I'm trying
to
> describe is a segment or wedge.
> What I want to know is..what is the math that would allow me to reconstruct a sphere
out
> of these pieces. I could type each rotation by hand, but I want to be able to apply
random
> scaling with regards to the radius of the sphere that each segment originates from.
By
> that I mean that one segment could have come from a sphere with radius 1, while
another
> could have come from a sphere with radius 1.4 etc...so the end result would be a
sphere
> made up of segments varying in height, but all being 18 degrees of the entire
surface.
>
> I apologise if my explanation is unclear. If you don't understand, then let me know
and
> I'll try again. This sounds to me like a candidate for a macro ( but I don't at the
moment
> know where to begin ). My main problem is that I can't work out how to make sure
every
> space is occupied by a segment. Although it would probably look good if not every
space
> *was* occupied.
>
> Thanks in advance if anyone can come up with any suggestions.
>
> Andy


Post a reply to this message

From: F VERBAAS
Subject: Re: Surface of a sphere
Date: 22 Feb 1999 13:59:30
Message: <36d1a912.0@news.povray.org>
Now, let me see. You can make a 'square' cone with a rounded base, simply
by:

#local a=tan(radians(9));

intersection{
   sphere{0,1}
   prism {
     conic_sweep
     linear_spline
     0, // height 1
     1, // height 2
     5, // the number of points making up the shape...
      <a,a>,<-a,a>,<-a,-a>,<a,-a>,<a,a>
    scale 2
  }
  rotate z*90
}

or something like that, but you will NOT be capable of building a sphere
from them, only a cross section, describing 9 degrees South to 9 degrees
North, if you rotate around the vertical axis.
To get pyramids to describe say 9 degrees North to 27 degrees north, you
need another base shape, representing some kind of trapezium, with one side
scaled by cos(radians(90-9-18)). This method leads to a
sphere with large patches at the equator, and fine patches at the poles.

A more promising method is the application of hexagons or triangles.

FRans





Andrew Cocker heeft geschreven in bericht <36d06de7.0@news.povray.org>...
>Hi all,
>
>I'm not sure how to describe what I want to be able to do, but I'll try.
>Lets say that I create, by CSG, a shape that can be described thus:
>Start with a sphere. On the surface, describe a square equivalent to 18
degrees of the
>entire sphere, then narrow it until at the centre it becomes zero. What I'm
trying to
>describe is a segment or wedge.
>What I want to know is..what is the math that would allow me to reconstruct
a sphere out
>of these pieces. I could type each rotation by hand, but I want to be able
to apply random
>scaling with regards to the radius of the sphere that each segment
originates from. By
>that I mean that one segment could have come from a sphere with radius 1,
while another
>could have come from a sphere with radius 1.4 etc...so the end result would
be a sphere
>made up of segments varying in height, but all being 18 degrees of the
entire surface.
>
>I apologise if my explanation is unclear. If you don't understand, then let
me know and
>I'll try again. This sounds to me like a candidate for a macro ( but I
don't at the moment
>know where to begin ). My main problem is that I can't work out how to make
sure every
>space is occupied by a segment. Although it would probably look good if not
every space
>*was* occupied.
>
>Thanks in advance if anyone can come up with any suggestions.
>
>Andy
>
>


Post a reply to this message

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