# tan^-1

#### dennishea

##### Active Member
a = Tan-1 * (y/x)

The above formula is for finding an angle when converting from rectangular to polar. I'm not sure how to get the tan-1 right. Have tried some different configurations but no luck. I've used this before with a scientific calculator and it worked great. Has anyone used this with basic4ppc? Any help would be appreciated.

#### Erel

Staff member
You should use ATan:
Msgbox(ATan(1) * 180 / cpi) 'Displays 45.

#### dennishea

##### Active Member
Thanks Erel. That's what I needed. Agian Thanks.

p.s. I realize that us non programmers abuse the use of variables, arrays, and what not but with your great job in designing basic4ppc and the use of yours, agraham, dzt and others dll's, it makes basic4ppc a very powerful and easy to use programing language. Not counting this very informative and friendly forum. I hope you have a very merry Chistmas.

:sign0188: :sign0188:

#### Erel

Staff member
Thank you and merry Christmas too

#### dennishea

##### Active Member
Rec to Pol

Hi all.

This program gives me x & y for polar to rectangular and gives me radius but not angle from rectangular to polar. Does anybody see what I'm doing wrong.

PHP:
``````Sub Globals
'Declare the global variables here.
End Sub

Sub App_Start
Form1.Show
End Sub

Sub btnRecPor_Click
radius = Sqrt((txtx.Text^2) + (txty.Text^2))
angle = ATan(txty.Text/txtx.Text * RadDeg)
txtanswer.Text = "Radius " & Format(radius,"n2") & " --  " & "Angle " & Format(angle,"n5")
End Sub

Sub btnPolRec_Click
x = txtx.Text * Cos(txty.Text * degrad)
y = txtx.Text * Sin(txty.Text * degrad)
txtanswer.Text = "x " & Format(x,"n2") & " ------  " & "y " & Format(y,"n2")

End Sub

Sub btnClear_Click
txtx.Text = ""
txty.Text = ""
End Sub``````

Thanks in advance for any help.

Denny