It does'nt work.Take away the space between - and Xc
This works: Xc = - 1 * Xc
It does'nt work.Take away the space between - and Xc
All I'm saying is that in the math logic, you must test for Y>0 first, before testing if X/Y <1.Hi S,
Regarding Y=0: So far I'm looking at the first OCTANT of the circle, so it's possible that in other OCTANTS there may be 'If y = 0 then'
I'm using Oshonsoft BASIC, and there is a SYNTAX '>=' What I'm following here, I think is written in C+?, and I'm not sure if '> 0' may also mean '>='. Perhaps you know?
At the moment, I'm not concerned with magnetic/true, I'll look farther into this later. I think the deviation here is <1 Deg.
C.
Hi S,All I'm saying is that in the math logic, you must test for Y>0 first, before testing if X/Y <1.
The example you show from C+ is a compound "if", testing all 3 conditions in one statement, which Oshonsoft cannot do. With Oshonsoft you have to do each test individually, as you show in your code, but your math logic should test for Y>0 first before the rest of it....
Hi J,Negate: Xc = - Xc
If changed to 14bit, maybe the 2's complement has to be changed too?
The variation is smaller now.
Can you rotate the full circle.
Hi J,The first picture says AK8963C 14 pin package
The second picture, data can be in 14bit or 16bit format.
Yes, that is the correct logic to prevent dividing by zero accidentally.Hi S,
Like this?:
If y_c > 0 Then
If x_c > 0 Then
If x_c / y_c < 1 Then
deg = Arctan(x_c / y_c) * 57.3
Endif
Endif
Endif
C.
Hi J,Haven't looked all the octants, but you can't directly compare x and y if they have different signs, should then compare their absolute values.
Simpler way for if x/y < 1 is if x<y
You have 4 cases for the signs of x, y:
++ 0-90 degrees
+- 90-180
-- 180-270
-+ 270-360
Value of b is in the message.Hi J,
This appears to be getting more complicated!
Can Oshonsoft deal with 'atan_approx' ? What is second order? where did 'b' come from?
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Here is a Honeywell equation:
To account for the tangent function being valid over 180° and not allowing the y=0 division calculation, the following equations can be used:
Azimuth (x=0, y<0) = 90.0
Azimuth (x=0, y>0) = 270.0
Azimuth (x<0) = 180 - [arcTan(y/x)]*180/¹
Azimuth (x>0, y<0) = - [arcTan(y/x)]*180/¹
Azimuth (x>0, y>0) = 360 - [arcTan(y/x)]*180/¹
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Am I correct that the choice of Octant or Quadrant is for accuracy? And whichever you use there is some error. There are ways of making them more accurate, but this is more complicated to do?
C.