I'm trying to solve a geometry problem that involves the intersection of two arbitrary spheres in 3D space. The intersection between the two spheres will be a circle in 3d space. I know that this circle will be contained in a plane with normal vector $\vec{a}$, defined as the vector pointing from the center of one sphere to the center of the other, and a point $M$, which is the centre of the circle of intersection, and will be some distance $d$ along $\vec{a}$ (this isn't the meat of the problem, I'm just giving some background). Finally, I find an orthonormal basis for my plane made up of vectors $\hat{u}$ and $\hat{v}%$ ($\hat{u}$ and $\hat{v}%$ have magnitude 1, and are both orthogonal to each other, and $\vec{a}$).
The circle of intersection can then be defined as the following:
$$C(x,y,z) = M + h*cos(t)*\hat{u} + h*sin(t)*\hat{v} $$
where $0 \leq t \leq 2\pi $
So now I have a parameterization of my circle, parameterized to some angle t, and this is where my question really starts. For my problem, I need to find certain points on $C(x,y,z)$ that obey a constraint in either x or y. For example, I may want to find all points in $C(x,y,z)$ such that $x = 5$, or such that $x$ is equal to some arbitrary number $b$. To do this, I look at only one variable in the above equation:
$$C(x) = b = M_x + h*cos(t)*\hat{u_x} + h*sin(t)*\hat{v_x}$$
where $M_X, \hat{u_x}, \hat{v_x}$ are the x components only. I rearrange the equation to look like:
$$\frac{b - M_x}{h} =cos(t)*\hat{u_x} + *sin(t)*\hat{v_x}$$
and then, for simplicity, let $k = \frac{b - M_x}{h}$:
$$k =cos(t)*\hat{u_x} + *sin(t)*\hat{v_x}$$
To solve this equation, I've been using the method described in this post, and it's been yielding correct solutions. The problem is that if I use the method described in that post, it will only give me one solution, when usually there will be two possible solutions for $t$ that satisfy my equation. What modifications can I make to my method such that I find all possible values for t, instead of just one? I have a matlab script running that does this calculation for me, which I can post if that would be helpful. I'd prefer not to use numerical methods in my code, as I'm sure this has an analytical solution.
The method will give you both solutions. You've just been ignoring the other one. Let's look at it.
First we calculate $r = \sqrt{(\hat u_x)^2 + (\hat v_x)^2}$. Then we find $\phi$ so that $\cos \phi = \frac{\hat u_x}r$ and $\sin \phi = \frac{\hat v_x}r$
Then we can divide through by $r$ and rewrite the equation as $$\frac{b-M_x}{rh} = k = \cos t \cos \phi + \sin t \sin \phi = \cos(t - \phi)$$
where I have replaced your $k$ with one divided by $r$. Let $\theta = t - \phi$. Then the equation is $$k = \cos\theta$$
But recall the shape of the cosine curve. In $[0,2\pi)$ it drops from $1$ at $\theta = 0$ down to $-1$ at $\theta = \pi$, then rises back up to $1$ at $\theta = 2\pi$. With the exception of $-1$ at the bottom of the trough and $1$ at the top, the curve passes through every $y$-value twice! ($2\pi$ doesn't count as a second $1$ because it is actually in the next period.) So unless your $k$ is $1$ or $-1$, there are two values in $[0,2\pi)$ that provide it. By the symmetry of the cosine, $$\cos \theta = \cos (2\pi - \theta)$$
So once you find one solution, subtract it from $2\pi$ to get the other:
Suppose $k = \frac 12$, then $\theta = \arccos \frac12 = \frac \pi 3$. The other solution is then $2\pi - \frac \pi 3 = \frac{5\pi}3$.
Then just add $\phi$ to both solutions to get the values of $t$ you need.