[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/diy/ - Do It Yourself

Search:


View post   

>> No.1842728 [View]
File: 18 KB, 512x288, uc.png [View same] [iqdb] [saucenao] [google]
1842728

>>1842712
Map your input data to pic related, then average x and y separately.
>but how do I map
1 bit of data gets an angle of 2pi/2^14 radians
so your input angle is
theta = <compass value>*2pi/2^14
which gives you
x = cos(theta)
y = sin(theta)
You then average x and y. Since there are no discontinuities (values from -1 to 1) you won't have same problem you have now. Then you get the angle of averaged values
theta_avg = arctan(y/x)
where you need to be careful to add 180° if x < 0 and 360° if y < 0. After you get your angle back you reverse first equation to get averaged compass value
<compass value> = theta_avg*2^14/(2pi)
but since you want your heading in degrees you'll probably omit this last step.

Navigation
View posts[+24][+48][+96]