Hi, how do i find a corner between two vectors?

1 and 2 is the vector position, and red cricle is the position i want to find from the compute

Hi, how do i find a corner between two vectors?

1 and 2 is the vector position, and red cricle is the position i want to find from the compute

1 Like

You should be able to just take the x from v1 and y from v2 if there is no type of translation going on and the corner should be aligned with the world coordinatesâ€¦

2 Likes

If you assume that the â€ścornerâ€ť is axis aligned, and the vectors are 3D vectors, then there are six possible â€ścornersâ€ť â€“ the two vectors span a box, and the box has corners made up of picking X, Y, and Z from each of the vectors â€“ two choices per coordinate, three coordinates, total of 8 corners of a box. Two of those corners are already specified by you, so 6 corners remain.

Now, letâ€™s assume that we know that the second vertex is moved in Y and X, and you want the corner that shares the first vertex position in Y. Further, letâ€™s assume that the vertices are on the same Z plane. In your illustration, this would be true if Y is to the right, and X is forward, and Z is up (typical Unreal coordinate system.)

IN THIS CASE, if the point on the left is `left`

and the point on the right is `right`

, you can say: `FVector corner(left.X, right.Y, left.Z);`

This is also easily done in Blueprint, use â€śbreak vectorâ€ť and pick the X, Y, and Z coordinates of a new â€śmake vectorâ€ť as appropriate.

IN THE GENERAL CASE, you have to define what basis you want â€“ what does â€śforwardâ€ť mean and which direction is â€śmost importantâ€ť to follow for your corner? This is needed so that the math can break the tie that exists in your illustration, because the bottom-right side of the picture is just as â€śgoodâ€ť for a â€ścorner.â€ť And if the points are at different elevation, you get another 4 possible corners, for an axis-aligned box. And if you donâ€™t want axis alignment, you have to also transform the corners into the space where you DO want them to line up.

2 Likes

Thanks for all of the amazing tips, got it to work.

One last question, is there a way to smooth the corners by adding more corner points? Not sure how to go about it