<p>This is a trackball camera:</p>
<p><a href="https://www.khronos.org/opengl/wiki/Object_Mouse_Trackball" rel="nofollow noreferrer">https://www.khronos.org/opengl/wiki/Object_Mouse_Trackball</a></p>
<p>Vulkan users beware, the coordinate system flips and so some of the signs in your computations should be different.</p>

CC BY-SA 4.0
2021-11-10T02:01:17.500Z
2024-05-13T20:47:42.210Z
2024-05-13T20:47:42.210Z
Makogan
<p>A spherical camera is pretty easy to define.</p>

<p>We have an anchor point C the camera always looks at and a relative position P where the camera is, which can be expressed in spherical coordinates, centered around the point C.</p>

<p>In this type of camera the the up direction is always the up vector of the world.</p>

<p>The implementation isn't terribly complex. given the parameters, we will calucate the position of the camera by doing:</p>

<p>rotation around the x axis by phi, rotation around the y axis by theta, multiply by the radius then translation.</p>

<p>And then we calculate the orientation of the camera with lookAt, centering the view at the anchor point.</p>

<p>The trackball camera is different however, it allows for orientations of the view in which the camera up isn't necessarily 0,1,0.</p>

<p>Also, in a spherical camera, the deltas around the x axis are mapped to one angle and the deltas around the y axis to the other. I am not 100% sure on how to represent nor map mouse movement to camera orientation in the case of a trackball.</p>

CC BY-SA 4.0
2019-09-27T16:54:25.527Z
Those seem to be arbitrary terms, but I got what you mean. Use $view = (T_cR_xR_yT_d)^{-1}$. Where $R_x$ is a rotation matrix around the $x$ axis, and $R_y$ is a rotation matrix around the $y$ axis, $T_d$ is the offset translation of the camera from point $C$, and $T_c$ is the translation matrix produced from the position of $C$. You may notice that in general you have $TRS$, in this case we do not have scaling, and we have added an extra translation (we do hierarchical transformations). You can think of it as parenting the camera to a pivot $C$ and rotating the pivot.
lightxbulb
<mesh><camera><camera-matrix>
Difference between a spherical camera and a trackball camera
Makogan
# Difference between a spherical camera and a trackball camera

(Asked by: username_0 on 2019-09-27)

A spherical camera is pretty easy to define.

We have an anchor point C the camera always looks at and a relative position P where the camera is, which can be expressed in spherical coordinates, centered around the point C.

In this type of camera the the up direction is always the up vector of the world.

The implementation isn't terribly complex. given the parameters, we will calucate the position of the camera by doing:

rotation around the x axis by phi, rotation around the y axis by theta, multiply by the radius then translation.

And then we calculate the orientation of the camera with lookAt, centering the view at the anchor point.

The trackball camera is different however, it allows for orientations of the view in which the camera up isn't necessarily 0,1,0.

Also, in a spherical camera, the deltas around the x axis are mapped to one angle and the deltas around the y axis to the other. I am not 100% sure on how to represent nor map mouse movement to camera orientation in the case of a trackball.

**Tags:** mesh, camera, camera-matrix

> **Comments:**
> **username_1**: Those seem to be arbitrary terms, but I got what you mean. Use $view = (T_cR_xR_yT_d)^{-1}$. Where $R_x$ is a rotation matrix around the $x$ axis, and $R_y$ is a rotation matrix around the $y$ axis, $T_d$ is the offset translation of the camera from point $C$, and $T_c$ is the translation matrix produced from the position of $C$. You may notice that in general you have $TRS$, in this case we do not have scaling, and we have added an extra translation (we do hierarchical transformations). You can think of it as parenting the camera to a pivot $C$ and rotating the pivot.  

---

## 1 answers

### Answer by username_0 on 2021-11-10. Score: 1

This is a trackball camera:

<https://www.khronos.org/opengl/wiki/Object_Mouse_Trackball>

Vulkan users beware, the coordinate system flips and so some of the signs in your computations should be different.


---

