Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to get the coordinates inside

  1. Mar 21, 2009 #1
    What's the formula on how to get the coordinates inside of:
    a) Square
    b) Triangle
    c) Circle
    d) Oval

    I tried the formula here, for triangle, (http://2000clicks.com/mathhelp/GeometryPointAndTriangle3.htm [Broken]) but sometimes even though the point is inside it says it is not.
     
    Last edited by a moderator: May 4, 2017
  2. jcsd
  3. Mar 21, 2009 #2
    A half-plane is given by an equation of the form [tex]xn_x+yn_y-d\ge 0[/tex] where [tex](n_x,n_y)[/tex] is the inward pointing normal vector of the boundary line, and [tex]d=p_xn_x+p_yn_y[/tex], where [tex](p_x,p_y)[/tex] is a point on the boundary.

    To test if a point is inside the half-plane, you only need to check the above inequality.

    Since a triangle (resp. a square) is the intersection of 3 (resp. 4) half-planes, you just need to figure out their equations and do the test for each one.

    For an ellipse of the form [tex]ax^2+by^2-c=0[/tex], the corresponding inequality for the points inside it is [tex]ax^2+by^2-c\le 0[/tex].
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook