1

Is there any way I can get the points in 2D plane on the sides of an equilateral triangle for certain infinite animation sequence?

For example in case of tracing the circumference of the circle, I have the polar coordinates for $x$ and $y$ as $$x=radius\times cosine(\theta)$$ $$y=radius\times sine(\theta)$$

I'm unable to figure how to take care of the discontinuity at the 3 vertexes

Siddharth Thevaril
  • 875
  • 4
  • 15
  • 27

1 Answers1

4

I found this answer to be useful: Is there an equation to describe regular polygons?

You can use absolute values or modular arithmetic to take care of the discontinuities. Here's one possible formula, which will trace out an equilateral triangle centered on the origin:

Let $k \equiv \frac{2\pi}{3}$. (In general, we divide $2\pi$ by the number of sides of the polygon we want to draw).

$$\begin{align*} r(\theta) = \frac{\cos{\left(\frac{k}{2}\right)}}{\cos{\left(-\frac{k}{2} + \;\theta \,\text{mod}\; k\right)}} \end{align*}$$

And you can plot this for every value of $\theta$ between 0 and $2\pi$.

If you want a larger triangle, multiply $r(\theta)$ by a suitable number. And if you want to rotate the triangle, replace $\theta$ with $\theta+d$ for some rotation amount $d$.

Finally, if you want to have a formula in rectangular coordinates, you can use the polar-to-rectangular transformation:

$$\begin{align*}x(\theta) &= r(\theta)\times \cos{\theta}\\y(\theta)&=r(\theta)\times \sin{\theta} .\end{align*}$$

I hope that helps!

user326210
  • 17,287