# Algorithmic approach to finding two vectors that span a plane

I am working on an experiment where I need to align a magnetic field to be parallel to a nanoscale wire embedden in a microscale planar structure. My tools for doing so are two-fold: the planar structure produces a signal $S_P$ (a resonance frequency) that is maximal when the field is fully in plane and that drops off in a typical angle-dependence fashion when not in plane; this dependence smooth and monotonic and essentially noise free, but the visibility quickly reduces when out of plane as the frequency moves out of our measurement window. Similarly (but subject to more stringent conditions) I have a signal $S_W$ produced by the wire that is maximal when the field is in the plane of the planar structure and parallel to the wire; also a resonance frequency. It quickly goes down in an angular fashion both w.r.t. the in-plane angle and the out-of-plane angle. My task is then, with these tools in hand, to align the magnetic field parallel to the wire.

Given that the field is homogeneous over scales much larger than the structures, I believe one can reduce this problem to a more general problem of aligning a 3D vector with spherical coordinates $\vec{v} = (r, \phi, \theta)$ (red) to be parallel to a 1D line (blue) that lies in a 2D plane with unknown vector span (green), at some unknown angle $\xi$ w.r.t. that plane.

To do this alignment, I had the following idea. In spherical coordinates I can 'algorithmically' control $\phi$ and $\theta$ of the (red) magnetic field vector while monitoring $S_P$, to find two vectors that span the plane. I use these two vectors to set up a new polar coordinate system of that plane, in which I can then sweep the polar angle to find $\xi$ and maximize $S_W$. The second part should be trivial, but the first part is what my question is about. How do I find two vectors that span the plane, controlling $\phi$ and $\theta$ and monitoring $S_P$?

As it currently stands I can rather easily find a single vector that works by simply varying $\phi$ and $\theta$ until $S_P$ reaches a maximum in both parameters simultaneously, but how do I go from there to find a linearly independent vector that is also in the plane? How should I algorithmically 'walk' through $\phi,\theta$ space to find that other vector? I say walk because what I envision the method to be like is that I start from the local maximum, 'overrotate' in $\theta$, bring $S_P$ back up with $\phi$ and overrotate, that one a bit, and then go back to theta and repeat. That will walk me through the angle space, but how I use this to find the second vector I am not sure of.

Context

Since this is a place where we discuss physics, it might be interesting to give some context. We are working on a 'gatemon' type device (see https://arxiv.org/abs/1503.08339) which is essentially a transmon qubit with a semiconducting nanowire as the junction, and proximity-effect-induced superconducting islands made out of semiconductor segments with superconductor shells. It has a charging energy and a josephson energy and thus a resonance frequency $S_W$, and we couple it to a planar waveguide with resonance frequency $S_P$. We're interested in studying its properties in a magnetic field, but it needs to be in the plane of the waveguide to keep that superconducting, and parallel to the wire to keep that superconducting. So I'm working on a good way to get that alignment as precise as possible.

• You have the angles $\theta$ and $\phi$ of the red vector and are looking for spanning vectors of the perpendicular green plane? – Jasper Dec 29 '17 at 13:06
• That's an unintended feature of the figure, the green plane is not perpendicular, it is at an unknown angle with the red vector. I don't know the basis of the green plane. – user129412 Dec 29 '17 at 13:18
• Sweep theta with phi=0 until maximum for first vector of plane, then repeat with theta=90degrees and sweep phi for second vector. – Jasper Dec 29 '17 at 13:48
• I'm afraid that doesn't work, which I should have specified. If the field is too far out of plane $S_P$ will go down, which will be the case for theta = 90 degrees. That by itself is fine, as long as it'll come up again, but it won't. Having too large out of plane field will introduce vortices in the planar resonator (reducing its resonant frequency due to kinetic inductance) that won't come out unless you heat the entire system above T_c, and in that case we'd have to start from scratch. – user129412 Dec 29 '17 at 14:41
• Then your proposed solution is probably the best one. Start from your first maximum in both $\theta$ and $\phi$, change one of them by e.g. $\Delta\theta$ and change $\phi$ to find the maximum again. You can then repeat this until the new vector is (almost) perpendicular to the first one, this should result in the best condition for the second sweep. – Jasper Jan 5 '18 at 11:50

The line that you're searching is perpendicular to the vector $\vec v$. If $\pi$ is a plane normal to $\vec v$, this line, say $R$ is inside $\pi$. You know that this line is in another plane. So the straight line that you are searching is the intersection of this two planes.

The vectors in the plane normal to $\vec v$ follow the equation:

$$\vec x \cdot \vec v = 0$$

The vectors in the other plane follow the equation:

$$\vec x \cdot \vec n = 0$$

We can find the direction of the straight line performing the cross product of the two vectors:

$$\vec d = \vec { n } \times \vec { v }$$

Using a point $\vec a$ that lies in the two planes, the equation of your line is:

$$\bbox[5px,border:2px solid red] { \vec x = \vec a + t \vec d }$$

• I'm afraid that is an artifact of the drawing, the line does not have to be perpendicular to v, and most likely it is not. So I don't think that'll work then. Unless of course it has to be perpendicular to v and I am not seeing it, I could be mistaken. But something like this might work; I can find two vectors $\vec{v}$ that are in the plane ($S_P$ is maximal in phi and theta) and take their normal, and use that together with a point in the plane to construct it. Then use two basis vectors of that plane to try and do the polar sweep. – user129412 Dec 29 '17 at 14:45

Consider the following picture:

Green is an arbitrary plane through the origin (corresponding to the plane in the picture of the question), red the xz plane and blue the xy plane. Angles are also taken from there.

If you set $\phi=0$ and sweep $\theta$ clockwise, you'll get a maximum of $S_p$ if you reach the black arrow.

Likewise, for $\theta=90^\circ$, $S_p$ will be maximal if $\phi$ describes the yellow arrow.

Both arrows define the plane (except for corner cases when the green plane is one of the coordinate planes).

Why do you think this doesn't work?

• I see what you mean, it is a good idea. But say that the green plane is almost parallel to the z-axis in the picture. Setting theta to 90 will then lead to a large out-of-plane field, which causes problems by creating vortices I can no longer get out. So I can't go there in one step, I need a way to get from the black arrow to the yellow arrow, without getting too far out of plane. I'd need to somehow walk through phi, theta space, with that goal in mind. So that moves the question of finding the basis (which your vectors form) to how to map out that basis without going too far out of plane. – user129412 Dec 29 '17 at 15:55