Quote: "Well, I think that the outer shell thins, and the inner shell thickens, and the hole expands, all by the same amount, so that the shells still add up to the total holes. I just didn't draw that part accurately."
Yes, actually you explained it much better. That's what I meant. Hard concept to convey
Okay, nearly finished a small demo for you...
EDIT: Here you go. Seems to work just fine!
sync on : sync rate 30
disable escapekey
set text font "Verdana" : set text size 12
`show results
x1 = screen width()/4
x2 = screen width()/2
x3 = x1 + x2
y = screen height()/2
`set some values
outerrad# = 100
innerrad# = 30
do
REM EDIT THE SIZES ACCORDING TO USER INPUT
if escapekey() then end
innerrad# = innerrad# + rightkey() - leftkey()
outerrad# = outerrad# + upkey() - downkey()
REM THIS PART WORKS OUT THE NEW SIZE OF THE OUTER SHELL
`this is the larger sphere
radiusO1# = outerrad#
radiusI1# = get_inner(radiusO1#)
`this is the smaller sphere
radiusO2# = innerrad#
radiusI2# = get_inner(radiusO2#)
`get the new larger radius
radiusO3# = get_new_outer(radiusO1#, radiusO2#)
radiusI3# = get_new_inner(radiusO3#, radiusO2#)
REM DISPLAY RESULTS
cls
`text
center text screen width()/2,screen height()/4,"Up/Down - Edit Outer Sphere | Left/Right - Edit Inner Sphere"
`starting larger circle
d3d_circle x1,y,radiusO1#,1,rgb(255,255,255)
d3d_circle x1,y,radiusI1#,1,rgb(0,0,0)
`starting smaller circle
d3d_circle x2,y,radiusO2#,1,rgb(255,0,0)
d3d_circle x2,y,radiusI2#,1,rgb(0,0,0)
`final larger circle
d3d_circle x3,y,radiusO3#,1,rgb(255,255,255)
d3d_circle x3,y,radiusI3#,1,rgb(0,0,0)
`show smaller too!
d3d_circle x3,y,radiusO2#,1,rgb(255,0,0)
d3d_circle x3,y,radiusI2#,1,rgb(0,0,0)
sync
loop
function get_inner(radius#)
`get the volume
vol1# = (4.0 / 3.0) * PI() * radius#^3
`get half the volume
vol2# = vol1# / 2.0
`get the radius for half the volume
rad2# = (vol2# / ((4.0 / 3.0) * PI()))^(1.0/3.0)
endfunction rad2#
function get_new_outer(OuterRad#, InnerRad#)
`get the volume of the larger sphere
volume1# = (4.0 / 3.0) * PI() * OuterRad#^3
`get the volume of the smaller sphere
volume2# = (4.0 / 3.0) * PI() * InnerRad#^3
`get the volume of both added together
volume3# = volume1# + volume2#
`get the radius for the full volume (new outer)
NewRad# = (volume3# / ((4.0 / 3.0) * PI()))^(1.0/3.0)
endfunction NewRad#
function get_new_inner(OuterRad#, InnerRad#)
`get the volume of the larger sphere
volume1# = (4.0 / 3.0) * PI() * OuterRad#^3
`get the volume of the smaller sphere
volume2# = (4.0 / 3.0) * PI() * InnerRad#^3
`get the new inner volume
volume3# = volume2# + (volume1# / 2)
`get the radius for the inner volume (of outer shell)
NewRad# = (volume3# / ((4.0 / 3.0) * PI()))^(1.0/3.0)
endfunction NewRad#
