8#include "../utility/utility.hpp"
9#include "../macros.hpp"
14hi_export_module(hikogui.geometry : perspective);
16hi_export
namespace hi {
inline namespace v1 {
37 perspective(
float fov_y,
float aspect_ratio,
float znear,
float zfar) noexcept :
38 _tan_half_fov_y(
std::tan(fov_y * 0.5f)), _aspect_ratio(aspect_ratio), _znear(znear), _zfar(zfar)
53 perspective(fov_y, view_port.width() / view_port.height(), znear, zfar)
57 [[nodiscard]]
constexpr operator matrix3() noexcept
59 auto const a = _aspect_ratio;
60 auto const t = _tan_half_fov_y;
62 auto const n = _znear;
66 1.0f / (a * t), 0.0f , 0.0f , 0.0f,
67 0.0f , 1.0f / t, 0.0f , 0.0f,
68 0.0f , 0.0f , f / (n - f), -(f * n) / (f - n),
69 0.0f , 0.0f , -1.0f , 0.0f
75 float _tan_half_fov_y;
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
A high-level geometric extent.
Definition extent2.hpp:32
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix3.hpp:36
Perspective transform.
Definition perspective.hpp:21
perspective(float fov_y, float aspect_ratio, float znear, float zfar) noexcept
Create a right-handed perspective transform.
Definition perspective.hpp:37
perspective(float fov_y, extent2 view_port, float znear, float zfar) noexcept
Create a right-handed perspective transform.
Definition perspective.hpp:52