Ocean
Frustum.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_MATH_FRUSTUM_H
9 #define META_OCEAN_MATH_FRUSTUM_H
10 
11 #include "ocean/math/Math.h"
12 #include "ocean/math/AnyCamera.h"
13 #include "ocean/math/Box3.h"
14 #include "ocean/math/Numeric.h"
16 #include "ocean/math/Plane3.h"
17 #include "ocean/math/Sphere3.h"
18 
19 namespace Ocean
20 {
21 
22 // Forward declaration.
23 template <typename T> class FrustumT;
24 
25 /**
26  * Definition of a frustum.
27  * @see FrustumT
28  * @ingroup math
29  */
31 
32 /**
33  * Definition of a frustum with double values.
34  * @see FrustumT
35  * @ingroup math
36  */
38 
39 /**
40  * Definition of a frustum vector with float values.
41  * @see FrustumT
42  * @ingroup math
43  */
45 
46 /**
47  * Definition of a typename alias for vectors with FrustumT objects.
48  * @see FrustumT
49  * @ingroup math
50  */
51 template <typename T>
52 using FrustumsT = std::vector<FrustumT<T>>;
53 
54 /**
55  * Definition of a vector holding Frustum objects.
56  * @see Frustum
57  * @ingroup math
58  */
59 typedef std::vector<Frustum> Frustums;
60 
61 /**
62  * Definition of a vector holding FrustumD objects.
63  * @see FrustumD
64  * @ingroup math
65  */
66 typedef std::vector<FrustumD> FrustumsD;
67 
68 /**
69  * Definition of a vector holding FrustumF objects.
70  * @see FrustumF
71  * @ingroup math
72  */
73 typedef std::vector<FrustumF> FrustumsF;
74 
75 /**
76  * This class implements a viewing frustum.
77  * The viewing frustum points towards the negative z-space with x-axis pointing towards the right plane of the frustum, and y-axis pointing towards the top plane of the frustum.
78  * @tparam T Data type of the frustum elements.
79  * @see Frustum.
80  * @ingroup math
81  */
82 template <typename T>
83 class FrustumT
84 {
85  public:
86 
87  /**
88  * Definition of ids for the individual planes of the frustum.
89  */
90  enum PlaneIds : unsigned int
91  {
92  /// The front plane, with normal pointing into the frustum.
93  PI_FRONT = 0u,
94  /// The back plane, with normal pointing into the frustum.
95  PI_BACK = 1u,
96  /// The left plane, with normal pointing into the frustum.
97  PI_LEFT = 2u,
98  /// The right plane, with normal pointing into the frustum.
99  PI_RIGHT = 3u,
100  /// The top plane, with normal pointing into the frustum.
101  PI_TOP = 4u,
102  /// The bottom plane, with normal pointing into the frustum.
103  PI_BOTTOM = 5u,
104  /// The number of planes.
105  PI_END = 6u
106  };
107 
108  public:
109 
110  /**
111  * Definition of the used data type.
112  */
113  typedef T Type;
114 
115  public:
116 
117  /**
118  * Default constructor creating an invalid frustum.
119  */
120  FrustumT() = default;
121 
122  /**
123  * Creates a new viewing frustum, pointing towards the negative z-space with y-axis up.
124  * @param width The width of the camera image, in pixel, with range (0, infinity)
125  * @param height The height of the camera image, in pixel, with range (0, infinity)
126  * @param focalLengthX The focal length of the camera in horizontal direction, in pixel domain, with range (0, infinity)
127  * @param focalLengthY The focal length of the camera in vertical direction, in pixel domain, with range (0, infinity)
128  * @param principalPointX The horizontal location of the camera's principal point, in pixel, with range (0, width)
129  * @param principalPointY The vertical location of the camera's principal point, in pixel, with range (0, height)
130  * @param nearDistance The distance to the frustum's front plane, with range [0, infinity)
131  * @param farDistance The distance to the frustum's back plane, with range (nearDistance, infinity)
132  */
133  FrustumT(const T width, const T height, const T focalLengthX, const T focalLengthY, const T principalPointX, const T principalPointY, const T nearDistance, const T farDistance);
134 
135  /**
136  * Creates a new viewing frustum from a camera, pointing towards the negative z-space with y-axis up.
137  * @param pinholeCamera The pinhole camera profile for which the frustum will be created, must be valid
138  * @param nearDistance The distance to the frustum's front plane, with range [0, infinity)
139  * @param farDistance The distance to the frustum's back plane, with range (nearDistance, infinity)
140  */
141  inline FrustumT(const PinholeCamera& pinholeCamera, const T nearDistance, const T farDistance);
142 
143  /**
144  * Creates a new viewing frustum from a camera, pointing towards the negative z-space with y-axis up.
145  * @param pinholeCamera The pinhole camera profile for which the frustum will be created, must be a pinhole camera, must be valid
146  * @param nearDistance The distance to the frustum's front plane, with range [0, infinity)
147  * @param farDistance The distance to the frustum's back plane, with range (nearDistance, infinity)
148  */
149  inline FrustumT(const AnyCameraT<T>& pinholeCamera, const T nearDistance, const T farDistance);
150 
151  /**
152  * Creates a new viewing frustum located anywhere in space.
153  * @param world_T_camera The transformation transforming the camera (pointing towards negative z-space with y-axis up) to world, must be valid
154  * @param width The width of the camera image, in pixel, with range (0, infinity)
155  * @param height The height of the camera image, in pixel, with range (0, infinity)
156  * @param focalLengthX The focal length of the camera in horizontal direction, in pixel domain, with range (0, infinity)
157  * @param focalLengthY The focal length of the camera in vertical direction, in pixel domain, with range (0, infinity)
158  * @param principalPointX The horizontal location of the camera's principal point, in pixel, with range (0, width)
159  * @param principalPointY The vertical location of the camera's principal point, in pixel, with range (0, height)
160  * @param nearDistance The distance to the frustum's front plane, with range [0, infinity)
161  * @param farDistance The distance to the frustum's back plane, with range (nearDistance, infinity)
162  */
163  FrustumT(const HomogenousMatrixT4<T>& world_T_camera, const T width, const T height, const T focalLengthX, const T focalLengthY, const T principalPointX, const T principalPointY, const T nearDistance, const T farDistance);
164 
165  /**
166  * Creates a new viewing frustum from a camera located anywhere in space.
167  * @param world_T_camera The transformation transforming the camera (pointing towards negative z-space with y-axis up) to world, must be valid
168  * @param pinholeCamera The pinhole camera profile for which the frustum will be created, must be valid
169  * @param nearDistance The distance to the frustum's front plane, with range [0, infinity)
170  * @param farDistance The distance to the frustum's back plane, with range (nearDistance, infinity)
171  */
172  inline FrustumT(const HomogenousMatrixT4<T>& world_T_camera, const PinholeCamera& pinholeCamera, const T nearDistance, const T farDistance);
173 
174  /**
175  * Creates a new viewing frustum from a camera located anywhere in space.
176  * @param world_T_camera The transformation transforming the camera (pointing towards negative z-space with y-axis up) to world, must be valid
177  * @param pinholeCamera The pinhole camera profile for which the frustum will be created, must be a pinhole camera, must be valid
178  * @param nearDistance The distance to the frustum's front plane, with range [0, infinity)
179  * @param farDistance The distance to the frustum's back plane, with range (nearDistance, infinity)
180  */
181  inline FrustumT(const HomogenousMatrixT4<T>& world_T_camera, const AnyCamera& pinholeCamera, const T nearDistance, const T farDistance);
182 
183  /**
184  * Returns the six planes of the frustum, with order as defined in PlaneIds.
185  * @return The frustum's planes
186  */
187  inline const PlaneT3<T>* planes() const;
188 
189  /**
190  * Returns whether a 3D object point is inside this frustum.
191  * @param objectPoint The 3D object point to check
192  * @return True, if so
193  */
194  bool isInside(const VectorT3<T>& objectPoint) const;
195 
196  /**
197  * Returns whether a 3D sphere is located entirely inside this frustum.
198  * @param sphere The sphere to check, must be valid
199  * @return True, if so
200  */
201  bool isInside(const SphereT3<T>& sphere) const;
202 
203  /**
204  * Returns whether a 3D box is located entirely inside this frustum.
205  * @param box The box to check, must be valid
206  * @return True, if so
207  */
208  bool isInside(const Box3& box) const;
209 
210  /**
211  * Returns whether a 3D object is located entirely inside this frustum.
212  * @param vertices The 3D vertices of the object to check, must be valid
213  * @param size The number of vertices, with range [1, infinity)
214  * @return True, if so
215  */
216  bool isInside(const Vector3* vertices, const size_t size) const;
217 
218  /**
219  * Returns whether a 3D sphere has an interaction with this frustum or is entirely inside this frustum.
220  * @param sphere The sphere to check, must be valid
221  * @return True, if so
222  */
223  bool hasIntersection(const SphereT3<T>& sphere) const;
224 
225  /**
226  * Returns whether a 3D box has an interaction with this frustum or is entirely inside this frustum.
227  * @param box The box to check, must be valid
228  * @return True, if so
229  */
230  bool hasIntersection(const Box3& box) const;
231 
232  /**
233  * Returns whether a 3D object has an interaction with this frustum or is entirely inside this frustum.
234  * @param vertices The 3D vertices of the object to check, must be valid
235  * @param size The number of vertices, with range [1, infinity)
236  * @return True, if so
237  */
238  bool hasIntersection(const Vector3* vertices, const size_t size) const;
239 
240  /**
241  * Returns whether this frustum object is valid.
242  */
243  inline bool isValid() const;
244 
245  /**
246  * Returns whether two frustum objects are equal up to a small epsilon.
247  * @param frustum The second frustum to check
248  * @param eps The epsilon to be used, with range [0, infinity)
249  * @return True, if so
250  */
251  bool isEqual(const FrustumT<T>& frustum, const T eps = NumericT<T>::eps()) const;
252 
253  /**
254  * Returns whether two frustum objects are identical.
255  * @param frustum The second frustum to check
256  * @return True, if so
257  */
258  inline bool operator==(const FrustumT<T>& frustum) const;
259 
260  /**
261  * Returns whether two frustum objects are not identical.
262  * @param frustum The second frustum to check
263  * @return True, if so
264  */
265  inline bool operator!=(const FrustumT<T>& frustum) const;
266 
267  protected:
268 
269  /// The six planes of the frustum.
271 };
272 
273 template <typename T>
274 FrustumT<T>::FrustumT(const T width, const T height, const T focalLengthX, const T focalLengthY, const T principalPointX, const T principalPointY, const T nearDistance, const T farDistance)
275 {
276  ocean_assert(width > NumericT<T>::eps() && height > NumericT<T>::eps());
277 
278  ocean_assert(focalLengthX > NumericT<T>::eps() && focalLengthY > NumericT<T>::eps());
279 
280  ocean_assert(principalPointX > 0 && principalPointX < width);
281  ocean_assert(principalPointY > 0 && principalPointY < height);
282 
283  ocean_assert(nearDistance >= 0 && nearDistance < farDistance);
284 
285  planes_[PI_FRONT] = PlaneT3<T>(VectorT3<T>(0, 0, -1), nearDistance);
286  planes_[PI_BACK] = PlaneT3<T>(VectorT3<T>(0, 0, 1), -farDistance);
287 
288  const T& leftPx = principalPointX;
289  const T rightPx = width - principalPointX;
290 
291  planes_[PI_LEFT] = PlaneT3<T>(VectorT3<T>(focalLengthX, 0, -leftPx).normalized(), 0);
292  planes_[PI_RIGHT] = PlaneT3<T>(VectorT3<T>(-focalLengthX, 0, -rightPx).normalized(), 0);
293 
294  const T& topPy = principalPointY;
295  const T bottomPy = height - principalPointY;
296 
297  planes_[PI_TOP] = PlaneT3<T>(VectorT3<T>(0, -focalLengthY, -topPy).normalized(), 0);
298  planes_[PI_BOTTOM] = PlaneT3<T>(VectorT3<T>(0, focalLengthY, -bottomPy).normalized(), 0);
299 
300  ocean_assert(isValid());
301 }
302 
303 template <typename T>
304 inline FrustumT<T>::FrustumT(const PinholeCamera& pinholeCamera, const T nearDistance, const T farDistance) :
305  FrustumT<T>(T(pinholeCamera.width()), T(pinholeCamera.height()), T(pinholeCamera.focalLengthX()), T(pinholeCamera.focalLengthY()), T(pinholeCamera.principalPointX()), T(pinholeCamera.principalPointY()), nearDistance, farDistance)
306 {
307  ocean_assert(pinholeCamera.isValid());
308 }
309 
310 template <typename T>
311 inline FrustumT<T>::FrustumT(const AnyCameraT<T>& pinholeCamera, const T nearDistance, const T farDistance) :
312  FrustumT<T>(T(pinholeCamera.width()), T(pinholeCamera.height()), T(pinholeCamera.focalLengthX()), T(pinholeCamera.focalLengthY()), T(pinholeCamera.principalPointX()), T(pinholeCamera.principalPointY()), nearDistance, farDistance)
313 {
314  ocean_assert(pinholeCamera.isValid());
315  ocean_assert(pinholeCamera.anyCameraType() == AnyCameraType::PINHOLE);
316 }
317 
318 template <typename T>
319 FrustumT<T>::FrustumT(const HomogenousMatrixT4<T>& world_T_camera, const T width, const T height, const T focalLengthX, const T focalLengthY, const T principalPointX, const T principalPointY, const T nearDistance, const T farDistance)
320 {
321  ocean_assert(world_T_camera.isValid() && world_T_camera.rotationMatrix().isOrthonormal(NumericT<T>::weakEps()));
322 
323  ocean_assert(width > NumericT<T>::eps() && height > NumericT<T>::eps());
324 
325  ocean_assert(focalLengthX > NumericT<T>::eps() && focalLengthY > NumericT<T>::eps());
326 
327  ocean_assert(principalPointX > 0 && principalPointX < width);
328  ocean_assert(principalPointY > 0 && principalPointY < height);
329 
330  ocean_assert(nearDistance >= 0 && nearDistance < farDistance);
331 
332  const VectorT3<T> translation = world_T_camera.translation();
333 
334  const VectorT3<T> zAxisNormalized = world_T_camera.zAxis().normalizedOrZero();
335 
336  planes_[PI_FRONT] = PlaneT3<T>(world_T_camera * VectorT3<T>(0, 0, -nearDistance), -zAxisNormalized);
337  planes_[PI_BACK] = PlaneT3<T>(world_T_camera * VectorT3<T>(0, 0, -farDistance), zAxisNormalized);
338 
339  const T& leftPx = principalPointX;
340  const T rightPx = width - principalPointX;
341 
342  const VectorT3<T> leftNormal = (world_T_camera * VectorT3<T>(focalLengthX, 0, -leftPx) - translation).normalizedOrZero();
343  const VectorT3<T> rightNormal = (world_T_camera * VectorT3<T>(-focalLengthX, 0, -rightPx) - translation).normalizedOrZero();
344 
345  planes_[PI_LEFT] = PlaneT3<T>(translation, leftNormal);
346  planes_[PI_RIGHT] = PlaneT3<T>(translation, rightNormal);
347 
348  const T& topPy = principalPointY;
349  const T bottomPy = height - principalPointY;
350 
351  const VectorT3<T> topNormal = (world_T_camera * VectorT3<T>(0, -focalLengthY, -topPy) - translation).normalizedOrZero();
352  const VectorT3<T> bottomNormal = (world_T_camera * VectorT3<T>(0, focalLengthY, -bottomPy) - translation).normalizedOrZero();
353 
354  planes_[PI_TOP] = PlaneT3<T>(translation, topNormal);
355  planes_[PI_BOTTOM] = PlaneT3<T>(translation, bottomNormal);
356 
357  ocean_assert(isValid());
358 }
359 
360 template <typename T>
361 FrustumT<T>::FrustumT(const HomogenousMatrixT4<T>& world_T_camera, const PinholeCamera& pinholeCamera, const T nearDistance, const T farDistance) :
362  FrustumT(world_T_camera, T(pinholeCamera.width()), T(pinholeCamera.height()), T(pinholeCamera.focalLengthX()), T(pinholeCamera.focalLengthY()), T(pinholeCamera.principalPointX()), T(pinholeCamera.principalPointY()), nearDistance, farDistance)
363 {
364  ocean_assert(pinholeCamera.isValid());
365 }
366 
367 template <typename T>
368 FrustumT<T>::FrustumT(const HomogenousMatrixT4<T>& world_T_camera, const AnyCamera& pinholeCamera, const T nearDistance, const T farDistance) :
369  FrustumT(world_T_camera, T(pinholeCamera.width()), T(pinholeCamera.height()), T(pinholeCamera.focalLengthX()), T(pinholeCamera.focalLengthY()), T(pinholeCamera.principalPointX()), T(pinholeCamera.principalPointY()), nearDistance, farDistance)
370 {
371  ocean_assert(pinholeCamera.isValid());
372  ocean_assert(pinholeCamera.anyCameraType() == AnyCameraType::PINHOLE);
373 }
374 
375 template <typename T>
376 inline const PlaneT3<T>* FrustumT<T>::planes() const
377 {
378  return planes_;
379 }
380 
381 template <typename T>
382 inline bool FrustumT<T>::isInside(const VectorT3<T>& objectPoint) const
383 {
384  ocean_assert(isValid());
385 
386  // the point is inside the frustum if the point is in front of all frustum planes
387 
388  for (unsigned int n = 0u; n < PI_END; ++n)
389  {
390  if (planes_[n].signedDistance(objectPoint) < T(0))
391  {
392  return false;
393  }
394  }
395 
396  return true;
397 }
398 
399 template <typename T>
400 bool FrustumT<T>::isInside(const SphereT3<T>& sphere) const
401 {
402  ocean_assert(isValid());
403  ocean_assert(sphere.isValid());
404 
405  // the sphere is entirely inside the frustum if the signed distance is bigger/equal than the radius of the sphere for all planes
406 
407  for (unsigned int n = 0u; n < PI_END; ++n)
408  {
409  if (planes_[n].signedDistance(sphere.center()) < sphere.radius())
410  {
411  return false;
412  }
413  }
414 
415  return true;
416 }
417 
418 template <typename T>
419 bool FrustumT<T>::isInside(const Box3& box) const
420 {
421  ocean_assert(isValid());
422  ocean_assert(box.isValid());
423 
424  // the box is entirely inside of the frustum if all 8 corners of the box are in front of all planes
425 
426  for (unsigned int n = 0u; n < PI_END; ++n)
427  {
428  const PlaneT3<T>& plane = planes_[n];
429 
430  if (plane.signedDistance(box.lower()) < T(0)
431  || plane.signedDistance(VectorT3<T>(box.lower().x(), box.lower().y(), box.higher().z())) < T(0)
432  || plane.signedDistance(VectorT3<T>(box.lower().x(), box.higher().y(), box.lower().z())) < T(0)
433  || plane.signedDistance(VectorT3<T>(box.lower().x(), box.higher().y(), box.higher().z())) < T(0)
434  || plane.signedDistance(VectorT3<T>(box.higher().x(), box.lower().y(), box.lower().z())) < T(0)
435  || plane.signedDistance(VectorT3<T>(box.higher().x(), box.lower().y(), box.higher().z())) < T(0)
436  || plane.signedDistance(VectorT3<T>(box.higher().x(), box.higher().y(), box.lower().z())) < T(0)
437  || plane.signedDistance(box.higher()) < T(0))
438  {
439  return false;
440  }
441  }
442 
443  return true;
444 }
445 
446 template <typename T>
447 bool FrustumT<T>::isInside(const Vector3* vertices, const size_t size) const
448 {
449  ocean_assert(isValid());
450  ocean_assert(vertices != nullptr && size != 0);
451 
452  // the object is entirely inside of the frustum if all vertices of the object are in front of all planes
453 
454  for (unsigned int n = 0u; n < PI_END; ++n)
455  {
456  const PlaneT3<T>& plane = planes_[n];
457 
458  for (size_t nVertex = 0; nVertex < size; ++nVertex)
459  {
460  if (plane.signedDistance(vertices[nVertex]) < T(0))
461  {
462  return false;
463  }
464  }
465  }
466 
467  return true;
468 }
469 
470 template <typename T>
471 bool FrustumT<T>::hasIntersection(const SphereT3<T>& sphere) const
472 {
473  ocean_assert(isValid());
474  ocean_assert(sphere.isValid());
475 
476  // the sphere is partially inside the frustum if the signed distance is bigger than the (negative) radius of the sphere for all planes
477 
478  for (unsigned int n = 0u; n < PI_END; ++n)
479  {
480  if (planes_[n].signedDistance(sphere.center()) < -sphere.radius())
481  {
482  return false;
483  }
484  }
485 
486  return true;
487 }
488 
489 template <typename T>
490 bool FrustumT<T>::hasIntersection(const Box3& box) const
491 {
492  ocean_assert(isValid());
493  ocean_assert(box.isValid());
494 
495  // the box is outside of the frustum if all 8 corners of the box are outside of one plane
496 
497  for (unsigned int n = 0u; n < PI_END; ++n)
498  {
499  const PlaneT3<T>& plane = planes_[n];
500 
501  if (plane.signedDistance(box.lower()) < T(0)
502  && plane.signedDistance(VectorT3<T>(box.lower().x(), box.lower().y(), box.higher().z())) < T(0)
503  && plane.signedDistance(VectorT3<T>(box.lower().x(), box.higher().y(), box.lower().z())) < T(0)
504  && plane.signedDistance(VectorT3<T>(box.lower().x(), box.higher().y(), box.higher().z())) < T(0)
505  && plane.signedDistance(VectorT3<T>(box.higher().x(), box.lower().y(), box.lower().z())) < T(0)
506  && plane.signedDistance(VectorT3<T>(box.higher().x(), box.lower().y(), box.higher().z())) < T(0)
507  && plane.signedDistance(VectorT3<T>(box.higher().x(), box.higher().y(), box.lower().z())) < T(0)
508  && plane.signedDistance(box.higher()) < T(0))
509  {
510  return false;
511  }
512  }
513 
514  return true;
515 }
516 
517 template <typename T>
518 bool FrustumT<T>::hasIntersection(const Vector3* vertices, const size_t size) const
519 {
520  ocean_assert(isValid());
521  ocean_assert(vertices != nullptr && size != 0);
522 
523  // the object is outside of the frustum if all vertices of the object are outside of at least one plane
524 
525  for (unsigned int n = 0u; n < PI_END; ++n)
526  {
527  const PlaneT3<T>& plane = planes_[n];
528 
529  bool allOutside = true;
530 
531  for (size_t nVertex = 0; allOutside && nVertex < size; ++nVertex)
532  {
533  allOutside = plane.signedDistance(vertices[nVertex]) < T(0);
534  }
535 
536  if (allOutside)
537  {
538  return false;
539  }
540  }
541 
542  return true;
543 }
544 
545 template <typename T>
546 inline bool FrustumT<T>::isValid() const
547 {
548  return planes_[PI_FRONT].isValid();
549 }
550 
551 template <typename T>
552 bool FrustumT<T>::isEqual(const FrustumT<T>& frustum, const T eps) const
553 {
554  for (unsigned int n = 0u; n < PI_END; ++n)
555  {
556  if (!planes_[n].isEqual(frustum.planes_[n], eps))
557  {
558  return false;
559  }
560  }
561 
562  return true;
563 }
564 
565 template <typename T>
566 inline bool FrustumT<T>::operator==(const FrustumT<T>& frustum) const
567 {
568  return isEqual(frustum);
569 }
570 
571 template <typename T>
572 inline bool FrustumT<T>::operator!=(const FrustumT<T>& frustum) const
573 {
574  return !isEqual(frustum);
575 }
576 
577 }
578 
579 #endif // META_OCEAN_MATH_FRUSTUM_H
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
virtual bool isValid() const =0
Returns whether this camera is valid.
virtual AnyCameraType anyCameraType() const =0
Returns the type of this camera.
bool isValid() const
Returns whether the bounding box is valid.
const VectorT3< T > & lower() const
Returns the lower corner of the box.
const VectorT3< T > & higher() const
Returns the higher corner of the box.
This class implements a viewing frustum.
Definition: Frustum.h:84
const PlaneT3< T > * planes() const
Returns the six planes of the frustum, with order as defined in PlaneIds.
Definition: Frustum.h:376
bool isValid() const
Returns whether this frustum object is valid.
Definition: Frustum.h:546
PlaneT3< T > planes_[PI_END]
The six planes of the frustum.
Definition: Frustum.h:270
bool isEqual(const FrustumT< T > &frustum, const T eps=NumericT< T >::eps()) const
Returns whether two frustum objects are equal up to a small epsilon.
Definition: Frustum.h:552
bool operator!=(const FrustumT< T > &frustum) const
Returns whether two frustum objects are not identical.
Definition: Frustum.h:572
bool operator==(const FrustumT< T > &frustum) const
Returns whether two frustum objects are identical.
Definition: Frustum.h:566
T Type
Definition of the used data type.
Definition: Frustum.h:113
FrustumT()=default
Default constructor creating an invalid frustum.
bool isInside(const VectorT3< T > &objectPoint) const
Returns whether a 3D object point is inside this frustum.
Definition: Frustum.h:382
PlaneIds
Definition of ids for the individual planes of the frustum.
Definition: Frustum.h:91
@ PI_END
The number of planes.
Definition: Frustum.h:105
@ PI_FRONT
The front plane, with normal pointing into the frustum.
Definition: Frustum.h:93
@ PI_BOTTOM
The bottom plane, with normal pointing into the frustum.
Definition: Frustum.h:103
@ PI_LEFT
The left plane, with normal pointing into the frustum.
Definition: Frustum.h:97
@ PI_RIGHT
The right plane, with normal pointing into the frustum.
Definition: Frustum.h:99
@ PI_TOP
The top plane, with normal pointing into the frustum.
Definition: Frustum.h:101
@ PI_BACK
The back plane, with normal pointing into the frustum.
Definition: Frustum.h:95
bool hasIntersection(const SphereT3< T > &sphere) const
Returns whether a 3D sphere has an interaction with this frustum or is entirely inside this frustum.
Definition: Frustum.h:471
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition: HomogenousMatrix4.h:110
SquareMatrixT3< T > rotationMatrix() const
Returns the rotation matrix of the transformation.
Definition: HomogenousMatrix4.h:1493
VectorT3< T > translation() const
Returns the translation of the transformation.
Definition: HomogenousMatrix4.h:1381
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
VectorT3< T > zAxis() const
Returns the z-axis of the transformation which is the first vector of the upper left 3x3 rotation mat...
Definition: HomogenousMatrix4.h:1374
This class provides basic numeric functionalities.
Definition: Numeric.h:57
bool isValid() const
Returns whether this camera is valid.
Definition: PinholeCamera.h:1572
This class implements a plane in 3D space.
Definition: Plane3.h:73
T signedDistance(const VectorT3< T > &point) const
Returns the distance between a given point and this plane.
Definition: Plane3.h:441
This class implements a 3D sphere.
Definition: Sphere3.h:57
bool isValid() const
Returns whether this radius of this sphere is not negative and thus the sphere is valid.
Definition: Sphere3.h:281
const T & radius() const
Returns the radius of the sphere.
Definition: Sphere3.h:209
const VectorT3< T > & center() const
Returns the center of the sphere.
Definition: Sphere3.h:203
This class implements a vector with three elements.
Definition: Vector3.h:97
const T & y() const noexcept
Returns the y value.
Definition: Vector3.h:812
const T & x() const noexcept
Returns the x value.
Definition: Vector3.h:800
const T & z() const noexcept
Returns the z value.
Definition: Vector3.h:824
std::vector< FrustumD > FrustumsD
Definition of a vector holding FrustumD objects.
Definition: Frustum.h:66
FrustumT< float > FrustumF
Definition of a frustum vector with float values.
Definition: Frustum.h:44
FrustumT< double > FrustumD
Definition of a frustum with double values.
Definition: Frustum.h:37
std::vector< FrustumF > FrustumsF
Definition of a vector holding FrustumF objects.
Definition: Frustum.h:73
std::vector< Frustum > Frustums
Definition of a vector holding Frustum objects.
Definition: Frustum.h:59
FrustumT< Scalar > Frustum
Definition of a frustum.
Definition: Frustum.h:23
std::vector< FrustumT< T > > FrustumsT
Definition of a typename alias for vectors with FrustumT objects.
Definition: Frustum.h:52
@ PINHOLE
A pinhole camera.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15