Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
camera.hpp
Go to the documentation of this file.
1#pragma once
2
27
28#include "orrery/core/types.hpp"
29#include "orrery/core/vec3.hpp"
31
32namespace orrery::viz {
33
43public:
53 static constexpr core::Real kMaximumElevation = static_cast<core::Real>(1.5607963);
54
57
59 core::Real distance = 30;
60
62 core::Real azimuth = 0;
63
65 core::Real elevation = static_cast<core::Real>(0.3);
66
73 core::Real field_of_view = static_cast<core::Real>(0.6981317);
74
84 core::Real near_fraction = static_cast<core::Real>(0.01);
85 core::Real far_fraction = 10;
86
89 [[nodiscard]] core::Vec3 eye() const noexcept;
90
91 [[nodiscard]] Mat4 view() const noexcept;
92
93 [[nodiscard]] Mat4 projection(core::Real aspect_ratio) const noexcept;
94
96 [[nodiscard]] Mat4 view_projection(core::Real aspect_ratio) const noexcept;
97
99 void orbit(core::Real delta_azimuth, core::Real delta_elevation) noexcept;
100
110 void zoom(core::Real factor) noexcept;
111
117 void pan(core::Real right, core::Real up) noexcept;
118};
119
120} // namespace orrery::viz
A camera that orbits a point.
Definition camera.hpp:42
core::Real near_fraction
The near and far clipping distances, as fractions of the distance to the target.
Definition camera.hpp:84
core::Vec3 eye() const noexcept
Where the camera is, which follows from the target, the distance and the two angles.
core::Real azimuth
The angle in the x-y plane, in radians, measured from the positive x axis.
Definition camera.hpp:62
void zoom(core::Real factor) noexcept
Move towards or away from the target by a multiplicative factor.
core::Real elevation
The angle above the x-y plane, in radians.
Definition camera.hpp:65
void pan(core::Real right, core::Real up) noexcept
Slide the target across the plane of the screen.
void orbit(core::Real delta_azimuth, core::Real delta_elevation) noexcept
Turn about the target, clamping the elevation away from the poles.
core::Vec3 target
The point the camera looks at.
Definition camera.hpp:56
Mat4 view_projection(core::Real aspect_ratio) const noexcept
The product of the two, which is the only matrix the renderer needs.
core::Real distance
The distance from the target, which is what zooming changes.
Definition camera.hpp:59
core::Real field_of_view
The whole vertical angle the frustum spans, in radians.
Definition camera.hpp:73
static constexpr core::Real kMaximumElevation
The largest angle from the plane the camera will take, in radians.
Definition camera.hpp:53
The 4-by-4 transforms a camera needs, and nothing else.
A vector in three-dimensional Euclidean space.
Definition vec3.hpp:26
A 4-by-4 transform in column-major order.
Definition matrix4.hpp:58
The scalar and index types that every layer of the project agrees on.
A three-component vector for interfaces, not for storage.