0

I am stuck on this simple question.

I have a rectangle and a point x that I don't know whether it's inside or outside the box. The only thing I know is the distance of point x from a point that I marked on the boundary.

Even if I calculate the coordinates I will have the coordinates for inside and for outside and still, I won't be sure where the point lies.

Thank you

Jean Marie
  • 81,803
  • Possible duplicate https://math.stackexchange.com/questions/190111/how-to-check-if-a-point-is-inside-a-rectangle – Roland Schulz May 01 '21 at 11:52
  • 1
    With only such a distance given, you cannot decide whether the point is inside or outside. At best, the distance is greater than the distance of the reference poin from all vertices, in which case you can infer that the other point is definitely outside, – Hagen von Eitzen May 01 '21 at 11:53
  • Your question should maybe be asked in terms of probability of being inside/outside. – Jean Marie May 01 '21 at 11:54
  • If you have the boundaries equation than by just inserting coordinates and calculating the sign you may get the location of x with reference to the boundaries and from here if in or out. – Moti May 02 '21 at 05:08
  • @RolandSchulz yes but that is just for right-angle triangles. the only thing I know is distance I don't know if it is right-angled or else – user15780268 May 02 '21 at 09:28
  • @JeanMarie yes kind of. how can we do that ? can you please guide a little – user15780268 May 02 '21 at 09:29
  • I fear that the probability is around fifty-fifty, therefore not very informative. For me, your issue is too fuzzy. You should explain the context, and take an example. – Jean Marie May 02 '21 at 09:33

1 Answers1

0

Point-in-convex-polygon method will work for any rectangle since rectangles are always convex.

You could check that the point is located on the inner side of each line segment of the rectangle. Or you could use the Barycentric approach. Other possibility is to split the rectangle into two triangles and lookup the solution for that case (very similar approach to a rectangle) if it makes it easier to understand (neatly described here).