Picking a random point from a circle in 3D

212 Views Asked by At

I have a circle that is given by $ \begin{cases} (x-3)^2 + (y-4)^2 + z^2 = 36\\ 4x + y - z - 9 = 0 \end{cases} $ , and i need to take a point that belongs to this circle. Is there an easier way in general to find a point without randomly try to pick $x,y$ and $z$ until somehow they fit the equation?

5

There are 5 best solutions below

0
On BEST ANSWER

Personally, I use wolframalpha.com for equations like this. Actually, a better equation to input is this.

What you're looking for is something like $f(x)=y$ and $f(x,y)=z$.

Here's how I approach this specific system of equations:

  1. Because the 3 squared terms always add up to 36, each term actually can be anywhere from 0 to 6. You can visualize this; it's every point on the surface of a sphere.

This means that z can be any value from -6 to 6, y any value from -2 to 10, and x any value from -3 to 9. This is called the "domain" of the surface.

  1. The two equations can be combined to see the shadow of the circle on the x and y coordinate grid:

$(x-3)^2 + (y-4)^2 + (4x + y - 9)^2 = 36$

another way to write this is:

$17 x^2 + x (8 y - 78) + 2 y^2 - 26 y = -70$

I can also solve for y, so that I have y=f(x):

$y = f(x) = 0.5(-sqrt(-18x^2 + 52x + 29) - 4x + 13)$

I can also solve the first equation for z, so that I have z=f(x,y):

$z = sqrt(-1((x-3)^2 + (y-4)^2 - 36))$

All I did was I took the second equation, solved for z, and substituted back into the first equation. Then I simplified, then I solved for y.

It's also important to realize that I could have solved your second equation for x or y as well, and then substituted that back into the first equation. I just picked z because it had no coefficients so it was easier to solve for.

  1. Now that we have an equation with 2 variables, x and y, we can pick an x within the domain and solve for a y. The domain of the 3D circle is different from the domain of the sphere, because it's on a slant. We can find the domain for x by looking at the y=f(x) equation from (2):

Find the roots of $-18x^2 + 52x + 29$:

$x = 1/18 (26 (+/-) sqrt(1198))$

This means x can be anywhere between $(26 - sqrt(1198))/18$ and $(26 + sqrt(1198))/18$.

To find a value to pick, I'll just use $x = (26 + 10)/18 = 36/18 = 2$.

  • $x=2$
  • $y = (5/2) -(sqrt(61)/2)$
  • $z = sqrt(-(x-6)x - (y-8)y + 11)$

In summary, what I did was:

  1. Use algebra to reduce the number of variables in an equation I'm working with
  2. Solve equations for y=f(x) and z=f(x,y)
  3. Find the domain of x, and pick an x in that domain
  4. Plug x in y=f(x), solve for y, then plug y in z=f(x,y) and solve for z.
0
On

There are many ways to do that, but I think fundamentally they are doing the same thing. One way to do it: you can do a rotation, translation, scaling so that the plane becomes e.g. the $x$-$y$ plane, and the sphere becomes the unit sphere. Then sample a point in the 2-d unit circle (in your example, the circle could be $\{(x, y, z): z = 0,\,x^2 + y^2 = 1\}$) by e.g. sample an angle. After you get a sample, to the reverse rotation, translation, scaling to get a sample from the original circle.

4
On

You can use the standard $r, \phi, \theta$ transformation, and you'll have a "cube", where all values within it are within your sphere. This way you choose $x,y,z$ in your ranges.

0
On

Essentially you still need to solve the system of equations to find the two variables in terms of the other variable.

From the second equation we have $z=4x+y-9$ and substituting into the first gives

$$(x-3)^2+(y-4)^2+(4x+y-9)^2=36$$ $$\implies 2y^2+(8x-26)y+17x^2-78x+70=0.$$

Then fixing $x=c$ we obtain a quadratic for $y$, and applying the quadratic formula we have

$$y=\frac{1}{2}\left(\pm\sqrt{-18c^2+52c+29}-4c+13\right)$$

and substituting in $z$ gives $$z = \frac{1}{2}\left(\pm\sqrt{-18c^2+52c+29}+4c-5\right)$$

Note that $-18c^2+52c+29\geq0\iff\frac{1}{18}(26-\sqrt{1198}) (\approx -0.478)\leq c\leq \frac{1}{18}(26+\sqrt{1198})( \approx 3.367),$ which is the range of values of $x$ for which you have real solutions.

Thus choosing any $x=c$ for $c$ in the given range above, you can obtain $y$ and $z$ by substituting.

0
On

We know that $n={(4,1,-1)\over3\sqrt{2}}$ is the unit vector normal to the plane. We can choose two perpendicular unit vectors parallel to the plane as follows: $$ u={(-1,4,0)\over\sqrt{17}},\quad v=n\times u={(-4,1,17)\over3\sqrt{34}}. $$ The center $C$ of the circle is that point on the plane which is nearest to the center $(3,4,0)$ of the sphere: $$ C=\left({13\over9},{65\over18},{7\over18}\right). $$ Pythagoras' theorem gives then the radius of the circle: $$ r=\sqrt{599\over18}. $$

It follows that a generic point on the circle can be parameterised as: $$ P=C+ru\cos t+rv\sin t,\quad t\in[0,2\pi). $$

For a uniform distribution, just pick $t$ uniformly at random and substitute into the above formula.