What is a formula to get a three dimensional vector B lying on the plane perpendicular to a vector A?
That is, given a vector A, what is a formula f(angle,modulus) which gives a vector that is perpendicular to A, with said modulus and rotated through an angle?
The vectors ⃑ 𝐴 and ⃑ 𝐵 are perpendicular if, and only if, their dot product is equal to zero: ⃑ 𝐴 ⋅ ⃑ 𝐵 = 0 .
A vector perpendicular to a given vector is a vector (voiced " -perp") such that and. form a right angle. In the plane, there are two vectors perpendicular to any given vector, one rotated counterclockwise and the other rotated clockwise.
function (a,b,c)
{
return (-b,a,0)
}
But this answer is not numerical stable when a,b are close to 0.
To avoid that case, use:
function (a,b,c)
{
return c<a ? (b,-a,0) : (0,-c,b)
}
The above answer is numerical stable, because in case c < a
then max(a,b) = max(a,b,c)
, then vector(b,-a,0).length() > max(a,b) = max(a,b,c)
, and since max(a,b,c)
should not be close to zero, so is the vector. The c > a
case is similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With