This post was updated on .
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: r=x2+y2‾‾‾‾‾‾‾√r=x2+y2 θ=arctan(xy) for 0<θ<90∘ ... i.e. both x & y positive θ=180∘+arctan(xy) for 90∘<θ<270∘ ... i.e. y negative θ=360∘+arctan(xy) for 270∘<θ<360∘ ... i.e. x negative, y positive 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). My current code can be found in the next post. Would anyone care to offer some advice, please and thank you? 

Hi, Martin! 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 topmost corner? or is it placed in the middle of XYpad If it's in the middle you have to do: kx1 = kx  kcenterX ky1 = ky  kcenterY Hope this helps! Anton 20170227 17:40 GMT+03:00 Nitram <[hidden email]>: <http://csound.1045644.n5. 
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 0360 degrees, as shown in the image in my first post. You mentioned something about "180 to 180". Thanks! 
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: not kx, ky Also my guess is that taninv2 expects the Oy axis to point to up but in UI widgets like XYpad 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 20170227 20:54 GMT+03:00 Nitram <[hidden email]>: Thanks for replying, Anton. 
Free forum by Nabble  Edit this page 