

You have to decide whether that matters to you. It also has a downside: if $C$ is very close to the line $AB$, the magnitude of the resulting vector gets very small. But it has one advantage: there's no branching, which can be helpful on some highly-parallel architectures (or at least this used to be the case). Is this a winning algorithm? I haven't counted the operations in the other one.
Find perpindicular vector 2d plus#
You needn't compute the $z$-component (it'll be zero), so you end up doing a total of $6$ multiplies and $3$ subtracts, plus the 6 subtractions to compute $u$ and $t$ in the first place. Then you compute $v = t \times s$, and this vector will point in the right direction. Īn alternative approach is to compute $s = u \times t$ (in 3-space), which seems bad because it's a cross-product, which looks like 2 multiplies and a subtraction for each term.but you only need to compute the "z" term because the other two are always zero. If it's $0$, then $C$ is actually collinear with $A$ and $B$, which is kind of a free sanity-check that your inputs were valid. If this turns out positive, then $u$ and $v_1$ point into the same halfplane, and your answer is $v_1$ if it's negative, your answer is $v_2$. The vectors $v_1$ and $v_2$ are indeed both nonzero and perpendicular to $L$, and also point in opposite directions, so one of them has to be a "good" one. I know that there are two orthogonal vectors to $T$: $\vec$? I really don't care about the magnitude of the resulting vector. Given three points $A$, $B$ and $C$, that are not colinear, I want to find the vector $v$ which is perpendicular to the line $L$ that passes from $A$ and $B$ AND points to the half-plane created by $L$ that $C$ lies on.
