How can I draw periodic shapes along horizontal axis?

67 Views Asked by At

I have Approximating Pi shape that simply I want to repeat It periodically along horizontal axis like, below image:

image

then I want to cut negative parts of the vertical axis:

image

1

There are 1 best solutions below

3
On

Your figure is a regular $2n$-gon with $n=4$.

Following the usual orientation, we start with the point $(1,0)$, then we have $n-1$ points on the upper half plane and then the point $(-1,0)$. For each $k\in\{0,1,\dots,n\}$ let

$$z_k=\exp\left(\frac{k\pi}{n}\right)= \underbrace{\cos\left(\frac{k\pi}{n}\right)}_{x_k} +i\,\underbrace{\sin\left(\frac{k\pi}{n}\right)}_{y_k}$$

Hence, one period of your function $f$ lies in $[-1,1]$, and for each $k$ with $1\leq k \leq n$ and each $x\in[x_{k},x_{k-1}]$ there is a unique $t_x$ such that $x=t_x\,x_k+(1-t_x)\,x_{k-1}$. Indeed, we have

$$t_x = \frac{x_{k-1}-x}{x_{k-1}-x_k}$$

Then, for each such $x$ we have that

$$f(x)= t_x\, y_k + (1-t_x)\,y_{k-1} $$

Finally, $f$ can be extended periodically for all $x\in \mathbb R\setminus[-1,1]$ via $f(x+1)=f(x)$.