Skip to content

360 on north direction instead of West#3

Open
vishal-adhikari wants to merge 1 commit intodalmirdasilva:masterfrom
vishal-adhikari:patch-1
Open

360 on north direction instead of West#3
vishal-adhikari wants to merge 1 commit intodalmirdasilva:masterfrom
vishal-adhikari:patch-1

Conversation

@vishal-adhikari
Copy link

No description provided.

magYMin = y;
}
heading = computeVectorAngle(y - ((magYMax + magYMin) / 2), x - ((magXMax + magXMin) / 2));
heading = -atan2(y - ((magYMax + magYMin) / 2), x - ((magXMax + magXMin) / 2)) * 180.0 / M_PI;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for the contribution.

I believe this code is covered here: https://github.com/dalmirdasilva/ArduinoMagnetometer/blob/master/Magnetometer/Magnetometer.cpp

Is there anything different on they way you are calculating from the dependency above?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dalmirdasilva I am not an expert here, but I guess issue is in passing the value. You are passing computeVectorAngle(y, x) and in below function its reversed. [computeVectorAngle(x, y)] x & y are getting interchanged and GPS location is showing 360 on west instead of north.

double Magnetometer::computeVectorAngle(int16_t x, int16_t y) {
double degrees = radiansToDegrees(-atan2(y, x));
if (degrees < 0) {
degrees += 360.0;
}
if (degrees > 360.0) {
degrees -= 360.0;
}
return degrees;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants