I am building a custom map viewer, part of meteorological production system, using Java language and GeoTools library. I have prepared a custom map renderer, using OpenGL, that allows to display maps in different projections and need a bit of help with user camera navigation over maps in Lambert conic projection.
I would like to allow user to navigate the conic map in such way, that map north is always pointing up. Moving mouse left and right should rotate the map around a pole, and moving up/down is always north-south adjustment:
I am struggling with understanding the mathematical transformation for screen-map coordinates for such use case, could anyone point me to the right direction?
This is a code I am trying right now; It only accounts for x axis mouse movement for now:
origin vector is north pole location
worldPos and prevWorldPos are mouse positions
all vectors are in projection coordinate system
float pdx = prevWorldPos.x - origin.x; float pdy = prevWorldPos.y - origin.y; float radius = (float) Math.sqrt( pdx*pdx + pdy*pdy ); float prevAngle = (float) Math.atan2(pdy, pdx); float da = (float) Math.atan2(radius, worldPos.x - prevWorldPos.x); float angle = prevAngle + da; cameraAngle = angle+Angles.PI_div_2; cameraX = origin.x + (float) (radius * Math.cos( angle )); cameraY = origin.y + (float) (radius * Math.sin( angle ));