PDA

View Full Version : Ring conforms to the circumference of sphere

 boomji12-08-2008, 09:37 AMHi, 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, 10:16 AM
say
posZ is the distance of the ring when travelling along the axis of the sphere
then the value
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, 10: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

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, 10:43 AM
EDIT: arg aaaaCHoooo you beat me to it!