Determining points on a circle in a particular plane

202 Views Asked by At

This is more of a computer graphics question really, but I was just wondering the efficient way to determine n equally spaced points on a circle, given a normal vector to the circle and the radius of a circle. Of course, one could always set $x = \cos(\frac{2\pi}{n}), ~y = \sin(\frac{2\pi}{n}), ~z = 0$, scale by the radius, and then rotate that vector so it lies in the desired plane, but I am wondering if there's a better way.

2

There are 2 best solutions below

1
On BEST ANSWER

Not sure if it's a "better way", but you could do this. If the centre of the circle is ${\bf c}$ and the normal vector is ${\bf a}$, find two unit vectors ${\bf u},{\bf v}$ which are perpendicular to ${\bf a}$ and to each other. Then your points could be $${\bf c}+(r\cos k\theta){\bf u}+(r\sin k\theta){\bf v}$$ where $r$ is the radius of the circle and $\theta=2\pi/n$ and $k=0,1,\ldots,n-1$.

0
On

Given: unit normal vector $\mathbf{\hat u} = (u_x, u_y, u_z)$ and desired radius $r$, pick an arbitrary starting point $\mathbf{r_0}$ on the circle. One way to do that is with

$$ \mathbf{r_0} = r \frac{\mathbf{\hat u} \times \mathbf{\hat z}}{\lVert \mathbf{\hat u} \times \mathbf{\hat{z}} \rVert}$$

(If it happens that $\mathbf{\hat u} = \pm \mathbf{\hat z}$, then the circle lies in the $xy$ plane, and the problem is trivial. In that case, just pick $\mathbf{r_0} = (r, 0, 0)$.)

Then, it's just a matter of rotating $\mathbf{r_0}$ to obtain the other points. Define a rotation matrix

$$ R = \left[ \begin{matrix} \cos \theta + u_x^2 (1 - \cos \theta) & u_x u_y (1 - \cos \theta) - u_z \sin \theta & u_x u_z (1 - \cos \theta) + u_y \sin \theta \\ u_y u_x (1 - \cos \theta) + u_z \sin \theta & \cos \theta + u_y^2 (1 - \cos \theta) & u_y u_z (1 - \cos \theta) - u_x \sin \theta \\ u_z u_x (1 - \cos \theta) - u_y \sin \theta & u_z u_y (1 - \cos \theta) + u_x \sin \theta & \cos \theta + u_z^2 (1 - \cos \theta) \end{matrix} \right] $$

where $\theta = \dfrac{2 \pi}{n}$.

Then, your points on the circle are $\mathbf{r_i} = R^i \mathbf{r_0}$, for $i = 0, 1, 2, \ldots, n - 1$.

An advantage of this method is that there are few trigonometric operations: you only need to compute $\cos \theta$ and $\sin \theta$ once. $R$ depends only on $n$ and $\mathbf{u}$. Thereafter, it's all matrix multiplication.