I am starting to try make a basic game (shooting cannons at each other) but want to figure out how to calculate the angle (e.g. 33%) between to two drawlines, that originate from the same point. e.g:

Canvas1.DrawLine(10dip, 200dip, 310dip, 200dip, Colors.Red, 1dip)

Canvas1.DrawLine(10dip, 200dip, 340dip, 100dip, Colors.Red, 1dip)

There are quite a few VB samples out there, e.g:

Public Function GetAngle(ByVal Ax As Single, ByVal Ay As _

Single, ByVal Bx As Single, ByVal By As Single, ByVal _

Cx As Single, ByVal Cy As Single) As Single

Dim side_a As Single

Dim side_b As Single

Dim side_c As Single

' Get the lengths of the triangle's sides.

side_a = Sqr((Bx - Cx) ^ 2 + (By - Cy) ^ 2)

side_b = Sqr((Ax - Cx) ^ 2 + (Ay - Cy) ^ 2)

side_c = Sqr((Ax - Bx) ^ 2 + (Ay - By) ^ 2)

' Calculate angle B between sides ab and bc.

GetAngle = Acos((side_b ^ 2 - side_a ^ 2 - side_c ^ 2) _

/ (-2 * side_a * side_c))

End Function

' Return the arccosine of X.

Function Acos(ByVal X As Single) As Single

Acos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

End Function

I tried to convert to Basic4Android but not having much luck sofar, e.g:

Sub GetAngle(Ax As Double, Ay As Double, Bx As Double, By As Double, Cx As Double, Cy As Double) As Double

Dim side_a As Double

Dim side_b As Double

Dim side_c As Double

' Get the lengths of the triangle's sides.

side_a = Sqrt((Bx - Cx) * 2 + (By - Cy) * 2)

side_b = Sqrt((Ax - Cx) * 2 + (Ay - Cy) * 2)

side_c = Sqrt((Ax - Bx) * 2 + (Ay - By) * 2)

' Calculate angle B between sides ab and bc.

'^

GetAngle = ACos((side_b * 2 - side_a * 2 - side_c * 2) / (-2 * side_a * side_c))

End Sub

' Return the arccosine of X.

Sub ACos(X As Double) As Double

ACos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

End Sub

I see this post: http://www.basic4ppc.com/forum/basic4android-updates-questions/8547-trigonometric-circle.html

I am rubbish at maths, I wondered if anyone would be able to help me out to see if this is possible, how should the data types be converted from the VB sample? or can the demo that Klaus/Erel wrote in http://www.basic4ppc.com/forum/basic4android-updates-questions/8547-trigonometric-circle.html be used?

Thanks for any help with this