PDA

View Full Version : Ring conforms to the circumference of sphere


boomji
12-08-2008, 10:37 AM
Hi,
Not a script question per say but a math related one.
Scnario:
1. a sphere of radius: 100
2. a circle shape of radius: 100
3.I align the circle to the sphere

I want the circle to start with radius 100 and when i take it(or animate) down to the bottom of the sphere(pole) it should zero out in radius.

Ring conforms to the circumference on each step of it's way down.
What would the math be in this situation.

i could hack this by:
1.At each step along it's down path(circle Pivot) shoot a ray to the sphere and use the the magnitude to drive the radius.

but that wont further my mathematical understanding of the problem.

Thanks for any help.


b

shibumenon
12-08-2008, 11:16 AM
say
sphRad is the radius of the sphere and
posZ is the distance of the ring when travelling along the axis of the sphere
then the value
squareRoot(sphRad*sphRad - posZ*posZ)
if applied to the radius of the ring, the ring should confirm exactly to the circumference of the sphere.
posZ needs to be evaluated wrt the sphere's pos.
You could use the math as either an expression or a float script on the radius of the ring.

cheers
Shibu

Gravey
12-08-2008, 11:25 AM
as far as maths goes in 3D: triangles are king! see my super amazing diagram below :)

http://forums.cgsociety.org/attachment.php?attachmentid=135870&stc=1

In the above diagram:
r = the radius of the sphere
d = the distance away from the center of the sphere
x = your new radius

so its a simple trig calculation. the old c^2 = a^2 + b^2 or in this case r^2 = d^2 + x^2
so we rearrange the equation so that we can solve for x:
x^2 = r^2 - d^2
x = sqrt (r^2 - d^2)

EDIT: arg aaaaCHoooo you beat me to it!

boomji
12-08-2008, 11:43 AM
EDIT: arg aaaaCHoooo you beat me to it!


Actually both were EXTREMELY helpful.
One was concise and the other visual.
The penny has dropped :thumbsup:


b

CGTalk Moderation
12-08-2008, 11:43 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.