• Advertisement
Sign in to follow this  

Finding vector perpendicular to line in 3D

This topic is 1255 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need a robust method for finding any vector that is perpendicular to a line in 3D. I know that there is an infinite number of them, but I just need any one of them.

Share this post


Link to post
Share on other sites
Advertisement
You know that the dot product between your unknown vector (x,y,z) and the line direction vector (A,B,C) is 0, which gives you the equation Ax + By + Cz = 0. If you let 'x' and 'y' be 1, then 'z' is -(A+B)/C. The issue is that C might be zero, so you want to make sure and solve for the component (by plugging in 'x' and 'z' instead and solving for 'y', etc.) whose corresponding value in the line direction vector isn't 0 (choosing the one largest in magnitude would help stabilize the division). From there you can normalize the vector and be done.

Another approach is to find which component in the line direction vector is closest to zero, and create a vector where that component value is 1 and the rest are 0. You can then use something like Gram-Schmidt to find the perpendicular vector.

Unfortunately, the hairy ball theorem tells us that you need conditional logic to make this process work for any given line direction, because there is no continuous function we can use.

Share this post


Link to post
Share on other sites
Solving the dotproduct equation was my initial solution to the problem. I was hoping for a prettier solution, but I guess it'll have to do. Thanks for the interesting wikipedia link (Hary ball theorem) :)

Share this post


Link to post
Share on other sites
Quote:
Original post by _swx_
Solving the dotproduct equation was my initial solution to the problem. I was hoping for a prettier solution, but I guess it'll have to do. Thanks for the interesting wikipedia link (Hary ball theorem) :)
I'm not sure if Zipster already mentioned this, but one solution is to find the element of the line direction vector with the smallest magnitude (as Zipster mentioned), and then cross the direction vector with the cardinal basis vector ([1, 0, 0], [0, 1, 0], or [0, 0, 1]) that corresponds to this element. (This is the method I prefer for computing an arbitrary vector perpendicular to another vector, an operation commonly needed for billboarding, decals, and so forth.)

Share this post


Link to post
Share on other sites
Thanks for the replies. I'm going to use the cross-product solution since it produces nice vectors :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Zipster
Unfortunately, the hairy ball theorem tells us that you need conditional logic to make this process work for any given line direction, because there is no continuous function we can use.


Why? The space here is RP^2, not S^2... granted, that's just S^2 with antipodes identified, but still, it doesn't jump out at me that this should automatically carry over... (But then, lots of things that should jump out at me seem not to...)

Actually, here you go: The hairy ball theorem says you can't have a smooth nonvanishing vector field on S^2. However, just ONE vanishing point is enough. E.g., consider a constant vector field on the plane multiplied by a radial falloff and mapped to the sphere by stereographic projection.

So now, here's a way to get a continuous (albeit nonsmooth) nonvanishing vector field on RP^2: Since each point on RP^2 is identified with two points on the sphere, just take whichever of the two vectors (from the vector field) has larger norm.

Then, there's always an analytic function arbitrarily close to any continuous function (constructively: Run the heat equation for epsilon seconds), so you can now get a smooth vector field from the continuous one constructed above.

(An alternate construction could have used some kind of "soft max" operator.)

Have I missed something?

[Edited by - Emergent on June 1, 2010 4:07:20 PM]

Share this post


Link to post
Share on other sites
I'm going to admit right off the bat that you probably know more about the underlying mathematics than I do, since I haven't studied projective spaces in much depth, but...

Quote:
Original post by Emergent
So now, here's a way to get a continuous (albeit nonsmooth) nonvanishing vector field on RP^2: Since each point on RP^2 is identified with two points on the sphere, just take whichever of the two vectors (from the vector field) has larger norm.

Wouldn't this require a conditional to determine the one with the larger norm?

Quote:
Have I missed something?

Probably not :) I've honestly just never seen a solution to this problem that didn't at some point require conditional logic in one way or another, due to the nature of the tangent field. But I'm certainly open to the possibility that one exists.

Share this post


Link to post
Share on other sites
*sigh*; I really need to think/read more before posting...

From Wikipedia:
Quote:
A consequence of the hairy ball theorem is that any continuous function that maps a sphere into itself has either a fixed point or a point that maps onto its own antipodal point. This can be seen by transforming the function into a tangential vector field as follows.


Hence, any smooth map from RP^2 to RP^2 has a fixed point. At the fixed point,

f(p)=p || p

so there's no way to have f(p) perpendicular to p for all p.

They even give the proof right there...

Share this post


Link to post
Share on other sites

If you rotate your direction vector twice (90° arround x-axis and 90° around y-axis) you get an arbitrary vector that is linearly independent of the direction vector. Then you retrieve a perpendicuar vector to those two vectors via cross product.

 

Or is there an error in reasoning for that method?

 

 

Edit: Oh yes there are cases where this fails -.- e.g. (1,0,-1) turned arround x-axis by 90° then turned arround y-axis by 90° results in the same vector. But can it still fail when turned by different angles like 30° and 60° ?

Edited by hageldave

Share this post


Link to post
Share on other sites

This topic is 1255 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement