Determine if Vector3 is within an area made by two Vector3

How do I know if a Vector3(position) it’s inside a square area made by other 2 Vector3

example image:


Since vectors don’t have rotation associated with them, I’m assuming that you are treating this like a region 3 except with a point instead of parts. You can do this with each axis.
if X>math.min(X1,X2) and X<math.max(X1,X2) and
Y>math.min(Y1,Y2) and Y< etc etc

1 Like

Something similar to this was done before, you might get some use out of this thread

A search does this?


Being honestly, I’m not good at searching things because I’m sure there’s a post but I use different keywords and I don’t have too much time so I decided to make a post.

I think the issue is that the DevForum search bar is a bit inaccurate rather than just Google searching

But yeah I suppose you can try that function, & it’ll either return back as “true” or “false”

What do you mean by X1 and X2? The upper and lower X?

X1 and X2, in this case, represent the x component of the Vector3’s

1 Like

X is the X component of the point, and X1/X2 are the X components of the boundaries.

Yes, but 1 is the lower bound and 2 is the upper bound?

It doesn’t matter, that’s why math.max and min. If I did make it matter, you would have to be careful to place one of them at higher XY and Z values. It would be slightly more efficient if you did that, but you’d have to be very careful that you placed the boundaries in the correct corners. I’m certain this way is good enough and that you will not need to worry about the small performance boost.

In other words it functions like region 3 does and it takes two points in any configuration.

Yeah, I was about to say “it does not work” but I was using the incorrect arguments in the function that I’m creating haha