Kyma Forum
  Tips & Techniques
  converting from polar to cartesian

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   converting from polar to cartesian
johannes
Member
posted 05 May 2014 09:05         Edit/Delete Message   Reply w/Quote

cart2pol2cart.kym

 
hello,

based on ssc´s cartesian to polar patch i just try to convert from polar back to cartesian coordinates using the formulae:
x = mag * cos(phi)
y = mag * sin(phi)
but it doesnt seem to work. the x and y values before and after the convertion (cart to pol to cart) doesn´t match.
did i miss something?

i also wonder how to calculate that (e.g. cos or sin of an angle) in the freq. domain.
this has to be done at samplerate so i cant use capytalk for that, right?

thanks, johannes

[This message has been edited by johannes (edited 05 May 2014).]

IP: Logged

SSC
Administrator
posted 05 May 2014 14:06         Edit/Delete Message   Reply w/Quote
There are a few things to change to make this work correctly:

* In the reconvert Sounds, change cos to normCos and sin to normSin

* In the Angle SoundToGlobalController, get rid of "1 -" and keep just the pasted in ArcTan Sound.

The ArcTan Sound outputs a "normalized" angle in the range of -1 to +1:

arcTan ( right / left ) / π

so, if you want to convert the "normalized" angle back to X and Y coordinates, you would need to use:

cos ( π * angle ) and sin ( π * angle )

which is exactly what the Capytalk normCos and normSin do.

IP: Logged

johannes
Member
posted 05 May 2014 15:02         Edit/Delete Message   Reply w/Quote
thanks for the fast reply. it works perfectly.

what exactly does "n" in your two equations stands for?
and how can i calculate the latter equation in the the frequency domain at samplerate?


IP: Logged

SSC
Administrator
posted 05 May 2014 18:32         Edit/Delete Message   Reply w/Quote
π = pi

The font makes it look like the letter "n"

To take the sine and cosine at the sample rate, you can use a Waveshaper whose shapingFunction is either the Sine or the Cosine wavetable.

[This message has been edited by SSC (edited 05 May 2014).]

IP: Logged

johannes
Member
posted 06 May 2014 03:00         Edit/Delete Message   Reply w/Quote

cart2pol2cart_v2.kym

 
ah, i see.

but it seems to that the sine calculated by the waveshaper is 180 degree out of phase to the sine calculated by capytalk, while this doesnt seem to occur for cos. to correct the phase i now multiply the sine function by -1 ...

after some experimentation i also realized some range-limitation of the reconverted x and y values. when setting x and y to 1 or -1 the reconverted x and y will be 0.7 or -0.7 (instead of 1 and -1)

i append two sounds for demonstration…

any help is welcome. ciao, j

[This message has been edited by johannes (edited 06 May 2014).]

IP: Logged

johannes
Member
posted 06 May 2014 15:48         Edit/Delete Message   Reply w/Quote

cart2pol2cart_v3.kym

 
thanks, i figured it out.

IP: Logged

SSC
Administrator
posted 07 May 2014 08:33         Edit/Delete Message   Reply w/Quote
Just so everyone else understands it too... in the Waveshaper an index of 0 maps to the center of the shaping function. So an input of 0 was giving you the center of the Sine table, rather than the start of the table.

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c