Problems with part orientations

Hello!
I’m HottylewrSlip, a programmer at Roblox.

Well, I have a somewhat confusing problem involving the orientations of the pieces, as I am making a system in which I identify any objects within an area and if that particular object is outside the area it will be corrected to the closest position within this area , however, this object can contain guidelines that get in the way of the calculation itself and I confess that I’m terrible at math.

image

Above you can see that I have a black area and a blank object. The problem in the image above is that the object is outside this area, but we don’t need to worry, after all, making this object go back inside the area is simpler than moving forward, we just need to identify the maximum position of our object with respect to the center of our area and the size of our object.
This would be really easy if we didn’t have the orientation of our object, what gets in our case is the edge that remains outside, after all when we base ourselves on the position to identify the maximum and minimum point of an area we have in mind that we are only working with the center of the object and not its edges, so these edges will be outside the area.

I thank you already! :wink:

Try this.

1 Like