15 #include <Eigen/Dense> 20 float left,
float right,
float bottom,
float top,
float znear,
float zfar)
26 p_matrix(0, 0) = 2.0f / (right - left);
27 p_matrix(1, 1) = 2.0f / (top - bottom);
28 p_matrix(2, 2) = -2.0f / (zfar - znear);
29 p_matrix(0, 3) = -(right + left) / (right - left);
30 p_matrix(1, 3) = -(top + bottom) / (top - bottom);
31 p_matrix(2, 3) = -(zfar + znear) / (zfar - znear);
49 std::abs(aspect - std::numeric_limits<float>::epsilon()), .0f);
57 p_matrix(2, 2) = -(zfar + znear) / (zfar - znear);
59 p_matrix(2, 3) = -(2.0f * zfar * znear) / (zfar - znear);
74 if (ratio != 0) Ay /= ratio;
77 const auto left = -.5f * Ax, right = .5f * Ax;
78 const auto bottom = -.5f * Ay, top = .5f * Ay;
92 const double fn = forward.norm();
98 const double sn = side.norm();
112 m(0, 0) =
d2f(side[0]);
113 m(0, 1) =
d2f(side[1]);
114 m(0, 2) =
d2f(side[2]);
116 m(1, 0) =
d2f(up2[0]);
117 m(1, 1) =
d2f(up2[1]);
118 m(1, 2) =
d2f(up2[2]);
120 m(2, 0) =
d2f(-forward[0]);
121 m(2, 1) =
d2f(-forward[1]);
122 m(2, 2) =
d2f(-forward[2]);
124 m(0, 3) =
d2f(-mrpt::math::dotProduct<3, double>(side,
eye));
125 m(1, 3) =
d2f(-mrpt::math::dotProduct<3, double>(up2,
eye));
126 m(2, 3) =
d2f(mrpt::math::dotProduct<3, double>(forward,
eye));
139 float x,
float y,
float z,
float& proj_u,
float& proj_v,
140 float& proj_z_depth)
const 145 proj_u = proj[3] ? proj[0] / proj[3] : 0;
146 proj_v = proj[3] ? proj[1] / proj[3] : 0;
147 proj_z_depth = proj[2];
151 float x,
float y,
float z,
float& proj_u_px,
float& proj_v_px,
152 float& proj_depth)
const 154 projectPoint(x, y, z, proj_u_px, proj_v_px, proj_depth);
mrpt::math::TPoint3D up
Up vector of the camera.
This file implements several operations that operate element-wise on individual or pairs of container...
void crossProduct3D(const T &v0, const U &v1, V &vOut)
Computes the cross product of two 3D vectors, returning a vector normal to both.
#define ASSERT_(f)
Defines an assertion mechanism.
float d2f(const double d)
shortcut for static_cast<float>(double)
void computeProjectionMatrix(float zmin, float zmax)
Uses is_projective , vw,vh, etc.
mrpt::math::CMatrixFloat44 pmv_matrix
Result of p_matrix * mv_matrix.
void projectPointPixels(float x, float y, float z, float &proj_u_px, float &proj_v_px, float &proj_depth) const
Projects a point from global world coordinates into (u,v) pixel coordinates.
void applyLookAt()
Updates the current p_matrix such that it "looks at" pointing, with up vector "up".
constexpr double DEG2RAD(const double x)
Degrees to radians.
#define ASSERT_ABOVEEQ_(__A, __B)
void computeOrthoProjectionMatrix(float left, float right, float bottom, float top, float znear, float zfar)
Especial case for custom parameters of Orthographic projection.
TPoint3D TVector3D
Useful type alias for 3-vectors.
size_t viewport_width
In pixels.
mrpt::math::TPoint3D eye
The camera is here.
#define ASSERT_ABOVE_(__A, __B)
void projectPoint(float x, float y, float z, float &proj_u, float &proj_v, float &proj_z_depth) const
Computes the normalized coordinates (range=[0,1]) on the current rendering viewport of a point with l...
mrpt::math::TPoint3D pointing
The camera points to here.
The namespace for 3D scene representation and rendering.
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
double FOV
Vertical FOV in degrees.
mrpt::math::CMatrixFloat44 p_matrix
Projection matrix, computed by renderNormalScene() from all the parameters above. ...
bool is_projective
true: projective, false: ortho