A problem with sound positioning

Hi guys,
I get a division by zero error, when I try to use the below sound positioning code. The division by zero error only occurs, or seems to anyway, when my x is the same as the sound source's x. Here is the function
def position_sound(handle, x, y, z, listener_x, listener_y, listener_z, theta):
    theta+=90
    if theta<0:
        theta=360+theta
    temp1=x -listener_x
    temp2=listener_y -y
    if temp1==0 and temp2==0:
        absolutetheta=-1
    if temp2>0:
        absolutetheta=math.atan(temp1/temp2)
    if temp2<=0:
        absolutetheta=math.atan(temp1/temp2)+3.14
    absolutetheta=(absolutetheta*(180/3.14))
    relativetheta=absolutetheta-theta
    tempf=math.cos(relativetheta*3.14/180)*-100
    z=listener_z -z
    tempv=math.sin(relativetheta*3.14/180)*-100
    handle.position=(tempf, z, tempv)

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector

Reply via email to