I need to calculate the lower angle.
The lower line the example is 8 and the line up 5 with a 90 degrees angle up.
Pythagoras should be: 5/8 = 0.625 and then Tan-1 and you should end up with 32 degrees.
I created a sample to test it with the part below and it response 0.7214844
Even hardcoded 5/8 or 0.625 in the final part gives the same result.
My idea is that something goes wrong with tan as I should use Tan-1 on a calculator but how to do that in Xojo?
I searched the manual and Google’d around but I can’t find it.
Dim c, t, x, y as Integer
Dim x1, y1 as String
Dim d as Double
//Const PI=3.14159265358979323846264338327950
//Read the input from the form
x1 = Label_x2.Text
y1 = Label_y2.Text
//Convert to integer for calculation
x = val(x1)
y = val(y1)
//Tangus
t = y/x
//d = Tan(t*180/PI)
//d = Tan(t)
d = Tan(5/8)
//Output to Gui
Label_Angle.Text = Str(d)
Tan^-1on a calculator is ATAN in Xojo.
And the result of Atan (and all the trig functions) is in radians, so multiply by 180/pi for degrees.
I use this in my little trig program I am developing
ATan(opp/adj) * 180/Pi
Which converts to …
ATan(5/8) * 180/Pi
= 32.005 deg
Thanks guys, it works now!
With all three answers I got it working.
Jason pointed me to the right Function, Will completed it with the PI part and Neil gave a snippet.
The power of a good community forum.
I also needed to change the result “t” into a Double instead of a Integer.
At the end, I floor the result to two decimal places, that works for me.
Dim c, x, y as Integer
Dim x1, y1 as String
Dim d, e, t as Double
Const PI=3.14159265358979323846264338327950
//Read the input from the form
x1 = Label_x2.Text
y1 = Label_y2.Text
//Convert to integer for calculation
x = val(x1)
y = val(y1)
//Tangus
t = y/x
d = ATan(t) * 180/Pi
//Round to two decimal places
e = Floor(d*100)/100
//Output to Gui
Label_Angle.Text = Str(e)