I'm currently working on a particular project where orthographic and perspective projections are both used interchangeably. To keep the transition between both projection modes somewhat seamless, I make use of an adjustable focus point in 3D space. This works really well for my use case, but I'm having a bit of trouble getting some of the vector math right to maintain the distance between the camera and the given focus point when the user is in orthographic mode.
I'll try and demonstrate the problem with a small mock-up drawing below. The actual rendering is in 3D but I don't think this particular problem differs much in 2D.
The red circle is the focus point. It initially exists at position 1 with a particular distance between it and the camera, and I want to maintain this camera distance when the focus point is moved to position 2. One way to accomplish this is to apply the same translation to the camera as the focus point, but I don't want the view itself to visibly shift. What I think I need to do is project the camera along its forward vector by an unknown amount, so that it reaches one of the blue line positions so that the distance between position 2 and the camera is still the same. That 'unknown' distance is what I'm trying to solve. It seems that projecting the delta of the two positions along the camera's forward vector is not enough.
While I know how to find the closest distance to the line, I can't really see this basic formula being adapted for maintaining a specific distance. I feel like I'm failing to grasp some fairly simple math here and would really appreciate if someone could point me in the right direction.