Stuck with the calculation of Solution 2 Compass #383
Replies: 2 comments
-
The compass tells us the strength of the magnetic field in an Then once we have the angle (in units of radians, so instead of 0-360° it goes from -pi up to +pi), we use this if/else if/else code to turn the angle into a direction. The Something like this diagram from Wikipedia, but label the (1, 0) point as South and the (-1, 0) point as North: Does that help? |
Beta Was this translation helpful? Give feedback.
-
@adamgreig This was really helpful and after this, I did some research also and found out that PI/8 contains the angle from |
Beta Was this translation helpful? Give feedback.
-
Hi Everyone, I am working on the stm32-discovery board for the last 4 months and successfully completed 13 chapters from the book. Currently, I am working on the chapter LED compass and I have passed Take 1 of the chapter using lsm303agr instead of lsm303dlhc.
Now I am working with Take 2 and got to know that we are going to find out the precise angle of magnetic field using atan2 function but I am really not getting the calculation which we are using inside the if-else block.
`let theta = (y as f32).atan2(x as f32); // in radians
Can someone please help me with this. Thanks
Beta Was this translation helpful? Give feedback.
All reactions