POV-Ray : Newsgroups : povray.general : Surface of a sphere : Re: Surface of a sphere Server Time
12 Aug 2024 11:15:14 EDT (-0400)
  Re: Surface of a sphere  
From: Josh English
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

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