# Getting current scene azimuth and elevation

**URL:** https://discourse.julialang.org/t/getting-current-scene-azimuth-and-elevation/108380
**Category:** General Usage
**Tags:** makie
**Created:** [January 5, 2024, 10:21am UTC](https://discourse.julialang.org/t/getting-current-scene-azimuth-and-elevation/108380 "2024-01-05T10:21:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [January 5, 2024, 10:21am UTC](https://discourse.julialang.org/t/getting-current-scene-azimuth-and-elevation/108380/1 "2024-01-05T10:21:15Z")

</div>

Makie 0.20 has added a method `update_cam!(scene, azimuth, elevation)`. Is there an easy way to go in the other direction, to get the azimuth and elevation values corresponding to the current scene configuration?

These values are readily available in an `Axis3` but I’m working with an `LScene`.

For context: In Matlab I often do the following:

```octave
% get a good viewing angle with the mouse
% then retrieve this config with:
[az, el] = view
 
% tweak the values of `az` and `el` manually or programatically
% then apply new values with:
view(az, el)

```

I’d like to do the same with Makie.

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [January 5, 2024, 11:16am UTC](https://discourse.julialang.org/t/getting-current-scene-azimuth-and-elevation/108380/2 "2024-01-05T11:16:44Z")

</div>

You can calculate those from `l.scene.camera_controls.eyeposition[]` and `l.scene.camera_controls.lookat[]` as those are what that method sets:

> <https://github.com/MakieOrg/Makie.jl/blob/6b8f12e6daec93aa21ab4f83b85d07669e3d0d0e/src/camera/camera3d.jl#L804-L819>

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [January 5, 2024, 2:05pm UTC](https://discourse.julialang.org/t/getting-current-scene-azimuth-and-elevation/108380/3 "2024-01-05T14:05:05Z")

</div>

Thanks! I guess I cannot assume this particular value `Vec3f(-st * cp, -st * sp, ct)` of `upvector` for the general case, but we can easily invert these spherical coordinates (with `theta` defined as the angle from the xy plane) based on `lookat` and `eyeposition`:

```julia
v = normalize(cam.eyeposition[] - cam.lookat[])
phi = atan(v[2], v[1]) # azimuth
theta = asin(v[3]) # elevation (between -π/2 and π/2)

```

It could be nice to have a helper function for that in Makie?
