I have four vectors $ d,w,c,n \in \mathscr{R}^3$. I want to find a rotation matrix $R$ that satisfies these constraints: $w$ is aligned with $d$ after rotation AND $c$ is perpendicular to $n$ after rotation. You can imagine it in two steps: after a first rotation that aligns $w$ with $d$, make a second rotation around $d$ so that $c$ becomes perpendicular to $n$. In a particular problem I am working on $d=[1,1,1]^T$ and $n=[0,0,1]^T$.
I believe the constraints can be expressed with these two equations
$$ d \times Rw=0$$ $$ n^T Rc=0$$
In addition, we must impose a third condition for $R$ being a rotation matrix $$ RR^T=I$$
Is there a nice way to solve for R using matrix algebra? Or how to formulate the two steps above?
I tried to play with Kronecker products to form a vectorized version of $R$, but did not reach a solution. With $S=skew(d)$ being the skew vector for cross product: $$d \times Rw=SRw=0 \rightarrow (w^T \oplus S)vec(R)=0$$ $$n^T Rc=0 \rightarrow(c^T \oplus n^T)vec(R)=0$$ but could not impose the $RR^T=I$
I think this will not work unless the angle between $n$ and $w$ equals that between $n$ and $d$, which may not be true.