Christian75
Member
Hi,
When I use this code in BANano:
That will be converted to:
It should be:
Please look at where the parentheses is located in the generated code. Math.atan2 only includes the (y2-y1) and not the (x2-x1)!
So in this case if (y2-y1) is zero then the Angel will be equal to (x2-x1) which is not correct. The angel in this case should be 0.
Edit:
ATan2 is also converted wrong!
Best regards
Christian
When I use this code in BANano:
B4X:
Angle = ATan2D((y2 - y1), (x2 - x1))
That will be converted to:
JavaScript:
__1fb=(Math.atan2((_y2-_y1)*(180/Math.PI)),(_x2-_x1))
It should be:
JavaScript:
__1fb=(Math.atan2((_y2-_y1),(_x2-_x1))*(180/Math.PI))
Please look at where the parentheses is located in the generated code. Math.atan2 only includes the (y2-y1) and not the (x2-x1)!
So in this case if (y2-y1) is zero then the Angel will be equal to (x2-x1) which is not correct. The angel in this case should be 0.
Edit:
ATan2 is also converted wrong!
JavaScript:
__1fb=(Math.atan2((_y2-_y1)),(_x2-_x1))
Best regards
Christian
Last edited: