<p>I asked this in regular SO but I think people are not understanding the question so i will try here:</p>

<p>So, for anyone familiar with Google Maps, when you zoom, it does it around the cursor.</p>

<p>That is to say, the matrix transformation for such a zoom is as simple as:</p>

<p>TST^{-1}*x</p>

<p>Where T is the translation matrix representing the point of focus, S the scale matrix and x is any arbitrary point on the plane.</p>

<p>Now, I want to produce a similar effect with a spherical camera, think <a href="https://sketchfab.com/3d-models/poisonous-cfba7da278eb41bc941022ca9ecebabe" rel="nofollow noreferrer">sketchfab</a>.</p>

<p>When you zoom in and out, the camera needs to be translated so as to give a similar effect as the 2D zooming in Maps. To be more precise, given a fully composed MVP matrix, there exists a set of parallel planes that are parallel to the camera plane. Among those there exists a unique plane P that also contains the center of the current spherical camera.</p>

<p>Given that plane, there exists a point x, that is the unprojection of the current cursor position onto the camera plane. </p>

<p>If the center of the spherical camera is c then the direction from c to x is d = x - c.</p>

<p>And here's where my challenge comes. Zooming is implemented as just offsetting the camera radially from the center, given a change in zoom Delta, I need to find the translation vector u, colinear with d, that moves the center of the camera towards x, such that I get a similar visual effect as zooming in google maps.</p>

<p>Since I know this is a bit hard to parse I tried to make a diagram:
<a href="https://i.sstatic.net/E2hqx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/E2hqx.png" alt="enter image description here"></a></p>

<p>TL;DR</p>

<p>I want to offset a spherical camera towards the cursor when I zoom, how do i pick my translation vector?</p>

CC BY-SA 4.0
2019-12-11T18:46:25.460Z
Isnt this a standard pole vector problem? Z is vector from center of circle. X is Z cross up (vector from center to north pole) , Y is Z cross X and the translate is R
joojaa
CC BY-SA 4.0
2019-12-11T18:50:55.997Z
I am not sure I am understanding your question, this isn;t a kinematic issue
Makogan
CC BY-SA 4.0
2019-12-11T18:54:43.617Z
You understand affine matrices?
joojaa
CC BY-SA 4.0
2019-12-11T18:56:23.203Z
I want to say yes, it's a transformation that remains the same regardless of the position of the input. e.g trnaslation is affine, scaling isn;t
Makogan
CC BY-SA 4.0
2019-12-11T18:58:55.053Z
Scaling is affine, so is skew, rotate, mirror and translate. Anyway all you need is to construct the tranformation matrix as described and stick yoir camera under that. (This works well eveywhere except on the singularities the pole)
joojaa
CC BY-SA 4.0
2019-12-11T20:13:40.483Z
while joojaa is right I think you are more concerned with how to calculate the fraction of the total lenght of the vector `d` for each mouse wheel click (as the camera gradually zooms) if I am correct? Why don'y you just take a small fraction of it say `0.1*d`
gallickgunner
CC BY-SA 4.0
2019-12-11T20:22:33.070Z
The camera needs to move towards the cursor as the user clicks the wheel, that's the main thing.
Makogan
CC BY-SA 4.0
2019-12-11T20:24:10.130Z
Oh okay so you are asking the procedure on how to move the spherical camera in the same way as google map does (but it isn't a spherical camera)
gallickgunner
CC BY-SA 4.0
2019-12-11T20:24:46.513Z
So, if I understand correctly, you are saying to move both the camera and the center along the vector cursor - camera

Correct?
Makogan
CC BY-SA 4.0
2019-12-11T20:25:16.350Z
That'd be my initial guess yes just nudge the camera basically the whole trackball system as it is a little in the direction of the translation then zoom
gallickgunner
CC BY-SA 4.0
2019-12-11T20:25:30.907Z
@gallickgunner Yes I know google maps isn;t a spherical camera, I am nonetheless trying to create the same effect.
Makogan
CC BY-SA 4.0
2019-12-21T19:44:04.980Z
The goal seems a bit strange since the entire point of an orbiting camera is to keep the target point at the center. I would recommend doing what Blender does, and having the target point change only when the user pans. Doing what google maps does in 3D doesn't make much sense because there are infinitely many positions along Z that match the mouse coordinates, and even zooming changes which of those points are visible (assuming perspective projection).
Dan
<projections><camera><linear-algebra><ui>
How to Pan Zoom a spherical camera?
Makogan
# How to Pan Zoom a spherical camera?

(Asked by: username_0 on 2019-12-11)

I asked this in regular SO but I think people are not understanding the question so i will try here:

So, for anyone familiar with Google Maps, when you zoom, it does it around the cursor.

That is to say, the matrix transformation for such a zoom is as simple as:

TST^{-1}\*x

Where T is the translation matrix representing the point of focus, S the scale matrix and x is any arbitrary point on the plane.

Now, I want to produce a similar effect with a spherical camera, think [sketchfab](https://sketchfab.com/3d-models/poisonous-cfba7da278eb41bc941022ca9ecebabe).

When you zoom in and out, the camera needs to be translated so as to give a similar effect as the 2D zooming in Maps. To be more precise, given a fully composed MVP matrix, there exists a set of parallel planes that are parallel to the camera plane. Among those there exists a unique plane P that also contains the center of the current spherical camera.

Given that plane, there exists a point x, that is the unprojection of the current cursor position onto the camera plane.

If the center of the spherical camera is c then the direction from c to x is d = x - c.

And here's where my challenge comes. Zooming is implemented as just offsetting the camera radially from the center, given a change in zoom Delta, I need to find the translation vector u, colinear with d, that moves the center of the camera towards x, such that I get a similar visual effect as zooming in google maps.

Since I know this is a bit hard to parse I tried to make a diagram:
[![enter image description here](https://i.sstatic.net/E2hqx.png)](https://i.sstatic.net/E2hqx.png)

TL;DR

I want to offset a spherical camera towards the cursor when I zoom, how do i pick my translation vector?

**Tags:** projections, camera, linear-algebra, ui

> **Comments:**
> **username_1**: Isnt this a standard pole vector problem? Z is vector from center of circle. X is Z cross up (vector from center to north pole) , Y is Z cross X and the translate is R  
> **username_0**: I am not sure I am understanding your question, this isn;t a kinematic issue  
> **username_1**: You understand affine matrices?  
> **username_0**: I want to say yes, it's a transformation that remains the same regardless of the position of the input. e.g trnaslation is affine, scaling isn;t  
> **username_1**: Scaling is affine, so is skew, rotate, mirror and translate. Anyway all you need is to construct the tranformation matrix as described and stick yoir camera under that. (This works well eveywhere except on the singularities the pole)  
> **username_2**: while username_1 is right I think you are more concerned with how to calculate the fraction of the total lenght of the vector `d` for each mouse wheel click (as the camera gradually zooms) if I am correct? Why don'y you just take a small fraction of it say `0.1*d`  
> **username_0**: The camera needs to move towards the cursor as the user clicks the wheel, that's the main thing.  
> **username_2**: Oh okay so you are asking the procedure on how to move the spherical camera in the same way as google map does (but it isn't a spherical camera)  
> **username_0**: So, if I understand correctly, you are saying to move both the camera and the center along the vector cursor - camera  Correct?  
> **username_2**: That'd be my initial guess yes just nudge the camera basically the whole trackball system as it is a little in the direction of the translation then zoom  
> **username_0**: @username_2 Yes I know google maps isn;t a spherical camera, I am nonetheless trying to create the same effect.  
> **username_3**: The goal seems a bit strange since the entire point of an orbiting camera is to keep the target point at the center. I would recommend doing what Blender does, and having the target point change only when the user pans. Doing what google maps does in 3D doesn't make much sense because there are infinitely many positions along Z that match the mouse coordinates, and even zooming changes which of those points are visible (assuming perspective projection).  

---

## 0 answers

