# How to decompose a 2d shape into sin and cosin modes?

Assume that you have a circle with radius $r_0$, then you keep adding cosine modes as below:

$r=r_0+a_1\cos(1\theta)+a_2\cos(2\theta)+a_3\cos(3\theta)+a_4\cos(4\theta)+~...$

if you plot this as below by matlab:

r0=1;
a1=0.2;
a2=0.2;
a3=0.2;
a4=0.2;
th=0:0.01:2*pi;
r=r0+a1cos(th)+a2cos(2*th)+a3cos(3*th)+a4cos(4*th);
x=r*cos(th);
y=r*sin(th);
plot(x,y);


You will see that you can get different shapes by changing the number of modes (i.e. here n=4) or coefficients (i.e. $a_i$) and even omitting some modes (i.e. $a_k=0$) you will get different shapes.

My question is that how can you decompose for instance an oval or a square in cosine modes, and find their coefficients (somehow in the way of fourier decomposition), is it ever possible?

But I think making any shape would be possible by my method mentioned above, but I am interested to know how I can come from an arbitrary shape to its corresponding cosine modes.

• I don't have an answer for you, but this is a really interesting question. I'm experimenting and doing research with it right now. I can tell you that some shapes are impossible. (I won't explain why right now). I'll get back to you. – Polygon Jun 4 '16 at 2:45
• @Polygon yes it is a good question, but could you give a simple example at least or a hint that help me in my thinking on it. – Soyol Jun 4 '16 at 3:01
• @soeil I don't have any examples or hints. It's pretty complicated. I don't even know if it's possible to make squares or ellipses, but I'm working on it. – Polygon Jun 4 '16 at 3:22
• @soeil I've been working on this, and I hate to say it, but I'm pretty sure a square is impossible. I'll keep trying different things and keep you updated. – Polygon Jun 5 '16 at 2:18
• The title also mentions sin modes, the text does not. Do you want to include these? Essentially you have a periodic function $r(\theta)$. I'd say that writing this as a linear combination $\sum_ka_k\sin(k\theta)+b_k\cos(k\theta)$ is not just “somehow in the way of fourier decomposition” but in fact is Fourier decomposition. Did I miss some relevant difference here? If $r(\theta)$ is not a function but a relation (i.e. if you have more than two points on the shape for every line through the origin), then you can't get the shape via this method. – MvG Jun 6 '16 at 11:29