how to find if a point lies within a square

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amrit007
    New Member
    • Sep 2017
    • 1

    how to find if a point lies within a square

    my question ask to n in_out(xs,ys,si de) that takes three numbers as input, where
    side is non-negative. Here xs and ys represent the x and y coordinates of the bottom
    left corner of a square; and side represents the length of the side of the square.
    (Notice that xs, ys, and side completely define a square and its position in the plane).
    Your function should first prompt the user to enter two numbers that represent the x
    and y coordinates of some query point. Your function should print True if the given
    query point is inside of the given square, otherwise it should print False. A point on the
    boundary of a square is considered to be inside the square
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    If you have the coordinates of the bottom left corner and the length of the sides, then all you need to do is check that the user inputted x is between the left and right side x's and the y is between the top and bottom y's.

    What have you tried to far?

    Comment

    Working...