camera.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_CAMERA_H
11 #define EIGEN_CAMERA_H
12 
13 #include <Eigen/Geometry>
14 #include <QObject>
15 // #include <frame.h>
16 
17 class Frame
18 {
19  public:
21 
22  inline Frame(const Eigen::Vector3f& pos = Eigen::Vector3f::Zero(),
24  : orientation(o), position(pos)
25  {}
26  Frame lerp(float alpha, const Frame& other) const
27  {
28  return Frame((1.f-alpha)*position + alpha * other.position,
29  orientation.slerp(alpha,other.orientation));
30  }
31 
33  Eigen::Vector3f position;
34 };
35 
36 class Camera
37 {
38  public:
40 
41  Camera(void);
42 
43  Camera(const Camera& other);
44 
45  virtual ~Camera();
46 
47  Camera& operator=(const Camera& other);
48 
49  void setViewport(uint offsetx, uint offsety, uint width, uint height);
50  void setViewport(uint width, uint height);
51 
52  inline uint vpX(void) const { return mVpX; }
53  inline uint vpY(void) const { return mVpY; }
54  inline uint vpWidth(void) const { return mVpWidth; }
55  inline uint vpHeight(void) const { return mVpHeight; }
56 
57  inline float fovY(void) const { return mFovY; }
58  void setFovY(float value);
59 
60  void setPosition(const Eigen::Vector3f& pos);
61  inline const Eigen::Vector3f& position(void) const { return mFrame.position; }
62 
63  void setOrientation(const Eigen::Quaternionf& q);
64  inline const Eigen::Quaternionf& orientation(void) const { return mFrame.orientation; }
65 
66  void setFrame(const Frame& f);
67  const Frame& frame(void) const { return mFrame; }
68 
69  void setDirection(const Eigen::Vector3f& newDirection);
70  Eigen::Vector3f direction(void) const;
71  void setUp(const Eigen::Vector3f& vectorUp);
72  Eigen::Vector3f up(void) const;
73  Eigen::Vector3f right(void) const;
74 
75  void setTarget(const Eigen::Vector3f& target);
76  inline const Eigen::Vector3f& target(void) { return mTarget; }
77 
78  const Eigen::Affine3f& viewMatrix(void) const;
79  const Eigen::Matrix4f& projectionMatrix(void) const;
80 
82  void localRotate(const Eigen::Quaternionf& q);
83  void zoom(float d);
84 
85  void localTranslate(const Eigen::Vector3f& t);
86 
88  void activateGL(void);
89 
90  Eigen::Vector3f unProject(const Eigen::Vector2f& uv, float depth, const Eigen::Matrix4f& invModelview) const;
91  Eigen::Vector3f unProject(const Eigen::Vector2f& uv, float depth) const;
92 
93  protected:
94  void updateViewMatrix(void) const;
95  void updateProjectionMatrix(void) const;
96 
97  protected:
98 
99  uint mVpX, mVpY;
101 
103 
105  mutable Eigen::Matrix4f mProjectionMatrix;
106 
107  mutable bool mViewIsUptodate;
108  mutable bool mProjIsUptodate;
109 
110  // used by rotateAroundTarget
111  Eigen::Vector3f mTarget;
112 
113  float mFovY;
114  float mNearDist;
115  float mFarDist;
116 };
117 
118 #endif // EIGEN_CAMERA_H
Camera::target
const Eigen::Vector3f & target(void)
Definition: camera.h:76
Camera::activateGL
void activateGL(void)
Definition: camera.cpp:238
Camera::right
Eigen::Vector3f right(void) const
Definition: camera.cpp:97
Camera::projectionMatrix
const Eigen::Matrix4f & projectionMatrix(void) const
Definition: camera.cpp:232
Camera::updateViewMatrix
void updateViewMatrix(void) const
Definition: camera.cpp:193
Eigen::Transform
Represents an homogeneous transformation in a N dimensional space.
Definition: ForwardDeclarations.h:294
alpha
RealScalar alpha
Definition: level1_cplx_impl.h:147
Camera::~Camera
virtual ~Camera()
Definition: camera.cpp:60
d
static const double d[K][N]
Definition: igam.h:11
Frame::position
Eigen::Vector3f position
Definition: camera.h:33
Camera
Definition: camera.h:36
Camera::mViewMatrix
Eigen::Affine3f mViewMatrix
Definition: camera.h:104
Camera::mVpY
uint mVpY
Definition: camera.h:99
Frame::lerp
Frame lerp(float alpha, const Frame &other) const
Definition: camera.h:26
Frame
Definition: camera.h:17
Camera::zoom
void zoom(float d)
Definition: camera.cpp:174
Camera::setViewport
void setViewport(uint offsetx, uint offsety, uint width, uint height)
Definition: camera.cpp:65
Camera::setUp
void setUp(const Eigen::Vector3f &vectorUp)
Frame::Frame
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Frame(const Eigen::Vector3f &pos=Eigen::Vector3f::Zero(), const Eigen::Quaternionf &o=Eigen::Quaternionf())
Definition: camera.h:22
Camera::setFrame
void setFrame(const Frame &f)
Definition: camera.cpp:139
Frame::orientation
Eigen::Quaternionf orientation
Definition: camera.h:32
Eigen::numext::q
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:1984
Camera::unProject
Eigen::Vector3f unProject(const Eigen::Vector2f &uv, float depth, const Eigen::Matrix4f &invModelview) const
Camera::setPosition
void setPosition(const Eigen::Vector3f &pos)
Definition: camera.cpp:127
Camera::setTarget
void setTarget(const Eigen::Vector3f &target)
Definition: camera.cpp:117
Camera::mFarDist
float mFarDist
Definition: camera.h:115
Camera::mNearDist
float mNearDist
Definition: camera.h:114
Camera::fovY
float fovY(void) const
Definition: camera.h:57
Camera::operator=
Camera & operator=(const Camera &other)
Definition: camera.cpp:34
Camera::rotateAroundTarget
void rotateAroundTarget(const Eigen::Quaternionf &q)
Definition: camera.cpp:145
Camera::setFovY
void setFovY(float value)
Definition: camera.cpp:83
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Definition: Memory.h:841
Camera::mVpHeight
uint mVpHeight
Definition: camera.h:100
Camera::mFrame
Frame mFrame
Definition: camera.h:102
Camera::position
const Eigen::Vector3f & position(void) const
Definition: camera.h:61
Camera::vpY
uint vpY(void) const
Definition: camera.h:53
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
Camera::mViewIsUptodate
bool mViewIsUptodate
Definition: camera.h:107
Camera::vpHeight
uint vpHeight(void) const
Definition: camera.h:55
Eigen::Quaternion
The quaternion class used to represent 3D orientations and rotations.
Definition: ForwardDeclarations.h:293
Camera::direction
Eigen::Vector3f direction(void) const
Definition: camera.cpp:89
Camera::Camera
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Camera(void)
Definition: camera.cpp:18
Camera::localTranslate
void localTranslate(const Eigen::Vector3f &t)
Definition: camera.cpp:184
Camera::viewMatrix
const Eigen::Affine3f & viewMatrix(void) const
Definition: camera.cpp:205
Camera::up
Eigen::Vector3f up(void) const
Definition: camera.cpp:93
Camera::mVpX
uint mVpX
Definition: camera.h:99
Camera::localRotate
void localRotate(const Eigen::Quaternionf &q)
Definition: camera.cpp:166
Camera::setOrientation
void setOrientation(const Eigen::Quaternionf &q)
Definition: camera.cpp:133
Camera::mVpWidth
uint mVpWidth
Definition: camera.h:100
Camera::frame
const Frame & frame(void) const
Definition: camera.h:67
Camera::setDirection
void setDirection(const Eigen::Vector3f &newDirection)
Definition: camera.cpp:102
Camera::mFovY
float mFovY
Definition: camera.h:113
Camera::mProjectionMatrix
Eigen::Matrix4f mProjectionMatrix
Definition: camera.h:105
Camera::updateProjectionMatrix
void updateProjectionMatrix(void) const
Definition: camera.cpp:211
pos
Definition: example-NearestNeighbor.cpp:32
depth
static double depth
Definition: testSphericalCamera.cpp:64
Camera::vpX
uint vpX(void) const
Definition: camera.h:52
align_3::t
Point2 t(10, 10)
Camera::mTarget
Eigen::Vector3f mTarget
Definition: camera.h:111
Camera::orientation
const Eigen::Quaternionf & orientation(void) const
Definition: camera.h:64
Camera::vpWidth
uint vpWidth(void) const
Definition: camera.h:54
test_callbacks.value
value
Definition: test_callbacks.py:160
Camera::mProjIsUptodate
bool mProjIsUptodate
Definition: camera.h:108
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:04