Frustum.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_MATH_FRUSTUM_HH_
18 #define IGNITION_MATH_FRUSTUM_HH_
19 
20 #include <ignition/math/Plane.hh>
21 #include <ignition/math/Angle.hh>
22 #include <ignition/math/Pose3.hh>
23 #include <ignition/math/config.hh>
24 
25 namespace ignition
26 {
27  namespace math
28  {
29  inline namespace IGNITION_MATH_VERSION_NAMESPACE
30  {
31  // Forward declaration of private data
32  class FrustumPrivate;
33 
36  class IGNITION_MATH_VISIBLE Frustum
37  {
39  public: enum FrustumPlane
40  {
42  FRUSTUM_PLANE_NEAR = 0,
43 
45  FRUSTUM_PLANE_FAR = 1,
46 
48  FRUSTUM_PLANE_LEFT = 2,
49 
51  FRUSTUM_PLANE_RIGHT = 3,
52 
54  FRUSTUM_PLANE_TOP = 4,
55 
57  FRUSTUM_PLANE_BOTTOM = 5
58  };
59 
67  public: Frustum();
68 
81  public: Frustum(const double _near,
82  const double _far,
83  const math::Angle &_fov,
84  const double _aspectRatio,
85  const math::Pose3d &_pose = math::Pose3d::Zero);
86 
89  public: Frustum(const Frustum &_p);
90 
92  public: virtual ~Frustum();
93 
98  public: double Near() const;
99 
104  public: void SetNear(const double _near);
105 
110  public: double Far() const;
111 
116  public: void SetFar(const double _far);
117 
123  public: math::Angle FOV() const;
124 
130  public: void SetFOV(const math::Angle &_fov);
131 
136  public: double AspectRatio() const;
137 
142  public: void SetAspectRatio(const double _aspectRatio);
143 
147  public: Planed Plane(const FrustumPlane _plane) const;
148 
152  public: bool Contains(const Box &_b) const;
153 
157  public: bool Contains(const Vector3d &_p) const;
158 
162  public: Pose3d Pose() const;
163 
167  public: void SetPose(const Pose3d &_pose);
168 
172  public: Frustum &operator=(const Frustum &_f);
173 
176  private: void ComputePlanes();
177 
180  private: FrustumPrivate *dataPtr;
181  };
182  }
183  }
184 }
185 #endif
Plane.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::SetPose
void SetPose(const Pose3d &_pose)
Set the pose of the frustum.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Angle
An angle and related functions.
Definition: Angle.hh:48
ignition
Definition: Angle.hh:40
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Plane
Planed Plane(const FrustumPlane _plane) const
Get a plane of the frustum.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Frustum
Frustum(const double _near, const double _far, const math::Angle &_fov, const double _aspectRatio, const math::Pose3d &_pose=math::Pose3d::Zero)
Constructor.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::SetAspectRatio
void SetAspectRatio(const double _aspectRatio)
Set the aspect ratio, which is the width divided by height of the near or far planes.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::operator=
Frustum & operator=(const Frustum &_f)
Assignment operator.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::AspectRatio
double AspectRatio() const
Get the aspect ratio, which is the width divided by height of the near or far planes.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum
Mathematical representation of a frustum and related functions.
Definition: Frustum.hh:37
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Pose
Pose3d Pose() const
Get the pose of the frustum.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::~Frustum
virtual ~Frustum()
Destructor.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Contains
bool Contains(const Vector3d &_p) const
Check if a point lies inside the pyramid frustum.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: Vector3.hh:40
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Far
double Far() const
Get the far distance.
Angle.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::SetFOV
void SetFOV(const math::Angle &_fov)
Set the horizontal field of view.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box
Mathematical representation of a box and related functions.
Definition: Box.hh:39
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Near
double Near() const
Get the near distance.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Contains
bool Contains(const Box &_b) const
Check if a box lies inside the pyramid frustum.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Plane
A plane and related functions.
Definition: Plane.hh:35
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Frustum
Frustum()
Default constructor.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::SetFar
void SetFar(const double _far)
Set the far distance.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Pose3
Encapsulates a position and rotation in three space.
Definition: Pose3.hh:34
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::FrustumPlane
FrustumPlane
Planes that define the boundaries of the frustum.
Definition: Frustum.hh:40
Pose3.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::SetNear
void SetNear(const double _near)
Set the near distance.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::FOV
math::Angle FOV() const
Get the horizontal field of view.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Frustum::Frustum
Frustum(const Frustum &_p)
Copy Constructor.