Skip to content

Commit

Permalink
add proper projection induced rotation to .agp
Browse files Browse the repository at this point in the history
  • Loading branch information
meikelm committed Jun 6, 2024
1 parent 4b8f6fa commit ed27e8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/WEDMap/WED_MapZoomerNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,21 @@ double WED_MapZoomerNew::GetRotation(const Point2& p) const
Point2 pt(p);
pt.x_ = min(max(mLogicalBounds[0], pt.x()), mLogicalBounds[2]);
pt.y_ = min(max(mLogicalBounds[1], pt.y()), mLogicalBounds[3]);

#if FULL_EQUATIONS
auto as = sinr(pt.y()); // todo: create aproximation, this really takes long.
auto ac = cosr(pt.y()); // if any kind of precision is needed, zoom is high
auto as2 = sinr(pt.y() + 1e-3 ); // and rotation for anything visible very small, << 1deg
auto as2 = sinr(pt.y() + 1e-3); // and rotation for anything visible very small, << 1deg
auto ac2 = cosr(pt.y() + 1e-3);
auto bs = sinr(pt.x() - mLonCenter);
auto bc = cosr(pt.x() - mLonCenter);

double dx = (ac2 - ac) * bs;
double dy = (mLatCenterCOS * (as2 -as) - mLatCenterSIN * (ac2 - ac) * bc);

double rotation = atan2f(dx, dy) * RAD_TO_DEG; // float is enough precision, atan2 takes REALLY long

double rotation = atan2(dx, dy) * RAD_TO_DEG;
#else
double rotation = -(pt.x() - mLonCenter) * sinr(pt.y());
#endif
if (mScale.Pix2DegLat() > THR_GNOMONIC * 0.3)
{
double blend = min(0.7, (THR_GNOMONIC - mScale.Pix2DegLat()) / THR_GNOMONIC) / 0.7;
Expand Down
2 changes: 1 addition & 1 deletion src/WEDMap/WED_PreviewLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ struct preview_object : public WED_PreviewItem {
// draw_obj_at_ll(tman, o, loc, agl, obj->GetHeading(), g, zoomer);
}
else if (rmgr->GetAGP(vpath, agp))
draw_agp_at_ll(tman, agp, loc, agl, obj->GetHeading(), g, zoomer, preview_level);
draw_agp_at_ll(tman, agp, loc, agl, obj->GetHeading() + zoomer->GetRotation(loc), g, zoomer, preview_level);
else
{
loc = zoomer->LLToPixel(loc);
Expand Down

0 comments on commit ed27e8f

Please sign in to comment.