I have a somewhat odd problem that maybe you can help me with. I would like to have a function which can take in two vectors, let’s call them A & B, and it should return a vector which is 90 degrees perpendicular to vector A, and as close to vector B as possible.

Basically I want a function which snaps vector B to being 90 degrees perpendicular to vector A.

Any idea on how I can accomplish that?