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 
81  void rotateAroundTarget(const Eigen::Quaternionf& q);
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;
100  uint mVpWidth, mVpHeight;
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
float mFarDist
Definition: camera.h:115
Frame lerp(float alpha, const Frame &other) const
Definition: camera.h:26
static double depth
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Definition: Memory.h:841
uint vpHeight(void) const
Definition: camera.h:55
uint mVpY
Definition: camera.h:99
bool mProjIsUptodate
Definition: camera.h:108
const Eigen::Quaternionf & orientation(void) const
Definition: camera.h:64
float mFovY
Definition: camera.h:113
float fovY(void) const
Definition: camera.h:57
Eigen::Vector3f mTarget
Definition: camera.h:111
Eigen::Quaternionf orientation
Definition: camera.h:32
Frame mFrame
Definition: camera.h:102
const Eigen::Vector3f & position(void) const
Definition: camera.h:61
bool mViewIsUptodate
Definition: camera.h:107
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Frame(const Eigen::Vector3f &pos=Eigen::Vector3f::Zero(), const Eigen::Quaternionf &o=Eigen::Quaternionf())
Definition: camera.h:22
RealScalar alpha
EIGEN_DEVICE_FUNC const Scalar & q
float mNearDist
Definition: camera.h:114
static char right
const Eigen::Vector3f & target(void)
Definition: camera.h:76
Eigen::Affine3f mViewMatrix
Definition: camera.h:104
uint mVpWidth
Definition: camera.h:100
const Frame & frame(void) const
Definition: camera.h:67
uint vpY(void) const
Definition: camera.h:53
The quaternion class used to represent 3D orientations and rotations.
uint vpX(void) const
Definition: camera.h:52
Eigen::Matrix4f mProjectionMatrix
Definition: camera.h:105
Definition: camera.h:17
uint vpWidth(void) const
Definition: camera.h:54
PinholePose< Cal3_S2 > Camera
Definition: camera.h:36
Represents an homogeneous transformation in a N dimensional space.
Eigen::Vector3f position
Definition: camera.h:33
Point2 t(10, 10)
EIGEN_DEVICE_FUNC Quaternion< Scalar > slerp(const Scalar &t, const QuaternionBase< OtherDerived > &other) const


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:00