24#ifndef JAU_FOV_HV_HALVES_HPP_
25#define JAU_FOV_HV_HALVES_HPP_
74 constexpr FovHVHalves(
const float left_,
const float right_,
const float top_,
const float bottom_,
const bool inTangents_) noexcept
92 const float halfHorizFovTan = std::tan(horizontalFov/2.0f);
93 const float halfVertFovTan = std::tan(verticalFov/2.0f);
94 return FovHVHalves(halfHorizFovTan, halfHorizFovTan, halfVertFovTan, halfVertFovTan,
true);
108 const float halfVertFovTan = std::tan(verticalFov/2.0f);
109 const float halfHorizFovTan = aspect * halfVertFovTan;
110 return FovHVHalves(halfHorizFovTan, halfHorizFovTan,
111 halfVertFovTan, halfVertFovTan,
true);
128 const float verticalFov,
const float vertCenterFromTop)
noexcept {
129 return FovHVHalves(std::tan(horizontalFov * horizCenterFromLeft),
130 std::tan(horizontalFov * ( 1.0f - horizCenterFromLeft )),
131 std::tan(verticalFov * vertCenterFromTop),
132 std::tan(verticalFov * (1.0f - vertCenterFromTop )),
151 const float aspect,
const float horizCenterFromLeft)
noexcept {
152 const float halfVertFovTan = std::tan(verticalFov/2.0f);
153 const float halfHorizFovTan = aspect * halfVertFovTan;
154 const float horizontalFov = std::atan(halfHorizFovTan) * 2.0f;
155 return byRadians(horizontalFov, horizCenterFromLeft, verticalFov, vertCenterFromTop);
184 const float f = 180.0f / M_PI;
185 std::string storedAs =
inTangents?
"tangents":
"radians";
187 const float aleft = std::atan(
left);
188 const float aright = std::atan(
right);
189 const float atop = std::atan(
top);
190 const float abottom = std::atan(
bottom);
Horizontal and vertical field of view (FOV) halves, allowing a non-centered projection.
bool inTangents
If true, values are in tangent, otherwise radians.
static FovHVHalves byFovyRadianAndAspect(const float verticalFov, const float aspect) noexcept
Returns a symmetrical centered FovHVHalves instance in inTangents, using:
static FovHVHalves byRadians(const float horizontalFov, const float verticalFov) noexcept
Returns a symmetrical centered FovHVHalves instance in inTangents, using:
float top
Half vertical FOV from center to top, either in inTangents or radians.
static FovHVHalves byRadians(const float horizontalFov, const float horizCenterFromLeft, const float verticalFov, const float vertCenterFromTop) noexcept
Returns a custom symmetry FovHVHalves instance inTangents, using:
float right
Half horizontal FOV from center to right, either in inTangents or radians.
constexpr FovHVHalves & operator=(FovHVHalves &&) noexcept=default
std::string toStringInDegrees() const noexcept
constexpr FovHVHalves(const float left_, const float right_, const float top_, const float bottom_, const bool inTangents_) noexcept
Constructor for one FovHVHalves instance.
static FovHVHalves byFovyRadianAndAspect(const float verticalFov, const float vertCenterFromTop, const float aspect, const float horizCenterFromLeft) noexcept
Returns a custom symmetry FovHVHalves instance inTangents, via computing the horizontalFov using:
constexpr FovHVHalves(FovHVHalves &&o) noexcept=default
float left
Half horizontal FOV from center to left, either in inTangents or radians.
constexpr FovHVHalves(const FovHVHalves &o) noexcept=default
std::string toString() const noexcept
FovHVHalves toTangents() const noexcept
Returns this instance in tangent values.
float vertFov() const noexcept
Returns the full vertical FOV, i.e.
constexpr FovHVHalves & operator=(const FovHVHalves &) noexcept=default
float horzFov() const noexcept
Returns the full horizontal FOV, i.e.
float bottom
Half vertical FOV from center to bottom, either in inTangents or radians.
std::string to_string(const alphabet &v) noexcept