Thread: Finding a point within a circle

  1. #1
    Unregistered
    Guest

    Finding a point within a circle

    This is either a total newbie question or then it's a totally difficult question. Anyhow.
    I'm working on a gravity-simulation program and I'm right now working on a method to define all points within a circle and it seems that I've struck a dead end. I can't think of anything.
    I think that analytic geometry holds the key to this, but I haven't figured it out.
    So: I don't necessarily need code. I'll just need a method to discern between points inside and outside of a circle whose function and radius are known.

  2. #2
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    the equation of a circle is x^2 + y^2 = r^2

    all points within the circle
    x^2 + y^2 <= r^2

    all points outside of circle
    x^2 + y^2 > r^2

    I'm pretty sure that's right.
    Last edited by taylorguitarman; 09-23-2001 at 11:29 AM.

  3. #3
    Ethereal Raccoon Procyon's Avatar
    Join Date
    Aug 2001
    Posts
    189
    That's only if the circle is located at (0, 0).

    More generally, a circle is specified by three variables:

    center x-coordinate (xo)
    center y-coordinate (yo)
    radius (r)

    The circle is then defined by the equation:

    (x - xo)^2 + (y - yo)^2 = r^2.

    If a point (x, y) is inside the circle, therefore, the follwing statement will be true:

    (x - xo)^2 + (y - yo)^2 < r^2.

  4. #4
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    good point.

    just a simple translation of the points gets it to (0,0).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Half of the circle
    By hdragon in forum Game Programming
    Replies: 14
    Last Post: 03-10-2006, 10:15 PM
  2. overloading operator help
    By syrel in forum C++ Programming
    Replies: 8
    Last Post: 09-30-2004, 10:49 AM
  3. Array of pointers to point objects
    By totalfreeloader in forum C++ Programming
    Replies: 6
    Last Post: 11-27-2003, 09:26 AM
  4. circle filling
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-08-2002, 05:37 AM