First let's make sure I understand. A hemisphere:
Center of the hemishpere selected (yellow):
Center is known (let's start with (0, 0, 0)
, default 3D cursor position)
Radius is known (let's start with 1 m
, default sphere setting)
And you want to compute camera 3d locations and corresponding Euler rotations on hemisphere pointing at the center:
(here computed based on current frame)
In order to get this effect, create a UV sphere in default 3D cursor position and default sphere settings, resize the camera to fit inside the hemisphere and make it show in front:
On the above screenshot you see 3 pink fields - those have drivers. If you right click on the first field (x location) and choose Add driver, or hover over it and press SHIFT + D, a driver dialog will appear. You can then remove the default variable:
And put sin(frame/100)
into an expression. Sine will give you a horizontal ratio of the distance for a given angle. Here the angle is frame/100
, so the current frame number, divided by 100, expressed in radians (without dividing, the animation would be too quick).
Likewise for z location you want cos(frame/100)
, where cosine will give you a vertical ratio of the distance.
The camera should also rotate towards the middle. So here you want to do the reverse of the above, to calculate the angle based on the ratios. So for Y rotation you input atan2(x, z)
, but here you're using two variables, that unlike frame, have to be added as input variables.
Press Add Input Variable button, choose its type as Transform Channel, name the variable x
, point to the camera as the object you're taking the value from, and choose the property of the object you take the value from. Then repeat the same for z
(with adequate changes).
You're done. If you parent the camera to the hemisphere, you will be able to scale it, and it will still work. However the rotation will break:
This is because I didn't tell you to change the space for two variables in the rotation driver from default World Space to Local Space.
If you don't want to use parenting, you can just multiply the ratio you get from sin/cos by the distance (here multiplying was redundant as we would be multiplying by 1
, which was the default radius of the sphere). You can hardcode the distance, or use a variable like the (hemi)sphere scale:
If you want each frame to correspond to 1°, then you have to replace frame/100
with frame * pi / 180
. If you don't want for the camera to start at the top, but at the bottom, you can just subtract 90 from the frame.
Finally, you can add offsets based on sphere position (again, if you didn't use parenting), as well as its rotation, but as you can see below, it gets quite complex really fast without parenting:
Location X: sin((frame-90)*pi/180+rotY) * scale + x
Location Z: cos((frame-90)*pi/180+rotY) * scale + z
Rotation Y: atan2(x1-x2, z1-z2)