Find Corner between 2 vectors?

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