Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a formula to get a vector perpendicular to another vector?

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?

like image 354
MaiaVictor Avatar asked Jun 21 '12 06:06

MaiaVictor


People also ask

How do you find a vector that is perpendicular to another vector?

The vectors ⃑ 𝐴 and ⃑ 𝐵 are perpendicular if, and only if, their dot product is equal to zero: ⃑ 𝐴 ⋅ ⃑ 𝐵 = 0 .

What is perpendicular in vector?

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.


1 Answers

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.

like image 63
golopot Avatar answered Nov 09 '22 13:11

golopot