Results 1 to 6 of 6

Thread: Calculate Radius of a sphere

  1. #1

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Calculate Radius of a sphere

    Okay...I got a node in a quad tree.

    I have 4 points which make up its bounding box..

    I can get the center of the 4 points easily. That center can be used as the center of the sphere.

    I am wondering how I can get the radius which would indeed cover those four points, or at least just past those 4 points. The sphere in most case's should be a bit bigger I think.

    Any help at all though?

    So far what I am doing is taking the magnitude of the a vector and dividing it by 2.
    That works in most cases's...see
    P1 (4,0) P3 (8,0)
    P2 (4,4) P4 (8,4)
    Center = ((P4 - P1) / 2) + P1 = (4,4 / 2) + 4,0 = (2,2) + (4,0) = 6,2
    Center = 6,2 is indeed correct if you wish to picture the grid.

    r^2 = x^2 + z^2 (the points I shall use will be from P4)
    r^2 = 8^2 + 4^2
    r^2 = 64 + 4
    SqrRt(r) = SqrRt(68)
    r = 8.2462112512353210996428197119482 / 2
    r = 4.1231056256176605498214098559741

    Indeed r as 4.1 is JUST outside the bounding box...is this correct????
    Last edited by Halsafar; Jan 2nd, 2005 at 11:27 PM.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Calculate Radius of a sphere

    I don't understand. Can you do us a picture in mspaint?
    Last edited by wossname; Jan 4th, 2005 at 04:35 AM.
    I don't live here any more.

  3. #3
    Junior Member
    Join Date
    Jan 2005
    Posts
    18

    Re: Calculate Radius of a sphere

    Halsafar,

    After reading through you post, we need some clarification here.

    1) Is your "bounding box" always square (or even rectangular) as in your example?
    2) Are you looking for the smallest circle that encompasses all four points?
    3) You suggest that the circle might need to be "a bit bigger" to take in the points, how much bigger?

    Incidentally, if you are looking for the smallest circle whose radius takes in all four points, your calculated radius should be SqrRt(8).

    I guess, as wossname suggested, your needs are a little unclear. Anything you can add will be of help.

    Steve

  4. #4

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Calculate Radius of a sphere

    Sorry about that. I do see how unclear I am.

    This picture should help.
    The radius is what I need to find.
    The center of the node is easy.
    The radius that encompas's past the 4 points....So the entire box is in the sphere.
    Attached Images Attached Images  
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Calculate Radius of a sphere

    So basically you want "the smallest bounding circle for any given rectangle"?

    Assuming P1 is top left point, P2 top right, P3 bottom left, P4 bottom right...

    Circle.Centre.X = (P1.X + P2.X) / 2
    Circle.Centre.Y = (P1.Y + P3.Y) / 2

    Circle.Radius = Sqrt((P4.X - Circle.Centre.X)2 + (P4.Y - Circle.Centre.Y)2)
    I don't live here any more.

  6. #6

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Calculate Radius of a sphere

    Alright sounds good.
    Thank you very much.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width