Csound Csound-dev Csound-tekno Search About

Implementing XY instead of Polar Coordinates for Vbap Query.

Date2017-02-27 14:33
FromNitram
SubjectImplementing XY instead of Polar Coordinates for Vbap Query.
Hi folks.

I'm trying to use an XYpad as a crude control to position sound within a 2d
space using and 8 channel Vbap setup. As Vbap works in angles ranging from 0
to 360 degrees (as in below image) in a scenario that does not correspond at
all to the way trigonometric angles are usually set up, I'm having lots of
trouble working this out.
 

As this is a math issue, I posted the query in a maths forum and these are
the instructions I got back:
 

I'm currently trying to implement these equations, but the results do not
correspond to what they should be (Also I get crashes if the XY coordinates
are at 0).

Here is my current code. Would anyone care to offer some advice, please and
thank you?
 







--
View this message in context: http://csound.1045644.n5.nabble.com/Implementing-XY-instead-of-Polar-Coordinates-for-Vbap-Query-tp5754854.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-02-27 14:40
FromNitram
SubjectRe: Implementing XY instead of Polar Coordinates for Vbap Query.
 



--
View this message in context: http://csound.1045644.n5.nabble.com/Implementing-XY-instead-of-Polar-Coordinates-for-Vbap-Query-tp5754854p5754855.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-02-27 16:09
FromAnton Kholomiov
SubjectRe: Implementing XY instead of Polar Coordinates for Vbap Query.
Hi, Martin!

My guess that the problem is with

taninv(kX / kY)

If kY is zero you should get divizion by zero error. 
This is very common case to get the polar coordinates.
It's so common that there is a special function that doesn't brakes on zero input taninv2:


Also note that taninv output is in radians not in degrees! 
So to get degrees you need to rescale it

taninv or taninv2 output lies in -pi/2 to pi/2 and if you want it to be -180 to 180
you need to do

ksig * 180 / (pi * 0.5)

also do you have a center in the left top-most corner? or is it placed in the middle of XY-pad
If it's in the middle you have to do:

kx1 = kx - kcenterX
ky1 = ky - kcenterY


Hope this helps!
Anton






2017-02-27 17:40 GMT+03:00 Nitram <martcrowl@gmail.com>:
<http://csound.1045644.n5.nabble.com/file/n5754855/Code.png>



--
View this message in context: http://csound.1045644.n5.nabble.com/Implementing-XY-instead-of-Polar-Coordinates-for-Vbap-Query-tp5754854p5754855.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2017-02-27 17:54
FromNitram
SubjectRe: Implementing XY instead of Polar Coordinates for Vbap Query.
Thanks for replying, Anton.

I'm trying to follow your instructions so I have input the data as follows.
 

The angles shown by the print are way off so clearly I'm doing something
wrong.

Also this circle goes from 0-360 degrees, as shown in the image in my first
post. You mentioned something about "-180 to 180".

Thanks!



--
View this message in context: http://csound.1045644.n5.nabble.com/Implementing-XY-instead-of-Polar-Coordinates-for-Vbap-Query-tp5754854p5754857.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-02-28 05:44
FromAnton Kholomiov
SubjectRe: Implementing XY instead of Polar Coordinates for Vbap Query.
I'm doing that kind of thing by trial and error myself. But the thing I see from the code

you reversed the arguments for taninv2. it should be:

taninv2 ky, kx

not kx, ky

Also my guess is that taninv2 expects the Oy axis to point to up but in UI widgets like XY-pad it's often points to down.
So maybe you need to reverse the Oy by negotiation

ky1 = - (ky - kCenterY)

And I think that you don't need to check whether kX or kY are positive or negative it should be built in the taninv2


2017-02-27 20:54 GMT+03:00 Nitram <martcrowl@gmail.com>:
Thanks for replying, Anton.

I'm trying to follow your instructions so I have input the data as follows.
<http://csound.1045644.n5.nabble.com/file/n5754857/Conundrum.png>

The angles shown by the print are way off so clearly I'm doing something
wrong.

Also this circle goes from 0-360 degrees, as shown in the image in my first
post. You mentioned something about "-180 to 180".

Thanks!



--
View this message in context: http://csound.1045644.n5.nabble.com/Implementing-XY-instead-of-Polar-Coordinates-for-Vbap-Query-tp5754854p5754857.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here