Merge pull request #90 from jwetzell/fix-draw-bearing

Fix draw bearing
This commit is contained in:
Erwin Ried 2020-07-02 06:40:43 +02:00 committed by GitHub
commit 6c71574d5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -169,8 +169,9 @@ void GeoMap::paint(Painter& painter) {
display.fill_rectangle({ r.center() - Point(16, 1), { 32, 2 } }, Color::red());
display.fill_rectangle({ r.center() - Point(1, 16), { 2, 32 } }, Color::red());
} else {
draw_bearing({ 120, 32 + 144 }, angle_, 10, Color::red());
painter.draw_string({ 120 - ((int)tag_.length() * 8 / 2), 32 + 144 - 32 }, style(), tag_);
draw_bearing(r.center(), angle_, 10, Color::red());
//center tag above bearing
painter.draw_string(r.center() - Point(((int)tag_.length() * 8 / 2), 2 * 16), style(), tag_);
}
}

View File

@ -91,7 +91,9 @@ Rect& Rect::operator-=(const Point& p) {
}
Point polar_to_point(float angle, uint32_t distance) {
return Point(sin_f32(DEG_TO_RAD(angle) + (pi / 2)) * distance, -sin_f32(DEG_TO_RAD(angle)) * distance);
//polar to compass with y negated for screen drawing
return Point(sin_f32(DEG_TO_RAD(-angle) + pi) * distance,
sin_f32(DEG_TO_RAD(-angle) - (pi / 2)) * distance);
}
} /* namespace ui */