OpendTect  6.3
geometry.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H. Lammertink
8  Date: 01/02/2000
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "gendefs.h"
14 #include "ranges.h"
15 #include "math2.h"
16 
17 namespace Geom
18 {
19 
24 template <class T>
25 mClass(Basic) Point2D
26 {
27 public:
28  Point2D(T xx=0,T yy=0);
29 
30  template <class TT>
31  Point2D<T>& setFrom(const Point2D<TT>&);
32 
33  template <class TT>
34  inline void setXY(TT xx,TT yy);
35  inline void setXY(T xx,T yy);
36  inline Point2D<T>& zero();
37  inline Point2D<T> operator-() const;
38 
39  inline T& operator[](int idx);
40  inline T operator[](int idx) const;
41 
42  inline bool operator==(const Point2D<T>&) const;
43  inline bool operator!=(const Point2D<T>&) const;
44  inline Point2D<T>& operator+=(T dist);
45  inline Point2D<T>& operator*=(T factor);
46  inline Point2D<T>& operator/=(T den);
47  inline Point2D<T>& operator+=(const Point2D<T>&);
48  inline Point2D<T>& operator-=(const Point2D<T>&);
49  inline Point2D<T> operator+(const Point2D<T>&) const;
50  inline Point2D<T> operator-(const Point2D<T>&) const;
51  inline Point2D<T> operator*(const T factor) const;
52  inline Point2D<T> operator/(const T den) const;
53  inline bool operator<(const Point2D<T>& crd) const;
54  inline bool operator>(const Point2D<T>& crd) const;
55 
56  inline void swapXY();
57 
58  inline T dot(const Point2D<T>&) const;
59  inline bool isDefined() const;
60  inline bool isUdf() const { return !isDefined(); }
61  inline Point2D<T> normalize() const;
62  template <class FT> FT abs() const;
63  inline T sqAbs() const;
65  template <class FT> FT distTo(const Point2D<T>&) const;
66  inline T sqDistTo(const Point2D<T>&) const;
68  template <class FT> FT angle(const Point2D<T>& from,
69  const Point2D<T>& to) const;
70  template <class FT> FT cosAngle(const Point2D<T>& from,
71  const Point2D<T>& to) const;
73 
74  BufferString toString(int nrdec=-1) const;
75  BufferString toPrettyString() const { return toString(2); }
76  bool fromString(const char*);
77 
78  static Point2D<T> udf() { return Point2D<T>(mUdf(T),mUdf(T)); }
79 
80  T x_;
81  T y_;
82 };
83 
84 
85 template <class T> inline
86 Point2D<T> operator*( int f, const Point2D<T>& b )
87 { return Point2D<T>( b.x_*f, b.y_*f ); }
88 
89 template <class T> inline
90 Point2D<T> operator*( double f, const Point2D<T>& b )
91 { return Point2D<T>( b.x_*f, b.y_*f ); }
92 
93 template <class T> inline
94 Point2D<T> operator*( float f, const Point2D<T>& b )
95 { return Point2D<T>( b.x_*f, b.y_*f ); }
96 
97 
103 template <class T>
104 mClass(Basic) Point3D
105 {
106 public:
107  Point3D(const Point2D<T>&,T);
108  Point3D(T xx=0,T yy=0, T zz=0);
109 
110  template <class TT>
111  Point3D<T>& setFrom(const Point3D<TT>&);
112 
113  template <class TT>
114  inline void setXY(TT xx,TT yy);
115  inline void setXY(T xx,T yy);
116  inline void setXY(const Point2D<T>&);
117  inline Point2D<T> getXY() const { return Point2D<T>( x_, y_ ); }
118  inline Point3D<T>& zero();
119  inline Point3D<T> operator-() const;
120 
121  inline T& operator[](int idx);
122  inline T operator[](int idx) const;
123 
124  inline bool operator==(const Point3D<T>&) const;
125  inline bool operator!=(const Point3D<T>&) const;
126  inline bool isSameAs( const Point3D<T>& pos,
127  const Point3D<T>& eps ) const;
128 
129  inline Point3D<T>& operator+=(T dist);
130  inline Point3D<T>& operator*=(T factor);
131  inline Point3D<T>& operator/=(T den);
132  inline Point3D<T>& operator+=(const Point3D<T>&);
133  inline Point3D<T>& operator-=(const Point3D<T>&);
134  inline Point3D<T> operator+(const Point3D<T>&) const;
135  inline Point3D<T> operator-(const Point3D<T>&) const;
136  inline Point3D<T> operator*(const T factor) const;
137  inline Point3D<T> operator/(const T den) const;
138 
139  inline Point3D<T> scaleBy(const Point3D<T>& factor) const;
140  inline Point3D<T> unScaleBy(const Point3D<T>& denominator) const;
141 
142  inline T dot(const Point3D<T>&) const;
143  inline Point3D<T> cross(const Point3D<T>&) const;
144  inline Point3D<T> normalize() const;
146  inline bool isDefined() const;
147  inline bool isUdf() const { return !isDefined(); }
148  template <class FT> FT abs() const;
149  inline T sqAbs() const;
151  template <class FT> FT distTo(const Point3D<T>&) const;
152  inline T sqDistTo(const Point3D<T>&) const;
154 
155  template <class FT> FT xyDistTo(const Point3D<T>&) const;
157  inline T xySqDistTo(const Point3D<T>&) const;
159  template <class FT> FT xyDistTo(const Point2D<T>&) const;
161  inline T xySqDistTo(const Point2D<T>&) const;
163 
164  static Point3D<T> udf();
165 
166  T x_;
167  T y_;
168  T z_;
169 };
170 
171 template <class T>
172 inline Point3D<T> operator*( int f, const Point3D<T>& b )
173 { return Point3D<T>(b.x_*f, b.y_*f, b.z_*f ); }
174 
175 template <class T>
176 inline Point3D<T> operator*( double f, const Point3D<T>& b )
177 { return Point3D<T>(b.x_*f, b.y_*f, b.z_*f ); }
178 
179 
180 template <class T>
181 inline Point3D<T> operator*( float f, const Point3D<T>& b )
182 { return Point3D<T>(b.x_*f, b.y_*f, b.z_*f ); }
183 
184 
189 template <class T>
191 {
192 public:
193  Size2D( T w = 0 , T h = 0 );
194 
195  inline bool operator==(const Size2D<T>&) const;
196  inline bool operator!=(const Size2D<T>&) const;
197 
198  inline T width() const;
199  inline T height() const;
200  inline void setWidth(T val);
201  inline void setHeight(T val);
202  inline void set(T w,T h);
203  inline Size2D<T> operator+(T val) const;
204  inline Size2D<T>& operator+=(T val);
205  inline Size2D<T>& operator-=(T val);
206  inline Size2D<T>& operator+=(const Size2D<T>&);
207  inline Size2D<T>& operator-=(const Size2D<T>&);
208 
209 protected:
210 
213 
214 };
215 
216 
227 template <class T>
229 {
230 public:
231  Rectangle(T l=0,T t=0,T r=0,T b=0) ;
232  Rectangle(const Point2D<T>& tl,const Point2D<T>& br);
233  Rectangle(const Point2D<T>& tl,const Size2D<T>& sz);
234 
235  inline bool operator==(const Rectangle<T>&) const;
236  inline bool operator!=(const Rectangle<T>&) const;
237 
238  inline Point2D<T> topLeft() const;
239  inline Point2D<T> topRight() const;
240  inline Point2D<T> bottomLeft() const;
241  inline Point2D<T> bottomRight() const;
242  inline Point2D<T> centre() const;
243  inline void setTopLeft(Point2D<T>);
244  inline void setBottomRight(Point2D<T>);
245  inline void setTopRight(Point2D<T>);
246  inline void setBottomLeft(Point2D<T>);
247  inline void setTopBottom(const Interval<T>&);
248  inline void setLeftRight(const Interval<T>&);
249 
250  inline Point2D<T> moveInside(const Point2D<T>&) const;
251 
252  inline void include(const Rectangle<T>&);
253  inline void include(const Point2D<T>&);
254  inline void limitTo(const Rectangle<T>&);
255  inline void translate(const Point2D<T>&);
256 
257  inline bool operator >(const Rectangle<T>&) const;
258 
259  inline T width() const;
260  inline T height() const;
261 
262  inline T left() const;
263  inline T top() const;
264  inline T right() const;
265  inline T bottom() const;
266  inline void setLeft(T val);
267  inline void setTop(T val);
268  inline void setRight(T val);
269  inline void setBottom(T val);
270 
271  bool checkCorners(bool leftislow=true,
272  bool topislow=true) const;
274  void sortCorners(bool leftislow=true,bool topislow=true);
275  inline Size2D<T> size() const;
276  inline void zero();
277  inline bool isDefined() const;
278 
279  inline Rectangle<T>& operator+=(const Point2D<T>&); // shifts
280  inline Rectangle<T>& operator-=(const Point2D<T>&);
281  inline Rectangle<T>& operator+=(const Size2D<T>&); // keeps topleft in place
282  inline Rectangle<T>& operator-=(const Size2D<T>&);
283 
284  inline void swapHor();
285  inline void swapVer();
286 
287  inline bool revX() const;
288  inline bool revY() const;
289 
290 protected:
291 
294 
295 };
296 
297 
306 template <class T>
307 mClass(Basic) PixRectangle : public Rectangle<T>
308 {
309 public:
310  PixRectangle(T l=0 , T t=0, T r=0 , T b=0 ) ;
311  PixRectangle(const Point2D<T>& tl,const Point2D<T>& br);
312  PixRectangle(const Point2D<T>& tl,const Size2D<T>& sz);
313  PixRectangle(const Rectangle<T>&);
314 
315  inline bool isInside(const Point2D<T>&) const;
316  inline bool isOutside(const Point2D<T>&) const;
317  inline bool isOnSide(const Point2D<T>&) const;
318  inline bool contains(const Point2D<T>&) const;
319  inline bool contains(const PixRectangle<T>&) const;
320  inline bool isInside(const PixRectangle<T>&) const;
321 
322  inline PixRectangle<T> grownBy(double sidesincreasebyfactor=1) const;
323 
324 protected:
325 
326  inline bool xOutside(T) const;
327  inline bool yOutside(T) const;
328 };
329 
330 
339 template <class T>
340 mClass(Basic) PosRectangle : public Rectangle<T>
341 {
342 public:
343  PosRectangle( T l = 0 , T t = 0, T r = 0 , T b = 0 )
344  : Rectangle<T>(l,t,r,b) {}
346  : Rectangle<T>(tl,br) {}
347 
348  inline bool isOutside( const Point2D<T>& p, T eps ) const
349  { return xOutside(p.x_,eps) || yOutside(p.y_,eps); }
350  inline bool isInside(const Point2D<T>&,T eps) const;
351  inline bool isOnSide(const Point2D<T>& p,T eps) const;
352 
353  inline bool contains( const Point2D<T>& p, T eps ) const
354  { return !isOutside(p,eps); }
355 
356  inline bool contains( const PosRectangle<T>& other, T eps ) const
357  {
358  return contains(other.topleft_,eps)
359  && contains(other.bottomright_,eps);
360  }
361  inline bool isInside( const PosRectangle<T>& other, T eps ) const
362  {
363  return other.isInside(this->topleft_,eps)
364  && other.isInside(this->bottomright_,eps);
365  }
366 
367  inline PosRectangle<T> grownBy(T sidesincreasebyfactor=1) const;
368 
369 protected:
370 
371  inline bool xOutside(T,T) const;
372  inline bool yOutside(T,T) const;
373 };
374 
375 
376 template <class T> inline
377 Point2D<T>::Point2D ( T xx , T yy )
378  : x_(xx), y_(yy)
379 {}
380 
381 template <class T> template <class TT> inline
383 { x_=(T) a.x_; y_=(T) a.y_; return *this;}
384 
385 
386 template <class T> inline
387 void Point2D<T>::setXY( T xx, T yy )
388 { x_ = xx ; y_ = yy; }
389 
390 template <class T> template <class TT> inline
391 void Point2D<T>::setXY( TT xx, TT yy )
392 { x_ = (T)xx; y_ = (T)yy; }
393 
394 template <class T> inline
396 { x_ = y_ = 0; return *this; }
397 
398 template <class T> inline
400 { return Point2D<T>( -x_, -y_ ); }
401 
402 
403 template <class T> inline
405 { return idx ? y_ : x_; }
406 
407 
408 template <class T> inline
409 T Point2D<T>::operator[]( int idx ) const
410 { return idx ? y_ : x_; }
411 
412 
413 template <class T> inline
414 bool Point2D<T>::operator ==( const Point2D<T>& p ) const
415 { return p.x_ == x_ && p.y_ == y_; }
416 
417 
418 template <class T> inline
419 bool Point2D<T>::operator<(const Point2D<T>& crd) const
420 { return x_<crd.x_ || (x_==crd.x_ && y_<crd.y_); }
421 
422 template <class T> inline
423 bool Point2D<T>::operator>(const Point2D<T>& crd) const
424 { return x_>crd.x_ || (x_==crd.x_ && y_>crd.y_); }
425 
426 
427 template <class T> inline
428 bool Point2D<T>::operator !=( const Point2D<T>& p ) const
429 { return !(*this==p); }
430 
431 template <class T> inline
433 { x_ += dist; y_ += dist; return *this; }
434 
435 
436 template <class T> inline
438 { x_ *= factor; y_ *= factor; return *this; }
439 
440 
441 template <class T> inline
443 { x_ /= den; y_ /= den; return *this; }
444 
445 
446 template <class T> inline
448 { x_ += p.x_; y_ += p.y_; return *this; }
449 
450 
451 template <class T> inline
453 { x_ -= p.x_; y_ -= p.y_; return *this; }
454 
455 
456 template <class T> inline
458 { return Point2D<T>(x_+p.x_,y_+p.y_); }
459 
460 
461 template <class T> inline
463 { return Point2D<T>(x_-p.x_,y_-p.y_); }
464 
465 
466 template <class T> inline
467 Point2D<T> Point2D<T>::operator *( const T factor ) const
468 { return Point2D<T>(factor*x_,factor*y_); }
469 
470 
471 template <class T> inline
472 Point2D<T> Point2D<T>::operator /( const T den ) const
473 { return Point2D<T>(x_/den,y_/den); }
474 
475 
476 template <class T> inline
478 { return !mIsUdf(x_) && !mIsUdf(y_); }
479 
480 
481 template <class T>
482 inline T Point2D<T>::dot(const Point2D<T>& b) const
483 { return x_*b.x_ + y_*b.y_; }
484 
485 
486 template <class T> inline
488 {
489  Swap( x_, y_ );
490 }
491 
492 
493 template <> inline
495 {
496  BufferString res;
497  if (isUdf())
498  res.set("<undef>");
499  else
500  {
501  res.set("(");
502  if (nrdec<0)
503  {
504  res.add(x_).add(",").add(y_);
505  }
506  else
507  {
508  BufferString xstr = ::toString(x_, nrdec);
509  BufferString ystr = ::toString(y_, nrdec);
510  res.add(xstr).add(",").add(ystr);
511  }
512 
513  res.add(")");
514  }
515 
516  return res;
517 }
518 
519 
520 template <> inline
522 {
523  BufferString res;
524  if (isUdf())
525  res.set("<undef>");
526  else
527  {
528  res.set("(");
529  if (nrdec<0)
530  {
531  res.add(x_).add(",").add(y_);
532  }
533  else
534  {
535  BufferString xstr = ::toString(x_, nrdec);
536  BufferString ystr = ::toString(y_, nrdec);
537  res.add(xstr).add(",").add(ystr);
538  }
539 
540  res.add(")");
541  }
542 
543  return res;
544 }
545 
546 
547 template <class T> inline
549 {
550  BufferString res;
551  if ( isUdf() )
552  res.set( "<undef>" );
553  else
554  {
555  res.set( "(" );
556  res.add( x_ ).add( "," ).add( y_ );
557  res.add( ")" );
558  }
559 
560  return res;
561 }
562 
563 
564 template <class T> inline
565 bool Point2D<T>::fromString( const char* s )
566 {
567  if ( !s || !*s ) return false;
568  if ( *s == '<' )
569  { *this = udf(); return true; }
570 
571  BufferString str( s );
572  char* ptrx = str.getCStr(); mSkipBlanks( ptrx );
573  if ( *ptrx == '(' ) ptrx++;
574  char* ptry = firstOcc( ptrx, ',' );
575  if ( !ptry ) return false;
576  *ptry++ = '\0';
577  if ( !*ptry ) return false;
578  char* ptrend = firstOcc( ptry, ')' );
579  if ( ptrend ) *ptrend = '\0';
580 
581  return getFromString( x_, ptrx, mUdf(T) ) &&
582  getFromString( y_, ptry, mUdf(T) );
583 }
584 
585 template <>
587 {
588  const double sqabsval = sqAbs();
589  if (sqabsval == 0)
590  return *this;
591 
592  return *this / Math::Sqrt(sqabsval);
593 }
594 
595 
596 template <>
598 {
599  const float sqabsval = sqAbs();
600  if (sqabsval == 0)
601  return *this;
602 
603  return *this / Math::Sqrt(sqabsval);
604 }
605 
606 template <class T>
608 {
609  const T sqabsval = sqAbs();
610  if ( sqabsval == 0 )
611  return *this;
612 
613  const float absval = Math::Sqrt((float)sqabsval);
614  return Point2D<T>((T) ( ((float) x_) / absval), (T) (((float) y_) / absval));
615 }
616 
617 
618 template <class T> template <class FT> inline
619 FT Point2D<T>::abs() const
620 { return ::Math::Sqrt( (FT)sqAbs() ); }
621 
622 
623 template <class T> inline
625 { return x_*x_ + y_*y_; }
626 
627 
628 template <class T> template <class FT> inline
629 FT Point2D<T>::distTo( const Point2D<T>& pt ) const
630 { return ::Math::Sqrt( (FT)sqDistTo(pt) ); }
631 
632 
633 template <class T> inline
634 T Point2D<T>::sqDistTo( const Point2D<T>& pt ) const
635 {
636  const T xdiff = x_-pt.x_;
637  const T ydiff = y_-pt.y_;
638  return xdiff*xdiff + ydiff*ydiff;
639 }
640 
641 
642 template <class T> template <class FT> inline
643 FT Point2D<T>::cosAngle( const Point2D<T>& from, const Point2D<T>& to ) const
644 {
645  const T rsq = sqDistTo( from );
646  const T lsq = sqDistTo( to );
647  if ( !rsq || !lsq ) return 1;
648 
649  const T osq = from.sqDistTo( to );
650  return (rsq + lsq - osq) / (2 * Math::Sqrt((FT)rsq) * Math::Sqrt((FT)lsq));
651 }
652 
653 
654 template <class T> template <class FT> inline
655 FT Point2D<T>::angle( const Point2D<T>& from, const Point2D<T>& to ) const
656 {
657  const FT cosang = cosAngle<FT>( from, to );
658  if ( cosang >= 1 ) return 0;
659  if ( cosang <= -1 ) return M_PI;
660 
661  const Point2D<T>& vec1 = from - *this;
662  const Point2D<T>& vec2 = to - *this;
663  const T det = vec1.x_ * vec2.y_ - vec1.y_ * vec2.x_;
664 
665  const FT ang = Math::ACos( cosang );
666  return det<0 ? 2*M_PI - ang : ang;
667 }
668 
669 
670 template <class T> inline
672  : x_( p.x_ )
673  , y_( p.y_ )
674  , z_( z )
675 {}
676 
677 
678 template <class T> inline
679 Point3D<T>::Point3D( T x, T y, T z)
680  : x_( x )
681  , y_( y )
682  , z_( z )
683 {}
684 
685 
686 template <class T> template <class TT> inline
688 { x_=(T)a.x_; y_=(T)a.y_; z_=(T)a.z_; return *this;}
689 
690 
691 template <class T> template <class TT> inline
692 void Point3D<T>::setXY( TT xx, TT yy )
693 { x_ = (T)xx; y_ = (T)yy; }
694 
695 
696 template <class T> inline
697 void Point3D<T>::setXY( T xx, T yy )
698 { x_ = xx ; y_ = yy; }
699 
700 
701 template <class T> inline
703 { x_ = p.x_ ; y_ = p.y_; }
704 
705 template <class T> inline
707 {
708  x_ = y_ = z_ = 0;
709  return *this;
710 }
711 
712 
713 
714 template <class T> inline
715 bool Point3D<T>::operator==( const Point3D<T>& b ) const
716 {
717  const T dx = x_-b.x_;
718  const T dy = y_-b.y_;
719  const T dz = z_-b.z_;
720  return mIsZero(dx,mDefEps) && mIsZero(dy,mDefEps) && mIsZero(dz,mDefEps);
721 }
722 
723 
724 template <class T>
725 inline bool Point3D<T>::operator!=( const Point3D<T>& b ) const
726 {
727  return !(b==*this);
728 }
729 
730 
731 
732 template <class T> inline
734  const Point3D<T>& eps ) const
735 {
736  return fabs(x_-pos.x_)<eps.x_ &&
737  fabs(y_-pos.y_)<eps.y_ &&
738  fabs(z_-pos.z_)<eps.z_;
739 }
740 
741 
742 template <class T> inline
744 {
745  if ( !idx )
746  return x_;
747  if ( idx==1 )
748  return y_;
749  return z_;
750 }
751 
752 template <class T> inline
753 T Point3D<T>::operator[]( int idx ) const
754 {
755  if ( !idx )
756  return x_;
757  if ( idx==1 )
758  return y_;
759  return z_;
760 }
761 
762 
763 template <class T> inline
765 {
766  return !Values::isUdf(x_) && !Values::isUdf(y_) && !Values::isUdf(z_);
767 }
768 
769 
770 template <class T>
772 {
773  return Point3D<T>( x_+p.x_, y_+p.y_, z_+p.z_ );
774 }
775 
776 
777 template <class T>
779 {
780  return Point3D<T>( x_-p.x_, y_-p.y_, z_-p.z_ );
781 }
782 
783 template <class T>
785 {
786  return Point3D<T>( -x_, -y_, -z_ );
787 }
788 
789 template <class T>
790 inline Point3D<T> Point3D<T>::operator*( T factor ) const
791 { return Point3D<T>( x_*factor, y_*factor, z_*factor ); }
792 
793 
794 template <class T>
795 inline Point3D<T> Point3D<T>::operator/( T denominator ) const
796 { return Point3D<T>( x_/denominator, y_/denominator, z_/denominator ); }
797 
798 
799 template <class T>
800 inline Point3D<T> Point3D<T>::scaleBy( const Point3D<T>& factor ) const
801 { return Point3D<T>( x_*factor.x_, y_*factor.y_, z_*factor.z_ ); }
802 
803 
804 template <class T>
805 inline Point3D<T>
806 Point3D<T>::unScaleBy( const Point3D<T>& denominator ) const
807 { return Point3D<T>( x_/denominator.x_,
808  y_/denominator.y_,
809  z_/denominator.z_ );
810 }
811 
812 
813 template <class T> inline
815 {
816  x_ += dist; y_ += dist; z_ += dist; return *this;
817 }
818 
819 template <class T> inline
821 {
822  x_ += p.x_; y_ += p.y_; z_ += p.z_;
823  return *this;
824 }
825 
826 
827 template <class T> inline
829 {
830  x_ -= p.x_; y_ -= p.y_; z_ -= p.z_;
831  return *this;
832 }
833 
834 
835 template <class T> inline
837 {
838  x_ *= factor; y_ *= factor; z_ *= factor;
839  return *this;
840 }
841 
842 
843 template <class T> inline
845 {
846  x_ /= denominator; y_ /= denominator; z_ /= denominator;
847  return *this;
848 }
849 
850 
851 template <class T> inline
852 T Point3D<T>::dot(const Point3D<T>& b) const
853 { return x_*b.x_ + y_*b.y_ + z_*b.z_; }
854 
855 
856 
857 template <class T> inline
859 { return Point3D<T>( y_*b.z_-z_*b.y_, z_*b.x_-x_*b.z_, x_*b.y_-y_*b.x_ ); }
860 
861 
862 template <class T> inline
864 {
865  const T sqabsval = sqAbs();
866  if ( sqabsval == 0 )
867  return *this;
868 
869  return *this / Math::Sqrt( sqabsval );
870 }
871 
872 
873 template <class T> template <class FT> inline
874 FT Point3D<T>::abs() const
875 { return ::Math::Sqrt( (FT) sqAbs() ); }
876 
877 
878 template <class T> inline
880 {
881  return x_*x_ + y_*y_ + z_*z_;
882 }
883 
884 
885 template <class T> template <class FT> inline
886 FT Point3D<T>::distTo( const Point3D<T>& pt ) const
887 { return ::Math::Sqrt( (FT)sqDistTo(pt) ); }
888 
889 
890 template <class T> inline
891 T Point3D<T>::sqDistTo( const Point3D<T>& pt ) const
892 {
893  const T xdiff = x_-pt.x_;
894  const T ydiff = y_-pt.y_;
895  const T zdiff = z_-pt.z_;
896  return xdiff*xdiff + ydiff*ydiff + zdiff*zdiff;
897 }
898 
899 
900 template <class T> template <class FT> inline
901 FT Point3D<T>::xyDistTo( const Point3D<T>& pt ) const
902 { return ::Math::Sqrt( (FT)xySqDistTo(pt) ); }
903 
904 
905 template <class T> inline
906 T Point3D<T>::xySqDistTo( const Point3D<T>& pt ) const
907 {
908  return xySqDistTo( pt.getXY() );
909 }
910 
911 template <class T> template <class FT> inline
912 FT Point3D<T>::xyDistTo( const Point2D<T>& pt ) const
913 { return ::Math::Sqrt( (FT)xySqDistTo(pt) ); }
914 
915 
916 template <class T> inline
917 T Point3D<T>::xySqDistTo( const Point2D<T>& pt ) const
918 {
919  return getXY().sqDistTo( pt );
920 }
921 
922 
923 template <class T> inline
925 { return Point3D<T>(mUdf(T),mUdf(T), mUdf(T)); }
926 
927 
928 template <class T> inline
929 Size2D<T>::Size2D( T w , T h )
930 { width_=w; height_=h; }
931 
932 
933 template <class T> inline
934 bool Size2D<T>::operator ==( const Size2D<T>& s ) const
935 { return s.width_ == width_ && s.height_ == height_; }
936 
937 
938 template <class T> inline
939 bool Size2D<T>::operator !=( const Size2D<T>& s ) const
940 { return s.width_ != width_ || s.height_ != height_; }
941 
942 
943 template <class T> inline
945 { return width_; }
946 
947 
948 template <class T> inline
950 { return height_; }
951 
952 
953 template <class T> inline
954 void Size2D<T>::setWidth( T val )
955 { width_ = val; }
956 
957 
958 template <class T> inline
959 void Size2D<T>::setHeight( T val )
960 { height_ = val; }
961 
962 
963 template <class T> inline
964 void Size2D<T>::set( T w, T h )
965 { width_ = w; height_ = h; }
966 
967 
968 template <class T> inline
970 { return Size2D<T>( width_+val, height_+val); }
971 
972 
973 template <class T> inline
975 { width_ += val; height_ += val; return *this; }
976 
977 
978 template <class T> inline
980 { width_ -= val; height_ -= val; return *this; }
981 
982 
983 template <class T> inline
985 { width_+=s.width_; height_+=s.height_; return *this; }
986 
987 
988 template <class T> inline
990 {
991  width_ -= s.width_; height_ -= s.height_;
992  if ( width_<0 ) width_ = -width_;
993  if ( height_<0 ) height_ = -height_;
994  return *this;
995 }
996 
997 
998 template <class T> inline
999 Rectangle<T>::Rectangle( T l, T t, T r, T b )
1000  : topleft_( Point2D<T>(l,t))
1001  , bottomright_( Point2D<T>(r,b) )
1002 {}
1003 
1004 
1005 template <class T> inline
1007  : topleft_( tl ) , bottomright_( br )
1008 {}
1009 
1010 
1011 template <class T> inline
1013  : topleft_( tl ) , bottomright_( tl.x_+sz.width(), tl.y_+sz.height() )
1014 {}
1015 
1016 
1017 template <class T> inline
1019 { return r.topleft_ == topleft_ && r.bottomright_ == bottomright_; }
1020 
1021 
1022 template <class T> inline
1024 { return r.topleft_ != topleft_ || r.bottomright_ != bottomright_; }
1025 
1026 
1027 template <class T> inline
1029 { return topleft_; }
1030 
1031 
1032 template <class T> inline
1034 { return Point2D<T>(right(),top()); }
1035 
1036 
1037 template <class T> inline
1039 { return Point2D<T>(left(),bottom()); }
1040 
1041 
1042 template <class T> inline
1044 { return bottomright_; }
1045 
1046 
1047 template <class T> inline
1049 {
1050  return Point2D<T>( (topleft_.x_+bottomright_.x_)/2,
1051  (topleft_.y_+bottomright_.y_)/2 );
1052 }
1053 
1054 
1055 template <class T> inline
1057 { topleft_ = tl; }
1058 
1059 
1060 template <class T> inline
1062 { bottomright_ = br; }
1063 
1064 
1065 template <class T> inline
1067 { topleft_.y_ = tr.y_; bottomright_.x_ = tr.x_; }
1068 
1069 
1070 template <class T> inline
1072 { topleft_.x_ = tr.x_; bottomright_.y_ = tr.y_; }
1073 
1074 
1075 template <class T> inline
1077 { topleft_.y_ = rg.start; bottomright_.y_ = rg.stop; }
1078 
1079 
1080 template <class T> inline
1082 { topleft_.x_ = rg.start; bottomright_.x_ = rg.stop; }
1083 
1084 
1085 template <class T> inline
1087 {
1088  Point2D<T> res = pt;
1089 
1090  res.x_ = mMAX( res.x_, mMIN( left(), right() ) );
1091  res.x_ = mMIN( res.x_, mMAX( left(), right() ) );
1092  res.y_ = mMAX( res.y_, mMIN( bottom(), top() ) );
1093  res.y_ = mMIN( res.y_, mMAX( bottom(), top() ) );
1094 
1095  return res;
1096 }
1097 
1098 
1099 template <class T> inline
1101 { return revX() ? left()-right() : right() - left(); }
1102 
1103 
1104 template <class T> inline
1106 { return revY() ? bottom()-top() : top()-bottom(); }
1107 
1108 
1109 template <class T> inline
1111 { return topleft_.x_; }
1112 
1113 
1114 template <class T> inline
1116 { return topleft_.y_; }
1117 
1118 
1119 template <class T> inline
1121 { return bottomright_.x_; }
1122 
1123 
1124 template <class T> inline
1126 { return bottomright_.y_; }
1127 
1128 
1129 template <class T> inline
1131 { topleft_.x_ = val; }
1132 
1133 
1134 template <class T> inline
1136 { topleft_.y_ = val; }
1137 
1138 
1139 template <class T> inline
1141 { bottomright_.x_ = val; }
1142 
1143 
1144 template <class T> inline
1146 { bottomright_.y_ = val; }
1147 
1148 
1149 template <class T> inline
1150 bool Rectangle<T>::checkCorners( bool leftislow, bool topislow ) const
1151 {
1152  if ( leftislow == (left() > right()) ) return false;
1153  if ( topislow == (top() > bottom()) ) return false;
1154 
1155  return true;
1156 }
1157 
1158 
1159 template <class T> inline
1160 void Rectangle<T>::sortCorners( bool leftislow, bool topislow )
1161 {
1162  if ( leftislow == (left() > right()) ) swapHor();
1163  if ( topislow == (top() > bottom()) ) swapVer();
1164 }
1165 
1166 
1167 template <class T> inline
1169 { return Size2D<T>( width(), height() ); }
1170 
1171 
1172 template <class T> inline
1174 { topleft_.zero(); bottomright_.zero(); }
1175 
1176 
1177 template <class T> inline
1179 { return topleft_.isDefined() && bottomright_.isDefined(); }
1180 
1181 
1182 template <class T> inline
1184 { topleft_ += p; bottomright_ += p; return *this; }
1185 
1186 
1187 template <class T> inline
1189 { topleft_ -= p; bottomright_ -= p; return *this; }
1190 
1191 
1192 template <class T> inline
1194 { bottomright_.x_ += sz.width(); bottomright_.y_ += sz.height(); return *this; }
1195 
1196 
1197 template <class T> inline
1199 { bottomright_.x_ -= sz.width(); bottomright_.y_ -= sz.height(); return *this; }
1200 
1201 
1202 template <class T> inline
1204 {
1205  T t = topleft_.x_;
1206  topleft_.x_ = bottomright_.x_;
1207  bottomright_.x_ = t;
1208 }
1209 
1210 
1211 template <class T> inline
1213 {
1214  T t = topleft_.y_;
1215  topleft_.y_ = bottomright_.y_;
1216  bottomright_.y_ = t;
1217 }
1218 
1219 
1220 template <class T> inline
1222 { return left() > right(); }
1223 
1224 
1225 template <class T> inline
1227 { return bottom() > top(); }
1228 
1229 
1230 template <class T>
1231 inline bool PixRectangle<T>::xOutside( T x ) const
1232 {
1233  return this->revX() ? (x > this->left() || x < this->right())
1234  : (x < this->left() || x > this->right());
1235 }
1236 
1237 
1238 template <class T>
1239 inline bool PixRectangle<T>::yOutside( T y ) const
1240 {
1241  return this->revY() ? (y > this->bottom() || y < this->top())
1242  : (y < this->bottom() || y > this->top());
1243 }
1244 
1245 
1246 template <class T>
1247 inline bool PixRectangle<T>::isOnSide( const Point2D<T>& pt ) const
1248 {
1249  return (pt.x_ == this->left() || pt.x_ == this->right())
1250  && (pt.y_ == this->top() || pt.y_ == this->bottom());
1251 }
1252 
1253 
1254 template <class T>
1255 inline bool PosRectangle<T>::xOutside( T x, T eps ) const
1256 {
1257  return this->revX() ? (x-this->left() > eps || this->right()-x > eps)
1258  : (this->left()-x > eps || x-this->right() > eps);
1259 }
1260 
1261 
1262 template <class T>
1263 inline bool PosRectangle<T>::yOutside( T y, T eps ) const
1264 {
1265  return this->revY() ? (this->top()-y > eps || y-this->bottom() > eps)
1266  : (y-this->top() > eps || this->bottom()-y > eps);
1267 }
1268 
1269 
1270 template <class T>
1271 inline bool PosRectangle<T>::isOnSide( const Point2D<T>& pt, T eps ) const
1272 {
1273  if ( xOutside(pt.x_) || yOutside(pt.y_) ) return false;
1274  return fabs(pt.x_-this->left()) < eps || fabs(pt.x_-this->right()) < eps
1275  || fabs(pt.y_-this->top()) < eps || fabs(pt.y_-this->bottom()) < eps;
1276 }
1277 
1278 
1279 template <class T>
1280 inline bool PosRectangle<T>::isInside( const Point2D<T>& pt, T eps ) const
1281 {
1282  return (this->revX()
1283  ? (this->left()-pt.x_>eps && pt.x_-this->right()>eps)
1284  : (pt.x_-this->left()>eps && this->right()-pt.x_>eps))
1285  && (this->revY()
1286  ? (pt.y_-this->bottom()<-eps && this->top()-pt.y_<-eps)
1287  : (this->bottom()-pt.y_<-eps && pt.y_-this->top()<-eps));
1288 }
1289 
1290 
1291 template <class T>
1292 inline T iwiderPos( int x1, int x2, double f )
1293 { return (T)mNINT32(x1 + f * (x1 - x2)); }
1294 
1295 
1296 template <class T>
1297 inline T fwiderPos( T x1, T x2, T f )
1298 { return x1 + f * (x1 - x2); }
1299 
1300 
1301 template <class T>
1302 PixRectangle<T>::PixRectangle( T l , T t, T r, T b )
1303  : Rectangle<T>(l,t,r,b)
1304 {}
1305 
1306 
1307 template <class T>
1309  : Rectangle<T>(tl,br)
1310 {}
1311 
1312 
1313 template <class T>
1315  : Rectangle<T>(tl,sz)
1316 {}
1317 
1318 
1319 template <class T>
1321  : Rectangle<T>( r )
1322 {}
1323 
1324 
1325 template <class T> inline
1327 { return !xOutside( p.x_ ) && !yOutside( p.y_ ) && !isOnSide( p ); }
1328 
1329 
1330 template <class T> inline
1332 { return xOutside(p.x_) || yOutside(p.y_); }
1333 
1334 
1335 template <class T> inline
1337 { return !isOutside(p); }
1338 
1339 
1340 template <class T> inline
1341 bool PixRectangle<T>::contains( const PixRectangle<T>& other ) const
1342 {
1343  return contains(other.topleft_) && contains(other.bottomright_);
1344 }
1345 
1346 
1347 template <class T> inline
1348 bool PixRectangle<T>::isInside( const PixRectangle<T>& other ) const
1349 {
1350  return other.isInside(this->topleft_) && other.isInside(this->bottomright_);
1351 }
1352 
1353 
1354 template <class T> inline
1356 {
1357  f *= .5;
1358  return PixRectangle<T>( iwiderPos<T>(this->left(),this->right(),f),
1359  iwiderPos<T>(this->top(),this->bottom(),f),
1360  iwiderPos<T>(this->right(),this->left(),f),
1361  iwiderPos<T>(this->bottom(),this->top(),f) );
1362 }
1363 
1364 
1365 template <class T>
1367 {
1368  f *= .5;
1369  return PosRectangle<T>( fwiderPos(this->left(),this->right(),f),
1370  fwiderPos(this->top(),this->bottom(),f),
1371  fwiderPos(this->right(),this->left(),f),
1372  fwiderPos(this->bottom(),this->top(),f) );
1373 }
1374 
1375 
1376 template <class T>
1377 inline bool Rectangle<T>::operator >( const Rectangle<T>& r ) const
1378 {
1379  Size2D<T> diff( width()-r.width(), height()-r.height() );
1380 
1381  if ( diff.width() > 0 && diff.height() > 0 )
1382  return true;
1383  if ( diff.width() < 0 && diff.height() < 0 )
1384  return false;
1385 
1386  return diff.width() < 0 ? diff.height() < -diff.width()
1387  : diff.width() > -diff.height();
1388 }
1389 
1390 
1391 template <class T>
1392 inline void Rectangle<T>::limitTo( const Rectangle<T>& r )
1393 {
1394  topleft_ = r.moveInside( topleft_ );
1396 }
1397 
1398 
1399 template <class T>
1400 inline void Rectangle<T>::translate(const Point2D<T> & trans )
1401 {
1402  topleft_ += trans;
1403  bottomright_ += trans;
1404 }
1405 
1406 
1407 template <class T>
1408 inline void Rectangle<T>::include( const Rectangle<T>& r )
1409 {
1410  if ( !r.isDefined() ) return;
1411  if ( !isDefined() ) *this = r;
1412 
1413  if ( revX() )
1414  {
1415  if ( r.left() > left() ) topleft_.x_ = r.left();
1416  if ( r.right() < right() ) bottomright_.x_ = r.right();
1417  }
1418  else
1419  {
1420  if ( r.left() < left() ) topleft_.x_ = r.left();
1421  if ( r.right() > right() ) bottomright_.x_ = r.right();
1422  }
1423  if ( revY() )
1424  {
1425  if ( r.bottom() > bottom() ) bottomright_.y_ = r.bottom();
1426  if ( r.top() < top() ) topleft_.y_ = r.top();
1427  }
1428  else
1429  {
1430  if ( r.bottom() < bottom() ) bottomright_.y_ = r.bottom();
1431  if ( r.top() > top() ) topleft_.y_ = r.top();
1432  }
1433 }
1434 
1435 
1436 template <class T>
1437 inline void Rectangle<T>::include( const Point2D<T>& p )
1438 {
1439  if ( !p.isDefined() ) return;
1440  if ( !isDefined() ) topleft_ = bottomright_ = p;
1441 
1442  if ( revX() )
1443  {
1444  if ( p.x_ > left() ) topleft_.x_ = p.x_;
1445  if ( p.x_ < right() ) bottomright_.x_ = p.x_;
1446  }
1447  else
1448  {
1449  if ( p.x_ < left() ) topleft_.x_ = p.x_;
1450  if ( p.x_ > right() ) bottomright_.x_ = p.x_;
1451  }
1452  if ( revY() )
1453  {
1454  if ( p.y_ > bottom() ) bottomright_.y_ = p.y_;
1455  if ( p.y_ < top() ) topleft_.y_ = p.y_;
1456  }
1457  else
1458  {
1459  if ( p.y_ < bottom() ) bottomright_.y_ = p.y_;
1460  if ( p.y_ > top() ) topleft_.y_ = p.y_;
1461  }
1462 }
1463 
1464 }; // namespace Geom
1465 
1466 
1467 namespace Conv
1468 {
1469 
1470  template <>
1471  inline void set( Geom::Point2D<float>& _to, const Geom::Point2D<double>& f )
1472  { _to.setFrom( f ); }
1473 
1474  template <>
1475  inline void set( Geom::Point2D<double>& _to, const Geom::Point2D<float>& f )
1476  { _to.setFrom( f ); }
1477 
1478  template <>
1479  inline void set( Geom::Point3D<float>& _to, const Geom::Point3D<double>& f )
1480  { _to.setFrom( f ); }
1481 
1482  template <>
1483  inline void set( Geom::Point3D<double>& _to, const Geom::Point3D<float>& f )
1484  { _to.setFrom( f ); }
1485 }
T & operator[](int idx)
Definition: geometry.h:743
void translate(const Point2D< T > &)
Definition: geometry.h:1400
FT cosAngle(const Point2D< T > &from, const Point2D< T > &to) const
saves the expensive acos() call
Definition: geometry.h:643
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:285
bool getFromString(int &, const char *, int udfval)
T dot(const Point3D< T > &) const
Definition: geometry.h:852
T width() const
Definition: geometry.h:1100
bool operator!=(const Rectangle< T > &) const
Definition: geometry.h:1023
Rectangle< T > & operator-=(const Point2D< T > &)
Definition: geometry.h:1188
bool operator>(const NamedObject &obj1, const NamedObject &obj2)
Definition: namedobj.h:75
bool isOnSide(const Point2D< T > &) const
Definition: geometry.h:1247
int operator-(const DateInfo &di1, const DateInfo &di2)
Definition: dateinfo.h:127
Integer rectangle class.
Definition: geometry.h:307
T left() const
Definition: geometry.h:1110
void setXY(TT xx, TT yy)
Definition: geometry.h:391
T to(const F &fr)
Definition: convert.h:31
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
Point3D< T > & setFrom(const Point3D< TT > &)
Definition: geometry.h:687
Point2D< T > bottomLeft() const
Definition: geometry.h:1038
Size2D< T > & operator-=(T val)
Definition: geometry.h:979
void zero()
Definition: geometry.h:1173
float ACos(float)
#define mIsZero(x, eps)
Definition: commondefs.h:55
FT abs() const
Definition: geometry.h:619
Point2D< T > operator/(const T den) const
Definition: geometry.h:472
void setXY(TT xx, TT yy)
Definition: geometry.h:692
void setTop(T val)
Definition: geometry.h:1135
void setWidth(T val)
Definition: geometry.h:954
void include(const Rectangle< T > &)
Definition: geometry.h:1408
PosRectangle< T > grownBy(T sidesincreasebyfactor=1) const
Definition: geometry.h:1366
void sortCorners(bool leftislow=true, bool topislow=true)
Definition: geometry.h:1160
PixRectangle(T l=0, T t=0, T r=0, T b=0)
Definition: geometry.h:1302
Definition: i_layout.h:26
Point3D< T > operator/(const T den) const
Definition: geometry.h:795
T width_
Definition: geometry.h:211
Size2D< T > operator+(T val) const
Definition: geometry.h:969
void limitTo(const Rectangle< T > &)
Definition: geometry.h:1392
void setTopLeft(Point2D< T >)
Definition: geometry.h:1056
Point3D< T > & operator/=(T den)
Definition: geometry.h:844
bool yOutside(T, T) const
Definition: geometry.h:1263
Point2D< T > bottomright_
Definition: geometry.h:293
T width() const
Definition: geometry.h:944
Point2D< T > & operator/=(T den)
Definition: geometry.h:442
Point3D< T > operator-() const
Definition: geometry.h:784
bool isOutside(const Point2D< T > &) const
Definition: geometry.h:1331
FT abs() const
Definition: geometry.h:874
bool isInside(const Point2D< T > &, T eps) const
Definition: geometry.h:1280
static Point2D< T > udf()
Definition: geometry.h:78
bool fromString(const char *)
Definition: geometry.h:565
bool isDefined() const
Definition: geometry.h:764
Size2D< T > & operator+=(T val)
Definition: geometry.h:974
T sqDistTo(const Point2D< T > &) const
Squared distance.
Definition: geometry.h:634
T bottom() const
Definition: geometry.h:1125
Point3D< T > & zero()
Definition: geometry.h:706
PixRectangle< T > grownBy(double sidesincreasebyfactor=1) const
Definition: geometry.h:1355
bool operator==(const Point2D< T > &) const
Definition: geometry.h:414
Point2D< T > bottomRight() const
Definition: geometry.h:1043
void setBottom(T val)
Definition: geometry.h:1145
#define mMIN(x, y)
Definition: commondefs.h:52
Interval of values.
Definition: commontypes.h:27
bool operator>(const Rectangle< T > &) const
Definition: geometry.h:1377
Point3D< T > normalize() const
Returns vector with length one.
Definition: geometry.h:863
bool isOutside(const Point2D< T > &p, T eps) const
Definition: geometry.h:348
Point3D< T > operator*(const T factor) const
Definition: geometry.h:790
bool contains(const Point2D< T > &p, T eps) const
Definition: geometry.h:353
Basic 2D sizes (width/height) class.
Definition: geometry.h:190
Point3D< T > scaleBy(const Point3D< T > &factor) const
Definition: geometry.h:800
#define M_PI
Definition: commondefs.h:66
void swapXY()
Definition: geometry.h:487
PosRectangle(Point2D< T > tl, Point2D< T > br)
Definition: geometry.h:345
T height() const
Definition: geometry.h:1105
T sqAbs() const
Squared absolute value.
Definition: geometry.h:624
Point3D< T > cross(const Point3D< T > &) const
Definition: geometry.h:858
bool isInside(const Point2D< T > &) const
Definition: geometry.h:1326
#define mSkipBlanks(ptr)
Advances given pointer to first non-whitespace.
Definition: string2.h:78
FT angle(const Point2D< T > &from, const Point2D< T > &to) const
Definition: geometry.h:655
#define mNINT32(x)
Definition: commondefs.h:48
3D point or vector
Definition: commontypes.h:57
Point2D< T > topRight() const
Definition: geometry.h:1033
Size2D(T w=0, T h=0)
Definition: geometry.h:929
bool operator<(const Point2D< T > &crd) const
Definition: geometry.h:419
bool contains(const PosRectangle< T > &other, T eps) const
Definition: geometry.h:356
Point3D< T > & operator+=(T dist)
Definition: geometry.h:814
void setBottomRight(Point2D< T >)
Definition: geometry.h:1061
FT distTo(const Point2D< T > &) const
Definition: geometry.h:629
bool yOutside(T) const
Definition: geometry.h:1239
static Point3D< T > udf()
Definition: geometry.h:924
Rectangle(T l=0, T t=0, T r=0, T b=0)
Definition: geometry.h:999
T sqDistTo(const Point3D< T > &) const
Squared distance.
Definition: geometry.h:891
PosRectangle(T l=0, T t=0, T r=0, T b=0)
Definition: geometry.h:343
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
bool checkCorners(bool leftislow=true, bool topislow=true) const
Definition: geometry.h:1150
Rectangle< T > & operator+=(const Point2D< T > &)
Definition: geometry.h:1183
void swapHor()
Definition: geometry.h:1203
Point3D(const Point2D< T > &, T)
Definition: geometry.h:671
Point2D< T > getXY() const
Definition: geometry.h:117
void setRight(T val)
Definition: geometry.h:1140
bool isDefined() const
Definition: geometry.h:477
void Swap(T &a, T &b)
Definition: commondefs.h:34
T & operator[](int idx)
Definition: geometry.h:404
bool isDefined() const
Definition: geometry.h:1178
Size2D< T > size() const
Definition: geometry.h:1168
Point2D< T > moveInside(const Point2D< T > &) const
Definition: geometry.h:1086
void setLeft(T val)
Definition: geometry.h:1130
T top() const
Definition: geometry.h:1115
T x_
Definition: geometry.h:80
void setTopRight(Point2D< T >)
Definition: geometry.h:1066
bool operator==(const Point3D< T > &) const
Definition: geometry.h:715
T x_
Definition: geometry.h:166
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
BufferString & set(const char *)
Definition: bufstring.h:227
Basic 2D rectangle class.
Definition: geometry.h:228
BufferString toString(const DBKey &ky)
Definition: dbkey.h:115
bool isSameAs(const Point3D< T > &pos, const Point3D< T > &eps) const
Definition: geometry.h:733
bool isUdf() const
Definition: geometry.h:147
#define mDefEps
Definition: commondefs.h:60
Point3D< T > operator+(const Point3D< T > &) const
Definition: geometry.h:771
T height_
Definition: geometry.h:212
T iwiderPos(int x1, int x2, double f)
Definition: geometry.h:1292
Point2D< T > centre() const
Definition: geometry.h:1048
Point3D< T > & operator*=(T factor)
Definition: geometry.h:836
Point2D< T > & operator*=(T factor)
Definition: geometry.h:437
FT xyDistTo(const Point3D< T > &) const
Distance in the xy plane.
Definition: geometry.h:901
bool contains(const Point2D< T > &) const
Definition: geometry.h:1336
bool revX() const
Definition: geometry.h:1221
T stop
Definition: ranges.h:91
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
T dot(const Point2D< T > &) const
Definition: geometry.h:482
void set(T w, T h)
Definition: geometry.h:964
Point2D< T > operator*(const T factor) const
Definition: geometry.h:467
void swapVer()
Definition: geometry.h:1212
T z_
Definition: geometry.h:168
Point2D< T > operator-() const
Definition: geometry.h:399
void setBottomLeft(Point2D< T >)
Definition: geometry.h:1071
bool operator!=(const Point3D< T > &) const
Definition: geometry.h:725
T sqAbs() const
Squared absolute value.
Definition: geometry.h:879
bool operator==(const Size2D< T > &) const
Definition: geometry.h:934
T xySqDistTo(const Point3D< T > &) const
Square distance in the xy plane.
Definition: geometry.h:906
Point2D< T > topleft_
Definition: geometry.h:292
Point2D< T > normalize() const
Definition: geometry.h:607
bool operator>(const Point2D< T > &crd) const
Definition: geometry.h:423
void setLeftRight(const Interval< T > &)
Definition: geometry.h:1081
T fwiderPos(T x1, T x2, T f)
Definition: geometry.h:1297
bool isOnSide(const Point2D< T > &p, T eps) const
Definition: geometry.h:1271
bool operator!=(const Size2D< T > &) const
Definition: geometry.h:939
Point2D(T xx=0, T yy=0)
Definition: geometry.h:377
BufferString & add(char)
Point2D< T > operator+(const Point2D< T > &) const
Definition: geometry.h:457
T start
Definition: ranges.h:90
Point2D< T > topLeft() const
Definition: geometry.h:1028
Point3D< T > unScaleBy(const Point3D< T > &denominator) const
Definition: geometry.h:806
Point3D< T > & operator-=(const Point3D< T > &)
Definition: geometry.h:828
Point2D< T > operator*(int f, const Point2D< T > &b)
Definition: geometry.h:86
bool isUdf() const
Definition: geometry.h:60
Template based type conversion.
Definition: convert.h:22
Definition: commontypes.h:55
T right() const
Definition: geometry.h:1120
#define mClass(module)
Definition: commondefs.h:161
2D point or vector class.
Definition: commontypes.h:58
bool xOutside(T) const
Definition: geometry.h:1231
Point2D< T > & setFrom(const Point2D< TT > &)
Definition: geometry.h:382
const char * firstOcc(const char *, char)
Point2D< T > & operator-=(const Point2D< T > &)
Definition: geometry.h:452
bool isUdf(const T &t)
Definition: undefval.h:241
bool revY() const
Definition: geometry.h:1226
T y_
Definition: geometry.h:167
Point2D< T > & zero()
Definition: geometry.h:395
bool isInside(const PosRectangle< T > &other, T eps) const
Definition: geometry.h:361
BufferString toPrettyString() const
Definition: geometry.h:75
T y_
Definition: geometry.h:81
char * getCStr()
Definition: bufstring.h:73
void setTopBottom(const Interval< T > &)
Definition: geometry.h:1076
float Sqrt(float)
FT distTo(const Point3D< T > &) const
Definition: geometry.h:886
Point2D< T > & operator+=(T dist)
Definition: geometry.h:432
T height() const
Definition: geometry.h:949
bool operator!=(const Point2D< T > &) const
Definition: geometry.h:428
#define mMAX(x, y)
Definition: commondefs.h:51
bool xOutside(T, T) const
Definition: geometry.h:1255
Floating-point rectangle class.
Definition: geometry.h:340
void setHeight(T val)
Definition: geometry.h:959
bool operator==(const Rectangle< T > &) const
Definition: geometry.h:1018
BufferString toString(int nrdec=-1) const
Definition: geometry.h:548
Definition: i_layout.h:26

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017