2
$\begingroup$

I have a unit vector $N$ which is the normal to some flat surface. I want to generate two other unit vectors $U$ and $V$ which are mutually perpendicular and lie in this surface, so $(N,U,V)$ will be a set of basis vectors. It does not matter how $U$ and $V$ are rotationally oriented.

In principle I can choose an arbitrary unit vector $M \neq N$ and take cross-products, but this isn't numerically stable in all cases.

Example of something which will not work, choosing $M=N+(1,0,0)^T$, because in the special case that $M=(1,0,0)^T$, the cross products will degenerate.

I can tweak this algorithm with suitable checks, obviously, but this will run on embedded hardware which doesn't handle conditional branches very well and performance is an issue.

Is there a numerically-stable, non-branching algorithm for picking $U$ and $V$ given $N$?

$\endgroup$
1
  • $\begingroup$ Take a basis $v_k$ and apply Gram Schmidt to $N,v_1,...$ and remove the element that gets reduced to zero. (Hmm, I guess that latter step is branching?) $\endgroup$ – copper.hat Sep 15 '19 at 22:34
2
$\begingroup$

What you want is not possible, otherwise you could construct a continuous unit vector field tangent to the sphere.

A "stable and non-branching" algorithm produces a continuous function. If you apply this to the sphere and its normal and select the first orthogonal vector as the unit vector field, you would get such a continuous tangential field without zeros. However, as is well known, any such vector field has to have at least one singularity, this is the hedgehog or hairy ball theorem.

To avoid producing a singularity you need to cover the unit ball with at least two charts (explicitly or implicitly), which implies branching, and the constructed orthogonal frames are not continuous at the boundary of the charts.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.