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$
2
  • $\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
    Commented Sep 15, 2019 at 22:34
  • $\begingroup$ There are non-branching ways to do this yes, but not continuous. the non-branching methods are usually implemented with hardware supported discontinuous functions. Here are two examples of such math.stackexchange.com/questions/137362/… and graphics.pixar.com/library/OrthonormalB/paper.pdf $\endgroup$
    – yosmo78
    Commented Aug 31 at 23:56

1 Answer 1

3
$\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$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .