HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImathFrustum.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2002-2012, Industrial Light & Magic, a division of Lucas
4 // Digital Ltd. LLC
5 //
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
10 // met:
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
16 // distribution.
17 // * Neither the name of Industrial Light & Magic nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
33 ///////////////////////////////////////////////////////////////////////////
34 
35 
36 
37 #ifndef INCLUDED_IMATHFRUSTUM_H
38 #define INCLUDED_IMATHFRUSTUM_H
39 
40 
41 #include "ImathVec.h"
42 #include "ImathPlane.h"
43 #include "ImathLine.h"
44 #include "ImathMatrix.h"
45 #include "ImathLimits.h"
46 #include "ImathFun.h"
47 #include "ImathNamespace.h"
48 
49 #include "IexMathExc.h"
50 
52 
53 //
54 // template class Frustum<T>
55 //
56 // The frustum is always located with the eye point at the
57 // origin facing down -Z. This makes the Frustum class
58 // compatable with OpenGL (or anything that assumes a camera
59 // looks down -Z, hence with a right-handed coordinate system)
60 // but not with RenderMan which assumes the camera looks down
61 // +Z. Additional functions are provided for conversion from
62 // and from various camera coordinate spaces.
63 //
64 // nearPlane/farPlane: near/far are keywords used by Microsoft's
65 // compiler, so we use nearPlane/farPlane instead to avoid
66 // issues.
67 
68 
69 template<class T>
70 class Frustum
71 {
72  public:
73  Frustum();
74  Frustum(const Frustum &);
75  Frustum(T nearPlane, T farPlane, T left, T right, T top, T bottom, bool ortho=false);
77  virtual ~Frustum();
78 
79  //--------------------
80  // Assignment operator
81  //--------------------
82 
83  const Frustum & operator = (const Frustum &);
84 
85  //--------------------
86  // Operators: ==, !=
87  //--------------------
88 
89  bool operator == (const Frustum<T> &src) const;
90  bool operator != (const Frustum<T> &src) const;
91 
92  //--------------------------------------------------------
93  // Set functions change the entire state of the Frustum
94  //--------------------------------------------------------
95 
96  void set(T nearPlane, T farPlane,
97  T left, T right,
98  T top, T bottom,
99  bool ortho=false);
100 
101  void set(T nearPlane, T farPlane, T fovx, T fovy, T aspect);
102 
103  //------------------------------------------------------
104  // These functions modify an already valid frustum state
105  //------------------------------------------------------
106 
108  void setOrthographic(bool);
109 
110  //--------------
111  // Access
112  //--------------
113 
114  bool orthographic() const { return _orthographic; }
115  T nearPlane() const { return _nearPlane; }
116  T hither() const { return _nearPlane; }
117  T farPlane() const { return _farPlane; }
118  T yon() const { return _farPlane; }
119  T left() const { return _left; }
120  T right() const { return _right; }
121  T bottom() const { return _bottom; }
122  T top() const { return _top; }
123 
124  //-----------------------------------------------------------------------
125  // Sets the planes in p to be the six bounding planes of the frustum, in
126  // the following order: top, right, bottom, left, near, far.
127  // Note that the planes have normals that point out of the frustum.
128  // The version of this routine that takes a matrix applies that matrix
129  // to transform the frustum before setting the planes.
130  //-----------------------------------------------------------------------
131 
132  void planes(Plane3<T> p[6]) const;
133  void planes(Plane3<T> p[6], const Matrix44<T> &M) const;
134 
135  //----------------------
136  // Derived Quantities
137  //----------------------
138 
139  T fovx() const;
140  T fovy() const;
141  T aspect() const;
143  bool degenerate() const;
144 
145  //-----------------------------------------------------------------------
146  // Takes a rectangle in the screen space (i.e., -1 <= left <= right <= 1
147  // and -1 <= bottom <= top <= 1) of this Frustum, and returns a new
148  // Frustum whose near clipping-plane window is that rectangle in local
149  // space.
150  //-----------------------------------------------------------------------
151 
152  Frustum<T> window(T left, T right, T top, T bottom) const;
153 
154  //----------------------------------------------------------
155  // Projection is in screen space / Conversion from Z-Buffer
156  //----------------------------------------------------------
157 
158  Line3<T> projectScreenToRay( const Vec2<T> & ) const;
159  Vec2<T> projectPointToScreen( const Vec3<T> & ) const;
160 
161  T ZToDepth(long zval, long min, long max) const;
162  T normalizedZToDepth(T zval) const;
163  long DepthToZ(T depth, long zmin, long zmax) const;
164 
165  T worldRadius(const Vec3<T> &p, T radius) const;
166  T screenRadius(const Vec3<T> &p, T radius) const;
167 
168 
169  protected:
170 
171  Vec2<T> screenToLocal( const Vec2<T> & ) const;
172  Vec2<T> localToScreen( const Vec2<T> & ) const;
173 
174  protected:
182 };
183 
184 
185 template<class T>
187 {
188  set(T (0.1),
189  T (1000.0),
190  T (-1.0),
191  T (1.0),
192  T (1.0),
193  T (-1.0),
194  false);
195 }
196 
197 template<class T>
199 {
200  *this = f;
201 }
202 
203 template<class T>
204 inline Frustum<T>::Frustum(T n, T f, T l, T r, T t, T b, bool o)
205 {
206  set(n,f,l,r,t,b,o);
207 }
208 
209 template<class T>
210 inline Frustum<T>::Frustum(T nearPlane, T farPlane, T fovx, T fovy, T aspect)
211 {
212  set(nearPlane,farPlane,fovx,fovy,aspect);
213 }
214 
215 template<class T>
217 {
218 }
219 
220 template<class T>
221 const Frustum<T> &
223 {
224  _nearPlane = f._nearPlane;
225  _farPlane = f._farPlane;
226  _left = f._left;
227  _right = f._right;
228  _top = f._top;
229  _bottom = f._bottom;
230  _orthographic = f._orthographic;
231 
232  return *this;
233 }
234 
235 template <class T>
236 bool
238 {
239  return
240  _nearPlane == src._nearPlane &&
241  _farPlane == src._farPlane &&
242  _left == src._left &&
243  _right == src._right &&
244  _top == src._top &&
245  _bottom == src._bottom &&
246  _orthographic == src._orthographic;
247 }
248 
249 template <class T>
250 inline bool
252 {
253  return !operator== (src);
254 }
255 
256 template<class T>
257 void Frustum<T>::set(T n, T f, T l, T r, T t, T b, bool o)
258 {
259  _nearPlane = n;
260  _farPlane = f;
261  _left = l;
262  _right = r;
263  _bottom = b;
264  _top = t;
265  _orthographic = o;
266 }
267 
268 template<class T>
270 {
271  if ( _orthographic )
272  {
273  _nearPlane = n;
274  }
275  else
276  {
277  Line3<T> lowerLeft( Vec3<T>(0,0,0), Vec3<T>(_left,_bottom,-_nearPlane) );
278  Line3<T> upperRight( Vec3<T>(0,0,0), Vec3<T>(_right,_top,-_nearPlane) );
279  Plane3<T> nearPlane( Vec3<T>(0,0,-1), n );
280 
281  Vec3<T> ll = Vec3<T> (0, 0, 0);
282  Vec3<T> ur = Vec3<T> (0, 0, 0);
283  nearPlane.intersect(lowerLeft,ll);
284  nearPlane.intersect(upperRight,ur);
285 
286  _left = ll.x;
287  _right = ur.x;
288  _top = ur.y;
289  _bottom = ll.y;
290  _nearPlane = n;
291  _farPlane = f;
292  }
293 
294  _farPlane = f;
295 }
296 
297 template<class T>
299 {
300  _orthographic = ortho;
301 }
302 
303 template<class T>
304 void Frustum<T>::set(T nearPlane, T farPlane, T fovx, T fovy, T aspect)
305 {
306  if (fovx != 0 && fovy != 0)
307  throw IEX_NAMESPACE::ArgExc ("fovx and fovy cannot both be non-zero.");
308 
309  const T two = static_cast<T>(2);
310 
311  if (fovx != 0)
312  {
313  _right = nearPlane * Math<T>::tan(fovx / two);
314  _left = -_right;
315  _top = ((_right - _left) / aspect) / two;
316  _bottom = -_top;
317  }
318  else
319  {
320  _top = nearPlane * Math<T>::tan(fovy / two);
321  _bottom = -_top;
322  _right = (_top - _bottom) * aspect / two;
323  _left = -_right;
324  }
325  _nearPlane = nearPlane;
326  _farPlane = farPlane;
327  _orthographic = false;
328 }
329 
330 template<class T>
332 {
333  return Math<T>::atan2(_right,_nearPlane) - Math<T>::atan2(_left,_nearPlane);
334 }
335 
336 template<class T>
338 {
339  return Math<T>::atan2(_top,_nearPlane) - Math<T>::atan2(_bottom,_nearPlane);
340 }
341 
342 template<class T>
344 {
345  T rightMinusLeft = _right-_left;
346  T topMinusBottom = _top-_bottom;
347 
348  if (abs(topMinusBottom) < 1 &&
349  abs(rightMinusLeft) > limits<T>::max() * abs(topMinusBottom))
350  {
351  throw IEX_NAMESPACE::DivzeroExc ("Bad viewing frustum: "
352  "aspect ratio cannot be computed.");
353  }
354 
355  return rightMinusLeft / topMinusBottom;
356 }
357 
358 template<class T>
360 {
361  T rightPlusLeft = _right+_left;
362  T rightMinusLeft = _right-_left;
363 
364  T topPlusBottom = _top+_bottom;
365  T topMinusBottom = _top-_bottom;
366 
367  T farPlusNear = _farPlane+_nearPlane;
368  T farMinusNear = _farPlane-_nearPlane;
369 
370  if ((abs(rightMinusLeft) < 1 &&
371  abs(rightPlusLeft) > limits<T>::max() * abs(rightMinusLeft)) ||
372  (abs(topMinusBottom) < 1 &&
373  abs(topPlusBottom) > limits<T>::max() * abs(topMinusBottom)) ||
374  (abs(farMinusNear) < 1 &&
375  abs(farPlusNear) > limits<T>::max() * abs(farMinusNear)))
376  {
377  throw IEX_NAMESPACE::DivzeroExc ("Bad viewing frustum: "
378  "projection matrix cannot be computed.");
379  }
380 
381  if ( _orthographic )
382  {
383  T tx = -rightPlusLeft / rightMinusLeft;
384  T ty = -topPlusBottom / topMinusBottom;
385  T tz = -farPlusNear / farMinusNear;
386 
387  if ((abs(rightMinusLeft) < 1 &&
388  2 > limits<T>::max() * abs(rightMinusLeft)) ||
389  (abs(topMinusBottom) < 1 &&
390  2 > limits<T>::max() * abs(topMinusBottom)) ||
391  (abs(farMinusNear) < 1 &&
392  2 > limits<T>::max() * abs(farMinusNear)))
393  {
394  throw IEX_NAMESPACE::DivzeroExc ("Bad viewing frustum: "
395  "projection matrix cannot be computed.");
396  }
397 
398  T A = 2 / rightMinusLeft;
399  T B = 2 / topMinusBottom;
400  T C = -2 / farMinusNear;
401 
402  return Matrix44<T>( A, 0, 0, 0,
403  0, B, 0, 0,
404  0, 0, C, 0,
405  tx, ty, tz, 1.f );
406  }
407  else
408  {
409  T A = rightPlusLeft / rightMinusLeft;
410  T B = topPlusBottom / topMinusBottom;
411  T C = -farPlusNear / farMinusNear;
412 
413  T farTimesNear = -2 * _farPlane * _nearPlane;
414  if (abs(farMinusNear) < 1 &&
415  abs(farTimesNear) > limits<T>::max() * abs(farMinusNear))
416  {
417  throw IEX_NAMESPACE::DivzeroExc ("Bad viewing frustum: "
418  "projection matrix cannot be computed.");
419  }
420 
421  T D = farTimesNear / farMinusNear;
422 
423  T twoTimesNear = 2 * _nearPlane;
424 
425  if ((abs(rightMinusLeft) < 1 &&
426  abs(twoTimesNear) > limits<T>::max() * abs(rightMinusLeft)) ||
427  (abs(topMinusBottom) < 1 &&
428  abs(twoTimesNear) > limits<T>::max() * abs(topMinusBottom)))
429  {
430  throw IEX_NAMESPACE::DivzeroExc ("Bad viewing frustum: "
431  "projection matrix cannot be computed.");
432  }
433 
434  T E = twoTimesNear / rightMinusLeft;
435  T F = twoTimesNear / topMinusBottom;
436 
437  return Matrix44<T>( E, 0, 0, 0,
438  0, F, 0, 0,
439  A, B, C, -1,
440  0, 0, D, 0 );
441  }
442 }
443 
444 template<class T>
446 {
447  return (_nearPlane == _farPlane) ||
448  (_left == _right) ||
449  (_top == _bottom);
450 }
451 
452 template<class T>
453 Frustum<T> Frustum<T>::window(T l, T r, T t, T b) const
454 {
455  // move it to 0->1 space
456 
457  Vec2<T> bl = screenToLocal( Vec2<T>(l,b) );
458  Vec2<T> tr = screenToLocal( Vec2<T>(r,t) );
459 
460  return Frustum<T>(_nearPlane, _farPlane, bl.x, tr.x, tr.y, bl.y, _orthographic);
461 }
462 
463 
464 template<class T>
466 {
467  return Vec2<T>( _left + (_right-_left) * (1.f+s.x) / 2.f,
468  _bottom + (_top-_bottom) * (1.f+s.y) / 2.f );
469 }
470 
471 template<class T>
473 {
474  T leftPlusRight = _left - T (2) * p.x + _right;
475  T leftMinusRight = _left-_right;
476  T bottomPlusTop = _bottom - T (2) * p.y + _top;
477  T bottomMinusTop = _bottom-_top;
478 
479  if ((abs(leftMinusRight) < T (1) &&
480  abs(leftPlusRight) > limits<T>::max() * abs(leftMinusRight)) ||
481  (abs(bottomMinusTop) < T (1) &&
482  abs(bottomPlusTop) > limits<T>::max() * abs(bottomMinusTop)))
483  {
484  throw IEX_NAMESPACE::DivzeroExc
485  ("Bad viewing frustum: "
486  "local-to-screen transformation cannot be computed");
487  }
488 
489  return Vec2<T>( leftPlusRight / leftMinusRight,
490  bottomPlusTop / bottomMinusTop );
491 }
492 
493 template<class T>
495 {
496  Vec2<T> point = screenToLocal(p);
497  if (orthographic())
498  return Line3<T>( Vec3<T>(point.x,point.y, 0.0),
499  Vec3<T>(point.x,point.y,-1.0));
500  else
501  return Line3<T>( Vec3<T>(0, 0, 0), Vec3<T>(point.x,point.y,-_nearPlane));
502 }
503 
504 template<class T>
506 {
507  if (orthographic() || point.z == T (0))
508  return localToScreen( Vec2<T>( point.x, point.y ) );
509  else
510  return localToScreen( Vec2<T>( point.x * _nearPlane / -point.z,
511  point.y * _nearPlane / -point.z ) );
512 }
513 
514 template<class T>
515 T Frustum<T>::ZToDepth(long zval,long zmin,long zmax) const
516 {
517  int zdiff = zmax - zmin;
518 
519  if (zdiff == 0)
520  {
521  throw IEX_NAMESPACE::DivzeroExc
522  ("Bad call to Frustum::ZToDepth: zmax == zmin");
523  }
524 
525  if ( zval > zmax+1 ) zval -= zdiff;
526 
527  T fzval = (T(zval) - T(zmin)) / T(zdiff);
528  return normalizedZToDepth(fzval);
529 }
530 
531 template<class T>
533 {
534  T Zp = zval * 2.0 - 1;
535 
536  if ( _orthographic )
537  {
538  return -(Zp*(_farPlane-_nearPlane) + (_farPlane+_nearPlane))/2;
539  }
540  else
541  {
542  T farTimesNear = 2 * _farPlane * _nearPlane;
543  T farMinusNear = Zp * (_farPlane - _nearPlane) - _farPlane - _nearPlane;
544 
545  if (abs(farMinusNear) < 1 &&
546  abs(farTimesNear) > limits<T>::max() * abs(farMinusNear))
547  {
548  throw IEX_NAMESPACE::DivzeroExc
549  ("Frustum::normalizedZToDepth cannot be computed. The "
550  "near and far clipping planes of the viewing frustum "
551  "may be too close to each other");
552  }
553 
554  return farTimesNear / farMinusNear;
555  }
556 }
557 
558 template<class T>
559 long Frustum<T>::DepthToZ(T depth,long zmin,long zmax) const
560 {
561  long zdiff = zmax - zmin;
562  T farMinusNear = _farPlane-_nearPlane;
563 
564  if ( _orthographic )
565  {
566  T farPlusNear = 2*depth + _farPlane + _nearPlane;
567 
568  if (abs(farMinusNear) < 1 &&
569  abs(farPlusNear) > limits<T>::max() * abs(farMinusNear))
570  {
571  throw IEX_NAMESPACE::DivzeroExc
572  ("Bad viewing frustum: near and far clipping planes "
573  "are too close to each other");
574  }
575 
576  T Zp = -farPlusNear/farMinusNear;
577  return long(0.5*(Zp+1)*zdiff) + zmin;
578  }
579  else
580  {
581  // Perspective
582 
583  T farTimesNear = 2*_farPlane*_nearPlane;
584  if (abs(depth) < 1 &&
585  abs(farTimesNear) > limits<T>::max() * abs(depth))
586  {
587  throw IEX_NAMESPACE::DivzeroExc
588  ("Bad call to DepthToZ function: value of `depth' "
589  "is too small");
590  }
591 
592  T farPlusNear = farTimesNear/depth + _farPlane + _nearPlane;
593  if (abs(farMinusNear) < 1 &&
594  abs(farPlusNear) > limits<T>::max() * abs(farMinusNear))
595  {
596  throw IEX_NAMESPACE::DivzeroExc
597  ("Bad viewing frustum: near and far clipping planes "
598  "are too close to each other");
599  }
600 
601  T Zp = farPlusNear/farMinusNear;
602  return long(0.5*(Zp+1)*zdiff) + zmin;
603  }
604 }
605 
606 template<class T>
607 T Frustum<T>::screenRadius(const Vec3<T> &p, T radius) const
608 {
609  // Derivation:
610  // Consider X-Z plane.
611  // X coord of projection of p = xp = p.x * (-_nearPlane / p.z)
612  // Let q be p + (radius, 0, 0).
613  // X coord of projection of q = xq = (p.x - radius) * (-_nearPlane / p.z)
614  // X coord of projection of segment from p to q = r = xp - xq
615  // = radius * (-_nearPlane / p.z)
616  // A similar analysis holds in the Y-Z plane.
617  // So r is the quantity we want to return.
618 
619  if (abs(p.z) > 1 || abs(-_nearPlane) < limits<T>::max() * abs(p.z))
620  {
621  return radius * (-_nearPlane / p.z);
622  }
623  else
624  {
625  throw IEX_NAMESPACE::DivzeroExc
626  ("Bad call to Frustum::screenRadius: the magnitude of `p' "
627  "is too small");
628  }
629 
630  return radius * (-_nearPlane / p.z);
631 }
632 
633 template<class T>
634 T Frustum<T>::worldRadius(const Vec3<T> &p, T radius) const
635 {
636  if (abs(-_nearPlane) > 1 || abs(p.z) < limits<T>::max() * abs(-_nearPlane))
637  {
638  return radius * (p.z / -_nearPlane);
639  }
640  else
641  {
642  throw IEX_NAMESPACE::DivzeroExc
643  ("Bad viewing frustum: the near clipping plane is too "
644  "close to zero");
645  }
646 }
647 
648 template<class T>
650 {
651  //
652  // Plane order: Top, Right, Bottom, Left, Near, Far.
653  // Normals point outwards.
654  //
655 
656  if (! _orthographic)
657  {
658  Vec3<T> a( _left, _bottom, -_nearPlane);
659  Vec3<T> b( _left, _top, -_nearPlane);
660  Vec3<T> c( _right, _top, -_nearPlane);
661  Vec3<T> d( _right, _bottom, -_nearPlane);
662  Vec3<T> o(0,0,0);
663 
664  p[0].set( o, c, b );
665  p[1].set( o, d, c );
666  p[2].set( o, a, d );
667  p[3].set( o, b, a );
668  }
669  else
670  {
671  p[0].set( Vec3<T>( 0, 1, 0), _top );
672  p[1].set( Vec3<T>( 1, 0, 0), _right );
673  p[2].set( Vec3<T>( 0,-1, 0),-_bottom );
674  p[3].set( Vec3<T>(-1, 0, 0),-_left );
675  }
676  p[4].set( Vec3<T>(0, 0, 1), -_nearPlane );
677  p[5].set( Vec3<T>(0, 0,-1), _farPlane );
678 }
679 
680 
681 template<class T>
682 void Frustum<T>::planes(Plane3<T> p[6], const Matrix44<T> &M) const
683 {
684  //
685  // Plane order: Top, Right, Bottom, Left, Near, Far.
686  // Normals point outwards.
687  //
688 
689  Vec3<T> a = Vec3<T>( _left, _bottom, -_nearPlane) * M;
690  Vec3<T> b = Vec3<T>( _left, _top, -_nearPlane) * M;
691  Vec3<T> c = Vec3<T>( _right, _top, -_nearPlane) * M;
692  Vec3<T> d = Vec3<T>( _right, _bottom, -_nearPlane) * M;
693  if (! _orthographic)
694  {
695  double s = _farPlane / double(_nearPlane);
696  T farLeft = (T) (s * _left);
697  T farRight = (T) (s * _right);
698  T farTop = (T) (s * _top);
699  T farBottom = (T) (s * _bottom);
700  Vec3<T> e = Vec3<T>( farLeft, farBottom, -_farPlane) * M;
701  Vec3<T> f = Vec3<T>( farLeft, farTop, -_farPlane) * M;
702  Vec3<T> g = Vec3<T>( farRight, farTop, -_farPlane) * M;
703  Vec3<T> o = Vec3<T>(0,0,0) * M;
704  p[0].set( o, c, b );
705  p[1].set( o, d, c );
706  p[2].set( o, a, d );
707  p[3].set( o, b, a );
708  p[4].set( a, d, c );
709  p[5].set( e, f, g );
710  }
711  else
712  {
713  Vec3<T> e = Vec3<T>( _left, _bottom, -_farPlane) * M;
714  Vec3<T> f = Vec3<T>( _left, _top, -_farPlane) * M;
715  Vec3<T> g = Vec3<T>( _right, _top, -_farPlane) * M;
716  Vec3<T> h = Vec3<T>( _right, _bottom, -_farPlane) * M;
717  p[0].set( c, g, f );
718  p[1].set( d, h, g );
719  p[2].set( a, e, h );
720  p[3].set( b, f, e );
721  p[4].set( a, d, c );
722  p[5].set( e, f, g );
723  }
724 }
725 
728 
729 
731 
732 
733 #if defined _WIN32 || defined _WIN64
734  #ifdef _redef_near
735  #define near
736  #endif
737  #ifdef _redef_far
738  #define far
739  #endif
740 #endif
741 
742 #endif // INCLUDED_IMATHFRUSTUM_H
#define IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
GLfloat GLfloat GLfloat top
Definition: glew.h:15525
T left() const
Definition: ImathFrustum.h:119
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
T z
Definition: ImathVec.h:275
#define IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
void modifyNearAndFar(T nearPlane, T farPlane)
Definition: ImathFrustum.h:269
T right() const
Definition: ImathFrustum.h:120
GLint left
Definition: glcorearb.h:2004
void setOrthographic(bool)
Definition: ImathFrustum.h:298
const GLfloat * c
Definition: glew.h:16631
GLboolean GLboolean g
Definition: glcorearb.h:1221
T aspect() const
Definition: ImathFrustum.h:343
long DepthToZ(T depth, long zmin, long zmax) const
Definition: ImathFrustum.h:559
T fovy() const
Definition: ImathFrustum.h:337
T hither() const
Definition: ImathFrustum.h:116
T farPlane() const
Definition: ImathFrustum.h:117
static T max()
GLenum src
Definition: glcorearb.h:1792
GLdouble GLdouble t
Definition: glew.h:1403
GLfloat right
Definition: glew.h:15525
GLdouble l
Definition: glew.h:9164
Line3< T > projectScreenToRay(const Vec2< T > &) const
Definition: ImathFrustum.h:494
Vec2< T > localToScreen(const Vec2< T > &) const
Definition: ImathFrustum.h:472
T nearPlane() const
Definition: ImathFrustum.h:115
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glcorearb.h:475
const Frustum & operator=(const Frustum &)
Definition: ImathFrustum.h:222
virtual ~Frustum()
Definition: ImathFrustum.h:216
T x
Definition: ImathVec.h:77
T x
Definition: ImathVec.h:275
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T abs(T a)
Definition: ImathFun.h:55
T normalizedZToDepth(T zval) const
Definition: ImathFrustum.h:532
T yon() const
Definition: ImathFrustum.h:118
T y
Definition: ImathVec.h:77
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
Vec2< T > screenToLocal(const Vec2< T > &) const
Definition: ImathFrustum.h:465
GLint GLint bottom
Definition: glcorearb.h:2004
bool _orthographic
Definition: ImathFrustum.h:181
bool intersect(const Line3< T > &line, Vec3< T > &intersection) const
Definition: ImathPlane.h:187
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
bool orthographic() const
Definition: ImathFrustum.h:114
Frustum< double > Frustumd
Definition: ImathFrustum.h:727
T worldRadius(const Vec3< T > &p, T radius) const
Definition: ImathFrustum.h:634
T screenRadius(const Vec3< T > &p, T radius) const
Definition: ImathFrustum.h:607
GLfloat GLfloat p
Definition: glew.h:16656
Frustum< float > Frustumf
Definition: ImathFrustum.h:726
static T atan2(T x, T y)
Definition: ImathMath.h:97
T bottom() const
Definition: ImathFrustum.h:121
GLdouble n
Definition: glcorearb.h:2007
GLclampd zmax
Definition: glew.h:9063
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
T fovx() const
Definition: ImathFrustum.h:331
bool degenerate() const
Definition: ImathFrustum.h:445
GLfloat f
Definition: glcorearb.h:1925
T y
Definition: ImathVec.h:275
T top() const
Definition: ImathFrustum.h:122
Vec2< T > projectPointToScreen(const Vec3< T > &) const
Definition: ImathFrustum.h:505
T ZToDepth(long zval, long min, long max) const
Definition: ImathFrustum.h:515
bool operator!=(const Frustum< T > &src) const
Definition: ImathFrustum.h:251
Matrix44< T > projectionMatrix() const
Definition: ImathFrustum.h:359
void set(T nearPlane, T farPlane, T left, T right, T top, T bottom, bool ortho=false)
Definition: ImathFrustum.h:257
GLboolean r
Definition: glcorearb.h:1221
bool operator==(const Frustum< T > &src) const
Definition: ImathFrustum.h:237
void set(const Vec3< T > &normal, T distance)
Definition: ImathPlane.h:159
GLdouble s
Definition: glew.h:1395
void planes(Plane3< T > p[6]) const
Definition: ImathFrustum.h:649
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:556
Frustum< T > window(T left, T right, T top, T bottom) const
Definition: ImathFrustum.h:453
static T tan(T x)
Definition: ImathMath.h:100