Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
xyzTriple.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file numeric/xyzTriple.hh
11 /// @brief Fast (x,y,z)-coordinate vector container
12 /// @author Frank M. D'Ippolito (Objexx@objexx.com)
13 /// @author Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
14 ///
15 /// @remarks
16 /// @li Inline, loop-free functions for speed
17 /// @li Non-virtual destructor for speed: Not set up for use as a base class
18 /// @li Pointer constructor and assignment not available for xyzTriples of pointers
19 /// @li Container semantics: lexicographic complete ordering
20 
21 
22 #ifndef INCLUDED_numeric_xyzTriple_hh
23 #define INCLUDED_numeric_xyzTriple_hh
24 
25 
26 // Unit headers
27 #include <numeric/xyzTriple.fwd.hh>
28 
29 // Package headers
31 
32 // C++ headers
33 #include <utility/assert.hh>
34 #include <cmath>
35 #include <stdexcept>
36 
37 
38 namespace numeric {
39 
40 
41 /// @brief Fast (x,y,z)-coordinate vector container
42 template< typename T >
43 class xyzTriple
44 {
45 
46 
47 private: // Friends
48 
49 
50  template< typename > friend class xyzTriple;
51 
52 
53 public: // Types
54 
55 
56  // Project style
57  typedef T Value;
58  typedef T & Reference;
59  typedef T const & ConstReference;
60  typedef T * Pointer;
61  typedef T const * ConstPointer;
62 
63  // STL/boost style
64  typedef T value_type;
65  typedef T & reference;
66  typedef T const & const_reference;
67  typedef T * pointer;
68  typedef T const * const_pointer;
69 
70  // Types to prevent compile failure when std::distance is in scope
71  typedef void iterator_category;
72  typedef void difference_type;
73 
74 
75 public: // Creation
76 
77 
78  /// @brief Default constructor
79  /// @note Values are uninitialized for efficiency
80  inline
82  {}
83 
84 
85  /// @brief Copy constructor
86  inline
87  xyzTriple( xyzTriple const & v ) :
88  x_( v.x_ ),
89  y_( v.y_ ),
90  z_( v.z_ )
91  {}
92 
93 
94  /// @brief Copy constructor
95  template< typename U >
96  inline
97  xyzTriple( xyzTriple< U > const & v ) :
98  x_( v.x_ ),
99  y_( v.y_ ),
100  z_( v.z_ )
101  {}
102 
103 
104  /// @brief Uniform value constructor
105  inline
106  explicit
107  xyzTriple( Value const & t ) :
108  x_( t ),
109  y_( t ),
110  z_( t )
111  {}
112 
113 
114  /// @brief Triple value constructor
115  inline
117  Value const & x_a,
118  Value const & y_a,
119  Value const & z_a
120  ) :
121  x_( x_a ),
122  y_( y_a ),
123  z_( z_a )
124  {}
125 
126 
127  /// @brief Pointer to contiguous values constructor
128  /// @note U must be assignable to a Value
129  /// @warning No way to check that argument points to three values
130  /// @warning Argument missing an & operator will quietly call the uniform value constructor
131  template< typename U >
132  inline
133  explicit
134  xyzTriple( U const * p ) :
135  x_( *p ),
136  y_( *++p ),
137  z_( *++p )
138  {}
139 
140 
141  /// @brief Destructor
142  inline
144  {}
145 
146 
147 public: // Assignment
148 
149 
150  /// @brief Copy assignment
151  inline
152  xyzTriple &
153  operator =( xyzTriple const & v )
154  {
155  if ( this != &v ) {
156  x_ = v.x_;
157  y_ = v.y_;
158  z_ = v.z_;
159  }
160  return *this;
161  }
162 
163 
164  /// @brief Copy assignment
165  template< typename U >
166  inline
167  xyzTriple &
169  {
170  x_ = v.x_;
171  y_ = v.y_;
172  z_ = v.z_;
173  return *this;
174  }
175 
176 
177  /// @brief Assignment from pointer to contiguous values
178  /// @warning No way to check that argument points to three values
179  template< typename U >
180  inline
181  xyzTriple &
182  operator =( U const * p )
183  {
184  x_ = *p;
185  y_ = *++p;
186  z_ = *++p;
187  return *this;
188  }
189 
190 
191  /// @brief += xyzTriple
192  template< typename U >
193  inline
194  xyzTriple &
196  {
197  x_ += v.x_;
198  y_ += v.y_;
199  z_ += v.z_;
200  return *this;
201  }
202 
203 
204  /// @brief -= xyzTriple
205  template< typename U >
206  inline
207  xyzTriple &
209  {
210  x_ -= v.x_;
211  y_ -= v.y_;
212  z_ -= v.z_;
213  return *this;
214  }
215 
216 
217  /// @brief Assign Value * xyzTriple
218  /// @note Avoids temporary of = Value * xyzTriple
219  template< typename U >
220  inline
221  xyzTriple &
222  scaled_assign( Value const & t, xyzTriple< U > const & v )
223  {
224  x_ = t * v.x_;
225  y_ = t * v.y_;
226  z_ = t * v.z_;
227  return *this;
228  }
229 
230 
231  /// @brief Add Value * xyzTriple
232  /// @note Avoids temporary of += Value * xyzTriple
233  template< typename U >
234  inline
235  xyzTriple &
236  scaled_add( Value const & t, xyzTriple< U > const & v )
237  {
238  x_ += t * v.x_;
239  y_ += t * v.y_;
240  z_ += t * v.z_;
241  return *this;
242  }
243 
244 
245  /// @brief Subtract Value * xyzTriple
246  /// @note Avoids temporary of -= Value * xyzTriple
247  template< typename U >
248  inline
249  xyzTriple &
250  scaled_sub( Value const & t, xyzTriple< U > const & v )
251  {
252  x_ -= t * v.x_;
253  y_ -= t * v.y_;
254  z_ -= t * v.z_;
255  return *this;
256  }
257 
258 
259  /// @brief = Value
260  inline
261  xyzTriple &
262  operator =( Value const & t )
263  {
264  x_ = y_ = z_ = t;
265  return *this;
266  }
267 
268 
269  /// @brief += Value
270  inline
271  xyzTriple &
272  operator +=( Value const & t )
273  {
274  x_ += t;
275  y_ += t;
276  z_ += t;
277  return *this;
278  }
279 
280 
281  /// @brief -= Value
282  inline
283  xyzTriple &
284  operator -=( Value const & t )
285  {
286  x_ -= t;
287  y_ -= t;
288  z_ -= t;
289  return *this;
290  }
291 
292 
293  /// @brief *= Value
294  inline
295  xyzTriple &
296  operator *=( Value const & t )
297  {
298  x_ *= t;
299  y_ *= t;
300  z_ *= t;
301  return *this;
302  }
303 
304 
305  /// @brief /= Value
306  inline
307  xyzTriple &
308  operator /=( Value const & t )
309  {
310  assert( t != Value( 0 ) );
311  Value const inv_t( Value( 1 ) / t );
312  x_ *= inv_t;
313  y_ *= inv_t;
314  z_ *= inv_t;
315  return *this;
316  }
317 
318 
319  /// @brief Triple value assignment
320  inline
321  xyzTriple &
323  Value const & x_a,
324  Value const & y_a,
325  Value const & z_a
326  )
327  {
328  x_ = x_a;
329  y_ = y_a;
330  z_ = z_a;
331  return *this;
332  }
333 
334 
335 public: // Methods
336 
337 
338  /// @brief Clear
339  inline
340  xyzTriple &
342  {
343  x_ = y_ = z_ = Value( 0 );
344  return *this;
345  }
346 
347 
348  /// @brief Zero
349  inline
350  xyzTriple &
352  {
353  x_ = y_ = z_ = Value( 0 );
354  return *this;
355  }
356 
357 
358  /// @brief Negate
359  inline
360  xyzTriple &
362  {
363  x_ = -x_;
364  y_ = -y_;
365  z_ = -z_;
366  return *this;
367  }
368 
369 
370  /// @brief -xyzTriple (negated copy)
371  inline
372  xyzTriple
373  operator -() const
374  {
375  return xyzTriple( -x_, -y_, -z_ );
376  }
377 
378 
379  /// @brief Negated copy
380  inline
381  xyzTriple
382  negated() const
383  {
384  return xyzTriple( -x_, -y_, -z_ );
385  }
386 
387 
388  /// @brief Negated: Return via argument (slightly faster)
389  inline
390  void
391  negated( xyzTriple & a ) const
392  {
393  a.x_ = -x_;
394  a.y_ = -y_;
395  a.z_ = -z_;
396  }
397 
398 
399  /// @brief xyzTriple + xyzTriple
400  friend
401  inline
402  xyzTriple
403  operator +( xyzTriple const & a, xyzTriple const & b )
404  {
405  return xyzTriple( a.x_ + b.x_, a.y_ + b.y_, a.z_ + b.z_ );
406  }
407 
408 
409  /// @brief xyzTriple + Value
410  friend
411  inline
412  xyzTriple
413  operator +( xyzTriple const & v, Value const & t )
414  {
415  return xyzTriple( v.x_ + t, v.y_ + t, v.z_ + t );
416  }
417 
418 
419  /// @brief Value + xyzTriple
420  friend
421  inline
422  xyzTriple
423  operator +( Value const & t, xyzTriple const & v )
424  {
425  return xyzTriple( t + v.x_, t + v.y_, t + v.z_ );
426  }
427 
428 
429  /// @brief xyzTriple - xyzTriple
430  friend
431  inline
432  xyzTriple
433  operator -( xyzTriple const & a, xyzTriple const & b )
434  {
435  return xyzTriple( a.x_ - b.x_, a.y_ - b.y_, a.z_ - b.z_ );
436  }
437 
438 
439  /// @brief xyzTriple - Value
440  friend
441  inline
442  xyzTriple
443  operator -( xyzTriple const & v, Value const & t )
444  {
445  return xyzTriple( v.x_ - t, v.y_ - t, v.z_ - t );
446  }
447 
448 
449  /// @brief Value - xyzTriple
450  friend
451  inline
452  xyzTriple
453  operator -( Value const & t, xyzTriple const & v )
454  {
455  return xyzTriple( t - v.x_, t - v.y_, t - v.z_ );
456  }
457 
458 
459  /// @brief xyzTriple * Value
460  friend
461  inline
462  xyzTriple
463  operator *( xyzTriple const & v, Value const & t )
464  {
465  return xyzTriple( v.x_ * t, v.y_ * t, v.z_ * t );
466  }
467 
468 
469  /// @brief Value * xyzTriple
470  friend
471  inline
472  xyzTriple
473  operator *( Value const & t, xyzTriple const & v )
474  {
475  return xyzTriple( t * v.x_, t * v.y_, t * v.z_ );
476  }
477 
478 
479  /// @brief xyzTriple / Value
480  friend
481  inline
482  xyzTriple
483  operator /( xyzTriple const & v, Value const & t )
484  {
485  assert( t != Value( 0 ) );
486  Value const inv_t( Value ( 1 ) / t );
487  return xyzTriple( v.x_ * inv_t, v.y_ * inv_t, v.z_ * inv_t );
488  }
489 
490 
491  /// @brief Add: xyzTriple + xyzTriple
492  friend
493  inline
494  void
495  add( xyzTriple const & a, xyzTriple const & b, xyzTriple & r )
496  {
497  r.x_ = a.x_ + b.x_;
498  r.y_ = a.y_ + b.y_;
499  r.z_ = a.z_ + b.z_;
500  }
501 
502 
503  /// @brief Add: xyzTriple + Value
504  friend
505  inline
506  void
507  add( xyzTriple const & v, Value const & t, xyzTriple & r )
508  {
509  r.x_ = v.x_ + t;
510  r.y_ = v.y_ + t;
511  r.z_ = v.z_ + t;
512  }
513 
514 
515  /// @brief Add: Value + xyzTriple
516  friend
517  inline
518  void
519  add( Value const & t, xyzTriple const & v, xyzTriple & r )
520  {
521  r.x_ = t + v.x_;
522  r.y_ = t + v.y_;
523  r.z_ = t + v.z_;
524  }
525 
526 
527  /// @brief Subtract: xyzTriple - xyzTriple
528  friend
529  inline
530  void
531  subtract( xyzTriple const & a, xyzTriple const & b, xyzTriple & r )
532  {
533  r.x_ = a.x_ - b.x_;
534  r.y_ = a.y_ - b.y_;
535  r.z_ = a.z_ - b.z_;
536  }
537 
538 
539  /// @brief Subtract: xyzTriple - Value
540  friend
541  inline
542  void
543  subtract( xyzTriple const & v, Value const & t, xyzTriple & r )
544  {
545  r.x_ = v.x_ - t;
546  r.y_ = v.y_ - t;
547  r.z_ = v.z_ - t;
548  }
549 
550 
551  /// @brief Subtract: Value - xyzTriple
552  friend
553  inline
554  void
555  subtract( Value const & t, xyzTriple const & v, xyzTriple & r )
556  {
557  r.x_ = t - v.x_;
558  r.y_ = t - v.y_;
559  r.z_ = t - v.z_;
560  }
561 
562 
563  /// @brief Multiply: xyzTriple * Value
564  friend
565  inline
566  void
567  multiply( xyzTriple const & v, Value const & t, xyzTriple & r )
568  {
569  r.x_ = v.x_ * t;
570  r.y_ = v.y_ * t;
571  r.z_ = v.z_ * t;
572  }
573 
574 
575  /// @brief Multiply: Value * xyzTriple
576  friend
577  inline
578  void
579  multiply( Value const & t, xyzTriple const & v, xyzTriple & r )
580  {
581  r.x_ = t * v.x_;
582  r.y_ = t * v.y_;
583  r.z_ = t * v.z_;
584  }
585 
586 
587  /// @brief Divide: xyzTriple / Value
588  friend
589  inline
590  void
591  divide( xyzTriple const & v, Value const & t, xyzTriple & r )
592  {
593  assert( t != Value( 0 ) );
594  Value const inv_t( Value( 1 ) / t );
595  r.x_ = v.x_ * inv_t;
596  r.y_ = v.y_ * inv_t;
597  r.z_ = v.z_ * inv_t;
598  }
599 
600 
601  /// @brief Set minimum coordinates wrt another xyzTriple
602  inline
603  xyzTriple &
604  min( xyzTriple const & v )
605  {
606  x_ = ( x_ <= v.x_ ? x_ : v.x_ );
607  y_ = ( y_ <= v.y_ ? y_ : v.y_ );
608  z_ = ( z_ <= v.z_ ? z_ : v.z_ );
609  return *this;
610  }
611 
612 
613  /// @brief Set maximum coordinates wrt another xyzTriple
614  inline
615  xyzTriple &
616  max( xyzTriple const & v )
617  {
618  x_ = ( x_ >= v.x_ ? x_ : v.x_ );
619  y_ = ( y_ >= v.y_ ? y_ : v.y_ );
620  z_ = ( z_ >= v.z_ ? z_ : v.z_ );
621  return *this;
622  }
623 
624 
625  /// @brief xyzTriple with min coordinates of two xyzTriples
626  friend
627  inline
628  xyzTriple
629  min( xyzTriple const & a, xyzTriple const & b )
630  {
631  return xyzTriple(
632  ( a.x_ <= b.x_ ? a.x_ : b.x_ ),
633  ( a.y_ <= b.y_ ? a.y_ : b.y_ ),
634  ( a.z_ <= b.z_ ? a.z_ : b.z_ )
635  );
636  }
637 
638 
639  /// @brief xyzTriple with max coordinates of two xyzTriples
640  friend
641  inline
642  xyzTriple
643  max( xyzTriple const & a, xyzTriple const & b )
644  {
645  return xyzTriple(
646  ( a.x_ >= b.x_ ? a.x_ : b.x_ ),
647  ( a.y_ >= b.y_ ? a.y_ : b.y_ ),
648  ( a.z_ >= b.z_ ? a.z_ : b.z_ )
649  );
650  }
651 
652 
653  /// @brief Normalize
654  inline
655  xyzTriple &
657  {
658  Value const length_ = length();
659  assert( length_ != Value ( 0 ) );
660  Value const inv_length( Value( 1 ) / length_ );
661  x_ *= inv_length;
662  y_ *= inv_length;
663  z_ *= inv_length;
664  return *this;
665  }
666 
667 
668  /// @brief Normalized
669  inline
670  void
671  normalized( xyzTriple & a ) const
672  {
673  Value const length_ = length();
674  assert( length_ != Value ( 0 ) );
675  Value const inv_length( Value( 1 ) / length_ );
676  a.x_ = x_ * inv_length;
677  a.y_ = y_ * inv_length;
678  a.z_ = z_ * inv_length;
679  }
680 
681 
682  /// @brief Normalize: zero xyzTriple if length is zero
683  inline
684  xyzTriple &
686  {
687  Value const length_ = length();
688  if ( length_ > Value( 0 ) ) {
689  Value const inv_length( Value( 1 ) / length_ );
690  x_ *= inv_length;
691  y_ *= inv_length;
692  z_ *= inv_length;
693  } else { // Set zero vector
694  x_ = Value( 0 );
695  y_ = Value( 0 );
696  z_ = Value( 0 );
697  }
698  return *this;
699  }
700 
701 
702  /// @brief Normalized: zero xyzTriple if length is zero
703  inline
704  void
706  {
707  Value const length_ = length();
708  if ( length_ > Value( 0 ) ) {
709  Value const inv_length( Value( 1 ) / length_ );
710  a.x_ = x_ * inv_length;
711  a.y_ = y_ * inv_length;
712  a.z_ = z_ * inv_length;
713  } else { // Return zero vector
714  a.x_ = Value( 0 );
715  a.y_ = Value( 0 );
716  a.z_ = Value( 0 );
717  }
718  }
719 
720 
721  /// @brief Normalize: arbitrary normalized xyzTriple if length is zero
722  inline
723  xyzTriple &
725  {
726  Value const length_ = length();
727  if ( length_ > Value( 0 ) ) {
728  Value const inv_length( Value( 1 ) / length_ );
729  x_ *= inv_length;
730  y_ *= inv_length;
731  z_ *= inv_length;
732  } else { // Set arbitrary normalized vector
733  x_ = Value( 1 );
734  y_ = Value( 0 );
735  z_ = Value( 0 );
736  }
737  return *this;
738  }
739 
740 
741  /// @brief Normalized: arbitrary normalized xyzTriple if length is zero
742  inline
743  void
745  {
746  Value const length_ = length();
747  if ( length_ > Value( 0 ) ) {
748  Value const inv_length( Value( 1 ) / length_ );
749  a.x_ = x_ * inv_length;
750  a.y_ = y_ * inv_length;
751  a.z_ = z_ * inv_length;
752  } else { // Return arbitrary normalized vector
753  a.x_ = Value( 1 );
754  a.y_ = Value( 0 );
755  a.z_ = Value( 0 );
756  }
757  }
758 
759 
760  /// @brief Normalize to a length
761  inline
762  xyzTriple &
763  normalize( Value const & length_a )
764  {
765  Value const length_ = length();
766  assert( length_ != Value ( 0 ) );
767  Value const dilation = length_a / length_;
768  x_ *= dilation;
769  y_ *= dilation;
770  z_ *= dilation;
771  return *this;
772  }
773 
774 
775  /// @brief Normalized to a length
776  inline
777  void
778  normalized( Value const & length_a, xyzTriple & a ) const
779  {
780  Value const length_ = length();
781  assert( length_ != Value ( 0 ) );
782  Value const dilation = length_a / length_;
783  a.x_ = x_ * dilation;
784  a.y_ = y_ * dilation;
785  a.z_ = z_ * dilation;
786  }
787 
788 
789  /// @brief Normalize to a length: zero xyzTriple if length is zero
790  inline
791  xyzTriple &
792  normalize_or_zero( Value const & length_a )
793  {
794  Value const length_ = length();
795  if ( length_ > Value( 0 ) ) {
796  Value const dilation = length_a / length_;
797  x_ *= dilation;
798  y_ *= dilation;
799  z_ *= dilation;
800  } else { // Set zero vector
801  x_ = Value( 0 );
802  y_ = Value( 0 );
803  z_ = Value( 0 );
804  }
805  return *this;
806  }
807 
808 
809  /// @brief Normalized to a length: zero xyzTriple if length is zero
810  inline
811  void
812  normalized_or_zero( Value const & length_a, xyzTriple & a ) const
813  {
814  Value const length_ = length();
815  if ( length_ > Value( 0 ) ) {
816  Value const dilation = length_a / length_;
817  a.x_ = x_ * dilation;
818  a.y_ = y_ * dilation;
819  a.z_ = z_ * dilation;
820  } else { // Return zero vector
821  a.x_ = Value( 0 );
822  a.y_ = Value( 0 );
823  a.z_ = Value( 0 );
824  }
825  }
826 
827 
828  /// @brief Normalize to a length: arbitrary normalized xyzTriple if length is zero
829  inline
830  xyzTriple &
831  normalize_any( Value const & length_a )
832  {
833  Value const length_ = length();
834  if ( length_ > Value( 0 ) ) {
835  Value const dilation = length_a / length_;
836  x_ *= dilation;
837  y_ *= dilation;
838  z_ *= dilation;
839  } else { // Set arbitrary normalized vector
840  x_ = length_a;
841  y_ = Value( 0 );
842  z_ = Value( 0 );
843  }
844  return *this;
845  }
846 
847 
848  /// @brief Normalized to a length: arbitrary normalized xyzTriple if length is zero
849  inline
850  void
851  normalized_any( Value const & length_a, xyzTriple & a ) const
852  {
853  Value const length_ = length();
854  if ( length_ > Value( 0 ) ) {
855  Value const dilation = length_a / length_;
856  a.x_ = x_ * dilation;
857  a.y_ = y_ * dilation;
858  a.z_ = z_ * dilation;
859  } else { // Return arbitrary normalized vector
860  a.x_ = length_a;
861  a.y_ = Value( 0 );
862  a.z_ = Value( 0 );
863  }
864  }
865 
866 
867  /// @brief Normalized copy
868  inline
869  xyzTriple
870  normalized() const
871  {
872  Value const length_ = length();
873  assert( length_ != Value ( 0 ) );
874  Value const inv_length( Value( 1 ) / length_ );
875  return xyzTriple( x_ * inv_length, y_ * inv_length, z_ * inv_length );
876  }
877 
878 
879  /// @brief Normalized copy: Zero xyzTriple if length is zero
880  inline
881  xyzTriple
883  {
884  Value const length_ = length();
885  if ( length_ > Value( 0 ) ) {
886  Value const inv_length( Value( 1 ) / length_ );
887  return xyzTriple( x_ * inv_length, y_ * inv_length, z_ * inv_length );
888  } else { // Return zero vector
889  return xyzTriple( Value( 0 ), Value( 0 ), Value( 0 ) );
890  }
891  }
892 
893 
894  /// @brief Normalized copy: Arbitrary normalized xyzTriple if length is zero
895  inline
896  xyzTriple
898  {
899  Value const length_ = length();
900  if ( length_ > Value( 0 ) ) {
901  Value const inv_length( Value( 1 ) / length_ );
902  return xyzTriple( x_ * inv_length, y_ * inv_length, z_ * inv_length );
903  } else { // Return arbitrary normalized vector
904  return xyzTriple( Value( 1 ), Value( 0 ), Value( 0 ) );
905  }
906  }
907 
908 
909  /// @brief Normalized to a length copy
910  inline
911  xyzTriple
912  normalized( Value const & length_a ) const
913  {
914  Value const length_ = length();
915  assert( length_ != Value ( 0 ) );
916  Value const dilation = length_a / length_;
917  return xyzTriple( x_ * dilation, y_ * dilation, z_ * dilation );
918  }
919 
920 
921  /// @brief Normalized to a length copy: Zero xyzTriple if length is zero
922  inline
923  xyzTriple
924  normalized_or_zero( Value const & length_a ) const
925  {
926  Value const length_ = length();
927  if ( length_ > Value( 0 ) ) {
928  Value const dilation = length_a / length_;
929  return xyzTriple( x_ * dilation, y_ * dilation, z_ * dilation );
930  } else { // Return zero vector
931  return xyzTriple( Value( 0 ), Value( 0 ), Value( 0 ) );
932  }
933  }
934 
935 
936  /// @brief Normalized to a length copy: Arbitrary normalized xyzTriple if length is zero
937  inline
938  xyzTriple
939  normalized_any( Value const & length_a ) const
940  {
941  Value const length_ = length();
942  if ( length_ > Value( 0 ) ) {
943  Value const dilation = length_a / length_;
944  return xyzTriple( x_ * dilation, y_ * dilation, z_ * dilation );
945  } else { // Return arbitrary normalized vector
946  return xyzTriple( length_a, Value( 0 ), Value( 0 ) );
947  }
948  }
949 
950 
951  /// @brief Project normal
952  /// @note This vector projected normally onto input vector
953  /// @note Not meaningful when v == 0
954  inline
955  xyzTriple &
957  {
958  assert( v.length_squared() != Value( 0 ) );
959  Value const c = dot( v ) / v.length_squared();
960  x_ -= c * v.x_;
961  y_ -= c * v.y_;
962  z_ -= c * v.z_;
963  return *this;
964  }
965 
966 
967  /// @brief Projected normal copy
968  /// @note Copy of this vector projected normally onto input vector
969  /// @note Not meaningful when v == 0
970  inline
971  xyzTriple
972  projected_normal( xyzTriple const & v ) const
973  {
974  assert( v.length_squared() != Value( 0 ) );
975  Value const c = dot( v ) / v.length_squared();
976  return xyzTriple( x_ - ( c * v.x_ ), y_ - ( c * v.y_ ), z_ - ( c * v.z_ ) );
977  }
978 
979 
980  /// @brief Projected normal
981  /// @note Copy of this vector projected normally onto first input vector
982  /// @note Not meaningful when v == 0
983  inline
984  void
985  projected_normal( xyzTriple const & v, xyzTriple & a ) const
986  {
987  assert( v.length_squared() != Value( 0 ) );
988  Value const c = dot( v ) / v.length_squared();
989  a.x_ = x_ - ( c * v.x_ );
990  a.y_ = y_ - ( c * v.y_ );
991  a.z_ = z_ - ( c * v.z_ );
992  }
993 
994 
995  /// @brief Project parallel
996  /// @note This vector projected in direction of input vector
997  /// @note Not meaningful when v == 0
998  inline
999  xyzTriple &
1001  {
1002  assert( v.length_squared() != Value( 0 ) );
1003  Value const c = dot( v ) / v.length_squared();
1004  x_ = c * v.x_;
1005  y_ = c * v.y_;
1006  z_ = c * v.z_;
1007  return *this;
1008  }
1009 
1010 
1011  /// @brief Projected parallel copy
1012  /// @note Copy of this vector projected in direction of input vector
1013  /// @note Not meaningful when v == 0
1014  inline
1015  xyzTriple
1016  projected_parallel( xyzTriple const & v ) const
1017  {
1018  assert( v.length_squared() != Value( 0 ) );
1019  Value const c = dot( v ) / v.length_squared();
1020  return xyzTriple( c * v.x_, c * v.y_, c * v.z_ );
1021  }
1022 
1023 
1024  /// @brief Projected parallel
1025  /// @note Copy of this vector projected in direction of first input vector
1026  /// @note Not meaningful when v == 0
1027  inline
1028  void
1030  {
1031  assert( v.length_squared() != Value( 0 ) );
1032  Value const c = dot( v ) / v.length_squared();
1033  a.x_ = c * v.x_;
1034  a.y_ = c * v.y_;
1035  a.z_ = c * v.z_;
1036  }
1037 
1038 
1039  /// @brief Distance
1040  inline
1041  Value
1042  distance( xyzTriple const & v ) const
1043  {
1044  return std::sqrt( square( x_ - v.x_ ) + square( y_ - v.y_ ) + square( z_ - v.z_ ) );
1045  }
1046 
1047 
1048  /// @brief Distance
1049  friend
1050  inline
1051  Value
1052  distance( xyzTriple const & a, xyzTriple const & b )
1053  {
1054  return std::sqrt( square( a.x_ - b.x_ ) + square( a.y_ - b.y_ ) + square( a.z_ - b.z_ ) );
1055  }
1056 
1057 
1058  /// @brief Distance squared
1059  inline
1060  Value
1061  distance_squared( xyzTriple const & v ) const
1062  {
1063  return square( x_ - v.x_ ) + square( y_ - v.y_ ) + square( z_ - v.z_ );
1064  }
1065 
1066 
1067  /// @brief Distance squared
1068  friend
1069  inline
1070  Value
1072  {
1073  return square( a.x_ - b.x_ ) + square( a.y_ - b.y_ ) + square( a.z_ - b.z_ );
1074  }
1075 
1076 
1077  /// @brief Dot product
1078  inline
1079  Value
1080  dot( xyzTriple const & v ) const
1081  {
1082  return ( x_ * v.x_ ) + ( y_ * v.y_ ) + ( z_ * v.z_ );
1083  }
1084 
1085 
1086  /// @brief Dot product
1087  inline
1088  Value
1089  dot_product( xyzTriple const & v ) const
1090  {
1091  return ( x_ * v.x_ ) + ( y_ * v.y_ ) + ( z_ * v.z_ );
1092  }
1093 
1094 
1095  /// @brief Inner product ( == dot product )
1096  inline
1097  Value
1098  inner_product( xyzTriple const & v ) const
1099  {
1100  return ( x_ * v.x_ ) + ( y_ * v.y_ ) + ( z_ * v.z_ );
1101  }
1102 
1103 
1104  /// @brief Dot product
1105  friend
1106  inline
1107  Value
1108  dot( xyzTriple const & a, xyzTriple const & b )
1109  {
1110  return ( a.x_ * b.x_ ) + ( a.y_ * b.y_ ) + ( a.z_ * b.z_ );
1111  }
1112 
1113 
1114  /// @brief Dot product
1115  friend
1116  inline
1117  Value
1118  dot_product( xyzTriple const & a, xyzTriple const & b )
1119  {
1120  return ( a.x_ * b.x_ ) + ( a.y_ * b.y_ ) + ( a.z_ * b.z_ );
1121  }
1122 
1123 
1124  /// @brief Inner product ( == dot product )
1125  friend
1126  inline
1127  Value
1128  inner_product( xyzTriple const & a, xyzTriple const & b )
1129  {
1130  return ( a.x_ * b.x_ ) + ( a.y_ * b.y_ ) + ( a.z_ * b.z_ );
1131  }
1132 
1133 
1134  /// @brief Cross product
1135  inline
1136  xyzTriple
1137  cross( xyzTriple const & v ) const
1138  {
1139  return xyzTriple(
1140  ( y_ * v.z_ ) - ( z_ * v.y_ ),
1141  ( z_ * v.x_ ) - ( x_ * v.z_ ),
1142  ( x_ * v.y_ ) - ( y_ * v.x_ )
1143  );
1144  }
1145 
1146 
1147  /// @brief Cross product
1148  inline
1149  xyzTriple
1150  cross_product( xyzTriple const & v ) const
1151  {
1152  return xyzTriple(
1153  ( y_ * v.z_ ) - ( z_ * v.y_ ),
1154  ( z_ * v.x_ ) - ( x_ * v.z_ ),
1155  ( x_ * v.y_ ) - ( y_ * v.x_ )
1156  );
1157  }
1158 
1159 
1160  /// @brief Cross product
1161  friend
1162  inline
1163  xyzTriple
1164  cross( xyzTriple const & a, xyzTriple const & b )
1165  {
1166  return xyzTriple(
1167  ( a.y_ * b.z_ ) - ( a.z_ * b.y_ ),
1168  ( a.z_ * b.x_ ) - ( a.x_ * b.z_ ),
1169  ( a.x_ * b.y_ ) - ( a.y_ * b.x_ )
1170  );
1171  }
1172 
1173 
1174  /// @brief Cross product
1175  friend
1176  inline
1177  xyzTriple
1178  cross_product( xyzTriple const & a, xyzTriple const & b )
1179  {
1180  return xyzTriple(
1181  ( a.y_ * b.z_ ) - ( a.z_ * b.y_ ),
1182  ( a.z_ * b.x_ ) - ( a.x_ * b.z_ ),
1183  ( a.x_ * b.y_ ) - ( a.y_ * b.x_ )
1184  );
1185  }
1186 
1187 
1188  /// @brief Cross product: Return via argument (slightly faster)
1189  friend
1190  inline
1191  void
1192  cross( xyzTriple const & a, xyzTriple const & b, xyzTriple & c )
1193  {
1194  c.x_ = ( a.y_ * b.z_ ) - ( a.z_ * b.y_ );
1195  c.y_ = ( a.z_ * b.x_ ) - ( a.x_ * b.z_ );
1196  c.z_ = ( a.x_ * b.y_ ) - ( a.y_ * b.x_ );
1197  }
1198 
1199 
1200  /// @brief Cross product: Return via argument (slightly faster)
1201  friend
1202  inline
1203  void
1204  cross_product( xyzTriple const & a, xyzTriple const & b, xyzTriple & c )
1205  {
1206  c.x_ = ( a.y_ * b.z_ ) - ( a.z_ * b.y_ );
1207  c.y_ = ( a.z_ * b.x_ ) - ( a.x_ * b.z_ );
1208  c.z_ = ( a.x_ * b.y_ ) - ( a.y_ * b.x_ );
1209  }
1210 
1211 
1212  /// @brief Midpoint of 2 xyzTriples
1213  friend
1214  inline
1215  xyzTriple
1216  midpoint( xyzTriple const & a, xyzTriple const & b )
1217  {
1218  return xyzTriple(
1219  Value( 0.5 * ( a.x_ + b.x_ ) ),
1220  Value( 0.5 * ( a.y_ + b.y_ ) ),
1221  Value( 0.5 * ( a.z_ + b.z_ ) )
1222  );
1223  }
1224 
1225 
1226  /// @brief Midpoint of 2 xyzTriples: Return via argument (slightly faster)
1227  friend
1228  inline
1229  void
1230  midpoint( xyzTriple const & a, xyzTriple const & b, xyzTriple & m )
1231  {
1232  m.x_ = Value( 0.5 * ( a.x_ + b.x_ ) );
1233  m.y_ = Value( 0.5 * ( a.y_ + b.y_ ) );
1234  m.z_ = Value( 0.5 * ( a.z_ + b.z_ ) );
1235  }
1236 
1237 
1238  /// @brief Center of 2 xyzTriples
1239  friend
1240  inline
1241  xyzTriple
1242  center( xyzTriple const & a, xyzTriple const & b )
1243  {
1244  return xyzTriple(
1245  Value( 0.5 * ( a.x_ + b.x_ ) ),
1246  Value( 0.5 * ( a.y_ + b.y_ ) ),
1247  Value( 0.5 * ( a.z_ + b.z_ ) )
1248  );
1249  }
1250 
1251 
1252  /// @brief Center of 2 xyzTriples: Return via argument (slightly faster)
1253  friend
1254  inline
1255  void
1256  center( xyzTriple const & a, xyzTriple const & b, xyzTriple & m )
1257  {
1258  m.x_ = Value( 0.5 * ( a.x_ + b.x_ ) );
1259  m.y_ = Value( 0.5 * ( a.y_ + b.y_ ) );
1260  m.z_ = Value( 0.5 * ( a.z_ + b.z_ ) );
1261  }
1262 
1263 
1264  /// @brief Center of 3 xyzTriples
1265  friend
1266  inline
1267  xyzTriple
1268  center( xyzTriple const & a, xyzTriple const & b, xyzTriple const & c )
1269  {
1270  long double const third( 1.0 / 3.0 );
1271  return xyzTriple(
1272  Value( third * ( a.x_ + b.x_ + c.x_ ) ),
1273  Value( third * ( a.y_ + b.y_ + c.y_ ) ),
1274  Value( third * ( a.z_ + b.z_ + c.z_ ) )
1275  );
1276  }
1277 
1278 
1279  /// @brief Center of 3 xyzTriples: Return via argument (slightly faster)
1280  friend
1281  inline
1282  void
1283  center( xyzTriple const & a, xyzTriple const & b, xyzTriple const & c, xyzTriple & m )
1284  {
1285  long double const third( 1.0 / 3.0 );
1286  m.x_ = Value( third * ( a.x_ + b.x_ + c.x_ ) );
1287  m.y_ = Value( third * ( a.y_ + b.y_ + c.y_ ) );
1288  m.z_ = Value( third * ( a.z_ + b.z_ + c.z_ ) );
1289  }
1290 
1291 
1292  /// @brief Center of 4 xyzTriples
1293  friend
1294  inline
1295  xyzTriple
1296  center( xyzTriple const & a, xyzTriple const & b, xyzTriple const & c, xyzTriple const & d )
1297  {
1298  return xyzTriple(
1299  Value( 0.25 * ( a.x_ + b.x_ + c.x_ + d.x_ ) ),
1300  Value( 0.25 * ( a.y_ + b.y_ + c.y_ + d.y_ ) ),
1301  Value( 0.25 * ( a.z_ + b.z_ + c.z_ + d.z_ ) )
1302  );
1303  }
1304 
1305 
1306  /// @brief Center of 4 xyzTriples: Return via argument (slightly faster)
1307  friend
1308  inline
1309  void
1310  center( xyzTriple const & a, xyzTriple const & b, xyzTriple const & c, xyzTriple const & d, xyzTriple & m )
1311  {
1312  m.x_ = Value( 0.25 * ( a.x_ + b.x_ + c.x_ + d.x_ ) );
1313  m.y_ = Value( 0.25 * ( a.y_ + b.y_ + c.y_ + d.y_ ) );
1314  m.z_ = Value( 0.25 * ( a.z_ + b.z_ + c.z_ + d.z_ ) );
1315  }
1316 
1317 
1318  /// @brief Angle between two vectors (in radians on [ 0, pi ])
1319  friend
1320  inline
1321  Value
1322  angle_of( xyzTriple const & a, xyzTriple const & b )
1323  {
1324  Value const mag = a.length() * b.length();
1325  return ( mag > Value( 0 ) ? std::acos( sin_cos_range( a.dot( b ) / mag ) ) : Value( 0 ) );
1326  }
1327 
1328 
1329  /// @brief Angle formed by three consecutive points (in radians on [ 0, pi ])
1330  /// @note For points a, b, c, the angle is the angle between the vectors a - b and c - b
1331  /// in other words, the positive angle about b from a to c
1332  friend
1333  inline
1334  Value
1335  angle_of( xyzTriple const & a, xyzTriple const & b, xyzTriple const & c )
1336  {
1337  return angle_of( a - b, c - b );
1338  }
1339 
1340 
1341  /// @brief Cosine of angle between two vectors
1342  friend
1343  inline
1344  Value
1345  cos_of( xyzTriple const & a, xyzTriple const & b )
1346  {
1347  Value const mag = a.length() * b.length();
1348  return ( mag > Value( 0 ) ? sin_cos_range( a.dot( b ) / mag ) : Value( 1 ) );
1349  }
1350 
1351 
1352  /// @brief Cosine of angle formed by three consecutive points
1353  /// @note For points a, b, c, the angle is the angle between the vectors a - b and c - b
1354  /// in other words, the positive angle about b from a to c.
1355  friend
1356  inline
1357  Value
1358  cos_of( xyzTriple const & a, xyzTriple const & b, xyzTriple const & c )
1359  {
1360  return cos_of( a - b, c - b );
1361  }
1362 
1363 
1364  /// @brief Sine of angle between two vectors
1365  friend
1366  inline
1367  Value
1368  sin_of( xyzTriple const & a, xyzTriple const & b )
1369  {
1370  return std::sqrt( Value( 1 ) - square( cos_of( a, b ) ) );
1371  }
1372 
1373 
1374  /// @brief Sine of angle formed by three consecutive points
1375  /// @note For points a, b, c, the angle is the angle between the vectors a - b and c - b
1376  /// in other words, the positive angle about b from a to c
1377  friend
1378  inline
1379  Value
1380  sin_of( xyzTriple const & a, xyzTriple const & b, xyzTriple const & c )
1381  {
1382  return sin_of( a - b, c - b );
1383  }
1384 
1385 
1386 public: // Properties: predicates
1387 
1388 
1389  /// @brief Is zero?
1390  inline
1391  bool
1392  is_zero() const
1393  {
1394  static Value const ZERO( 0 );
1395  return ( x_ == ZERO ) && ( y_ == ZERO ) && ( z_ == ZERO );
1396  }
1397 
1398 
1399  /// @brief Is exactly normalized?
1400  inline
1401  bool
1403  {
1404  return ( length_squared() == Value( 1 ) );
1405  }
1406 
1407 
1408  /// @brief Is normalized to within a tolerance?
1409  inline
1410  bool
1411  is_normalized( Value const & tol ) const
1412  {
1413  Value const tol_sq = tol * tol;
1414  Value const length_sq = length_squared();
1415  return ( ( length_sq >= Value( 1 ) - tol_sq ) && ( length_sq <= Value( 1 ) + tol_sq ) );
1416  }
1417 
1418 
1419  /// @brief Is exactly a unit vector?
1420  inline
1421  bool
1422  is_unit() const
1423  {
1424  return ( length_squared() == Value( 1 ) );
1425  }
1426 
1427 
1428  /// @brief Is a unit vector to within a tolerance?
1429  inline
1430  bool
1431  is_unit( Value const & tol ) const
1432  {
1433  Value const tol_sq = tol * tol;
1434  Value const length_sq = length_squared();
1435  return ( ( length_sq >= Value( 1 ) - tol_sq ) && ( length_sq <= Value( 1 ) + tol_sq ) );
1436  }
1437 
1438 
1439 public: // Properties: accessors
1440 
1441 
1442  /// @brief Value x const
1443  inline
1444  Value const &
1445  x() const
1446  {
1447  return x_;
1448  }
1449 
1450 
1451  /// @brief Value x
1452  inline
1453  Value &
1454  x()
1455  {
1456  return x_;
1457  }
1458 
1459 
1460  /// @brief Value y const
1461  inline
1462  Value const &
1463  y() const
1464  {
1465  return y_;
1466  }
1467 
1468 
1469  /// @brief Value y
1470  inline
1471  Value &
1472  y()
1473  {
1474  return y_;
1475  }
1476 
1477 
1478  /// @brief Value z const
1479  inline
1480  Value const &
1481  z() const
1482  {
1483  return z_;
1484  }
1485 
1486 
1487  /// @brief Value z
1488  inline
1489  Value &
1490  z()
1491  {
1492  return z_;
1493  }
1494 
1495 
1496  /// @brief Length
1497  inline
1498  Value
1499  length() const
1500  {
1501  return std::sqrt( ( x_ * x_ ) + ( y_ * y_ ) + ( z_ * z_ ) );
1502  }
1503 
1504 
1505  /// @brief Length squared
1506  inline
1507  Value
1509  {
1510  return ( x_ * x_ ) + ( y_ * y_ ) + ( z_ * z_ );
1511  }
1512 
1513 
1514  /// @brief Norm
1515  inline
1516  Value
1517  norm() const
1518  {
1519  return std::sqrt( ( x_ * x_ ) + ( y_ * y_ ) + ( z_ * z_ ) );
1520  }
1521 
1522 
1523  /// @brief Norm squared
1524  inline
1525  Value
1527  {
1528  return ( x_ * x_ ) + ( y_ * y_ ) + ( z_ * z_ );
1529  }
1530 
1531 
1532  /// @brief Magnitude
1533  inline
1534  Value
1535  magnitude() const
1536  {
1537  return std::sqrt( ( x_ * x_ ) + ( y_ * y_ ) + ( z_ * z_ ) );
1538  }
1539 
1540 
1541  /// @brief Magnitude squared
1542  inline
1543  Value
1545  {
1546  return ( x_ * x_ ) + ( y_ * y_ ) + ( z_ * z_ );
1547  }
1548 
1549 
1550 public: // Properties: value assignment
1551 
1552 
1553  /// @brief x assignment
1554  inline
1555  void
1556  x( Value const & x_a )
1557  {
1558  x_ = x_a;
1559  }
1560 
1561 
1562  /// @brief y assignment
1563  inline
1564  void
1565  y( Value const & y_a )
1566  {
1567  y_ = y_a;
1568  }
1569 
1570 
1571  /// @brief z assignment
1572  inline
1573  void
1574  z( Value const & z_a )
1575  {
1576  z_ = z_a;
1577  }
1578 
1579 
1580 public: // Indexers
1581 
1582  /// @brief xyzVector.at: 0-based index with bounds checking
1583  inline
1584  Value const &
1585  at(int const i) const
1586  {
1587  if ( !((i >= 0) && (i < 3)) ) {
1588  throw std::out_of_range("numeric::xyzTriple::at");
1589  }
1590 
1591  return ( i == 0 ? x_ : ( i == 1 ? y_ : z_ ) );
1592  }
1593 
1594  /// @brief xyzVector.at: 0-based index with bounds checking
1595  inline
1596  Value &
1597  at(int const i)
1598  {
1599  if ( !((i >= 0) && (i < 3)) ) {
1600  throw std::out_of_range ("numeric::xyzTriple::at");
1601  }
1602 
1603  return ( i == 0 ? x_ : ( i == 1 ? y_ : z_ ) );
1604  }
1605 
1606  /// @brief xyzTriple[ i ] const: 0-based index
1607  inline
1608  Value const &
1609  operator []( int const i ) const
1610  {
1611  assert( ( i >= 0 ) && ( i < 3 ) );
1612  return ( i == 0 ? x_ : ( i == 1 ? y_ : z_ ) );
1613  }
1614 
1615 
1616  /// @brief xyzTriple[ i ]: 0-based index
1617  inline
1618  Value &
1619  operator []( int const i )
1620  {
1621  assert( ( i >= 0 ) && ( i < 3 ) );
1622  return ( i == 0 ? x_ : ( i == 1 ? y_ : z_ ) );
1623  }
1624 
1625 
1626  /// @brief xyzTriple( i ) const: 1-based index
1627  inline
1628  Value const &
1629  operator ()( int const i ) const
1630  {
1631  assert( ( i > 0 ) && ( i <= 3 ) );
1632  return ( i == 1 ? x_ : ( i == 2 ? y_ : z_ ) );
1633  }
1634 
1635 
1636  /// @brief xyzTriple( i ): 1-based index
1637  inline
1638  Value &
1639  operator ()( int const i )
1640  {
1641  assert( ( i > 0 ) && ( i <= 3 ) );
1642  return ( i == 1 ? x_ : ( i == 2 ? y_ : z_ ) );
1643  }
1644 
1645 
1646 public: // Comparison
1647 
1648 
1649  /// @brief xyzTriple == xyzTriple
1650  friend
1651  inline
1652  bool
1653  operator ==( xyzTriple const & a, xyzTriple const & b )
1654  {
1655  return ( a.x_ == b.x_ ) && ( a.y_ == b.y_ ) && ( a.z_ == b.z_ );
1656  }
1657 
1658 
1659  /// @brief xyzTriple != xyzTriple
1660  friend
1661  inline
1662  bool
1663  operator !=( xyzTriple const & a, xyzTriple const & b )
1664  {
1665  return ( a.x_ != b.x_ ) || ( a.y_ != b.y_ ) || ( a.z_ != b.z_ );
1666  }
1667 
1668 
1669  /// @brief xyzTriple < xyzTriple: Lexicographic order
1670  friend
1671  inline
1672  bool
1673  operator <( xyzTriple const & a, xyzTriple const & b )
1674  {
1675  return (
1676  ( a.x_ < b.x_ ? true :
1677  ( b.x_ < a.x_ ? false : // a.x_ == b.x_
1678  ( a.y_ < b.y_ ? true :
1679  ( b.y_ < a.y_ ? false : // a.y_ == b.y_
1680  ( a.z_ < b.z_ ) ) ) ) ) );
1681  }
1682 
1683 
1684  /// @brief xyzTriple <= xyzTriple
1685  friend
1686  inline
1687  bool
1688  operator <=( xyzTriple const & a, xyzTriple const & b )
1689  {
1690  return (
1691  ( a.x_ < b.x_ ? true :
1692  ( b.x_ < a.x_ ? false : // a.x_ == b.x_
1693  ( a.y_ < b.y_ ? true :
1694  ( b.y_ < a.y_ ? false : // a.y_ == b.y_
1695  ( a.z_ <= b.z_ ) ) ) ) ) );
1696  }
1697 
1698 
1699  /// @brief xyzTriple >= xyzTriple
1700  friend
1701  inline
1702  bool
1703  operator >=( xyzTriple const & a, xyzTriple const & b )
1704  {
1705  return (
1706  ( a.x_ > b.x_ ? true :
1707  ( b.x_ > a.x_ ? false : // a.x_ == b.x_
1708  ( a.y_ > b.y_ ? true :
1709  ( b.y_ > a.y_ ? false : // a.y_ == b.y_
1710  ( a.z_ >= b.z_ ) ) ) ) ) );
1711  }
1712 
1713 
1714  /// @brief xyzTriple > xyzTriple
1715  friend
1716  inline
1717  bool
1718  operator >( xyzTriple const & a, xyzTriple const & b )
1719  {
1720  return (
1721  ( a.x_ > b.x_ ? true :
1722  ( b.x_ > a.x_ ? false : // a.x_ == b.x_
1723  ( a.y_ > b.y_ ? true :
1724  ( b.y_ > a.y_ ? false : // a.y_ == b.y_
1725  ( a.z_ > b.z_ ) ) ) ) ) );
1726  }
1727 
1728 
1729  /// @brief xyzTriple == Value
1730  friend
1731  inline
1732  bool
1733  operator ==( xyzTriple const & v, Value const & t )
1734  {
1735  return ( v.x_ == t ) && ( v.y_ == t ) && ( v.z_ == t );
1736  }
1737 
1738 
1739  /// @brief xyzTriple != Value
1740  friend
1741  inline
1742  bool
1743  operator !=( xyzTriple const & v, Value const & t )
1744  {
1745  return ( v.x_ != t ) || ( v.y_ != t ) || ( v.z_ != t );
1746  }
1747 
1748 
1749  /// @brief xyzTriple < Value
1750  friend
1751  inline
1752  bool
1753  operator <( xyzTriple const & v, Value const & t )
1754  {
1755  return ( v.x_ < t ) && ( v.y_ < t ) && ( v.z_ < t );
1756  }
1757 
1758 
1759  /// @brief xyzTriple <= Value
1760  friend
1761  inline
1762  bool
1763  operator <=( xyzTriple const & v, Value const & t )
1764  {
1765  return ( v.x_ <= t ) && ( v.y_ <= t ) && ( v.z_ <= t );
1766  }
1767 
1768 
1769  /// @brief xyzTriple >= Value
1770  friend
1771  inline
1772  bool
1773  operator >=( xyzTriple const & v, Value const & t )
1774  {
1775  return ( v.x_ >= t ) && ( v.y_ >= t ) && ( v.z_ >= t );
1776  }
1777 
1778 
1779  /// @brief xyzTriple > Value
1780  friend
1781  inline
1782  bool
1783  operator >( xyzTriple const & v, Value const & t )
1784  {
1785  return ( v.x_ > t ) && ( v.y_ > t ) && ( v.z_ > t );
1786  }
1787 
1788 
1789  /// @brief Value == xyzTriple
1790  friend
1791  inline
1792  bool
1793  operator ==( Value const & t, xyzTriple const & v )
1794  {
1795  return ( t == v.x_ ) && ( t == v.y_ ) && ( t == v.z_ );
1796  }
1797 
1798 
1799  /// @brief Value != xyzTriple
1800  friend
1801  inline
1802  bool
1803  operator !=( Value const & t, xyzTriple const & v )
1804  {
1805  return ( t != v.x_ ) || ( t != v.y_ ) || ( t != v.z_ );
1806  }
1807 
1808 
1809  /// @brief Value < xyzTriple
1810  friend
1811  inline
1812  bool
1813  operator <( Value const & t, xyzTriple const & v )
1814  {
1815  return ( t < v.x_ ) && ( t < v.y_ ) && ( t < v.z_ );
1816  }
1817 
1818 
1819  /// @brief Value <= xyzTriple
1820  friend
1821  inline
1822  bool
1823  operator <=( Value const & t, xyzTriple const & v )
1824  {
1825  return ( t <= v.x_ ) && ( t <= v.y_ ) && ( t <= v.z_ );
1826  }
1827 
1828 
1829  /// @brief Value >= xyzTriple
1830  friend
1831  inline
1832  bool
1833  operator >=( Value const & t, xyzTriple const & v )
1834  {
1835  return ( t >= v.x_ ) && ( t >= v.y_ ) && ( t >= v.z_ );
1836  }
1837 
1838 
1839  /// @brief Value > xyzTriple
1840  friend
1841  inline
1842  bool
1843  operator >( Value const & t, xyzTriple const & v )
1844  {
1845  return ( t > v.x_ ) && ( t > v.y_ ) && ( t > v.z_ );
1846  }
1847 
1848 
1849  /// @brief Equal length?
1850  inline
1851  bool
1853  {
1854  return ( length_squared() == v.length_squared() );
1855  }
1856 
1857 
1858  /// @brief Equal length?
1859  friend
1860  inline
1861  bool
1862  equal_length( xyzTriple const & a, xyzTriple const & b )
1863  {
1864  return ( a.length_squared() == b.length_squared() );
1865  }
1866 
1867 
1868  /// @brief Not equal length?
1869  inline
1870  bool
1872  {
1873  return ( length_squared() != v.length_squared() );
1874  }
1875 
1876 
1877  /// @brief Not equal length?
1878  friend
1879  inline
1880  bool
1882  {
1883  return ( a.length_squared() != b.length_squared() );
1884  }
1885 
1886 
1887  /// @brief Longer?
1888  inline
1889  bool
1890  longer( xyzTriple const & v )
1891  {
1892  return ( length_squared() > v.length_squared() );
1893  }
1894 
1895 
1896  /// @brief Longer or equal length?
1897  inline
1898  bool
1900  {
1901  return ( length_squared() >= v.length_squared() );
1902  }
1903 
1904 
1905  /// @brief Shorter?
1906  inline
1907  bool
1908  shorter( xyzTriple const & v )
1909  {
1910  return ( length_squared() < v.length_squared() );
1911  }
1912 
1913 
1914  /// @brief Shorter or equal length?
1915  inline
1916  bool
1918  {
1919  return ( length_squared() <= v.length_squared() );
1920  }
1921 
1922 
1923 private: // Methods
1924 
1925 
1926  /// @brief square( t ) == t * t
1927  inline
1928  static
1929  Value
1930  square( Value const & t )
1931  {
1932  return t * t;
1933  }
1934 
1935 
1936 private: // Fields
1937 
1938 
1939  /// @brief Coordinates of the 3 coordinate vector
1943 
1944 
1945 }; // xyzTriple
1946 
1947 
1948 /// @brief xyzTriple + xyzTriple
1949 template< typename T >
1951 operator +( xyzTriple< T > const & a, xyzTriple< T > const & b );
1952 
1953 
1954 /// @brief xyzTriple + T
1955 template< typename T >
1957 operator +( xyzTriple< T > const & v, T const & t );
1958 
1959 
1960 /// @brief T + xyzTriple
1961 template< typename T >
1963 operator +( T const & t, xyzTriple< T > const & v );
1964 
1965 
1966 /// @brief xyzTriple - xyzTriple
1967 template< typename T >
1969 operator -( xyzTriple< T > const & a, xyzTriple< T > const & b );
1970 
1971 
1972 /// @brief xyzTriple - T
1973 template< typename T >
1975 operator -( xyzTriple< T > const & v, T const & t );
1976 
1977 
1978 /// @brief T - xyzTriple
1979 template< typename T >
1981 operator -( T const & t, xyzTriple< T > const & v );
1982 
1983 
1984 /// @brief xyzTriple * T
1985 template< typename T >
1987 operator *( xyzTriple< T > const & v, T const & t );
1988 
1989 
1990 /// @brief T * xyzTriple
1991 template< typename T >
1993 operator *( T const & t, xyzTriple< T > const & v );
1994 
1995 
1996 /// @brief xyzTriple / T
1997 template< typename T >
1999 operator /( xyzTriple< T > const & v, T const & t );
2000 
2001 
2002 /// @brief Add: xyzTriple + xyzTriple
2003 template< typename T >
2004 void
2005 add( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > & r );
2006 
2007 
2008 /// @brief Add: xyzTriple + T
2009 template< typename T >
2010 void
2011 add( xyzTriple< T > const & v, T const & t, xyzTriple< T > & r );
2012 
2013 
2014 /// @brief Add: T + xyzTriple
2015 template< typename T >
2016 void
2017 add( T const & t, xyzTriple< T > const & v, xyzTriple< T > & r );
2018 
2019 
2020 /// @brief Subtract: xyzTriple - xyzTriple
2021 template< typename T >
2022 void
2023 subtract( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > & r );
2024 
2025 
2026 /// @brief Subtract: xyzTriple - T
2027 template< typename T >
2028 void
2029 subtract( xyzTriple< T > const & v, T const & t, xyzTriple< T > & r );
2030 
2031 
2032 /// @brief Subtract: T - xyzTriple
2033 template< typename T >
2034 void
2035 subtract( T const & t, xyzTriple< T > const & v, xyzTriple< T > & r );
2036 
2037 
2038 /// @brief Multiply: xyzTriple * T
2039 template< typename T >
2040 void
2041 multiply( xyzTriple< T > const & v, T const & t, xyzTriple< T > & r );
2042 
2043 
2044 /// @brief Multiply: T * xyzTriple
2045 template< typename T >
2046 void
2047 multiply( T const & t, xyzTriple< T > const & v, xyzTriple< T > & r );
2048 
2049 
2050 /// @brief Divide: xyzTriple / T
2051 template< typename T >
2052 void
2053 divide( xyzTriple< T > const & v, T const & t, xyzTriple< T > & r );
2054 
2055 
2056 /// @brief xyzTriple with min coordinates of two xyzTriples
2057 template< typename T >
2059 min( xyzTriple< T > const & a, xyzTriple< T > const & b );
2060 
2061 
2062 /// @brief xyzTriple with max coordinates of two xyzTriples
2063 template< typename T >
2065 max( xyzTriple< T > const & a, xyzTriple< T > const & b );
2066 
2067 
2068 /// @brief Distance
2069 template< typename T >
2070 T
2071 distance( xyzTriple< T > const & a, xyzTriple< T > const & b );
2072 
2073 
2074 /// @brief Distance squared
2075 template< typename T >
2076 T
2077 distance_squared( xyzTriple< T > const & a, xyzTriple< T > const & b );
2078 
2079 
2080 /// @brief Dot product
2081 template< typename T >
2082 T
2083 dot( xyzTriple< T > const & a, xyzTriple< T > const & b );
2084 
2085 
2086 /// @brief Dot product
2087 template< typename T >
2088 T
2089 dot_product( xyzTriple< T > const & a, xyzTriple< T > const & b );
2090 
2091 
2092 /// @brief Inner product ( == dot product )
2093 template< typename T >
2094 T
2095 inner_product( xyzTriple< T > const & a, xyzTriple< T > const & b );
2096 
2097 
2098 /// @brief Cross product
2099 template< typename T >
2101 cross( xyzTriple< T > const & a, xyzTriple< T > const & b );
2102 
2103 
2104 /// @brief Cross product
2105 template< typename T >
2107 cross_product( xyzTriple< T > const & a, xyzTriple< T > const & b );
2108 
2109 
2110 /// @brief Cross product: Return via argument (slightly faster)
2111 template< typename T >
2112 void
2113 cross( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > & c );
2114 
2115 
2116 /// @brief Cross product: Return via argument (slightly faster)
2117 template< typename T >
2118 void
2119 cross_product( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > & c );
2120 
2121 
2122 /// @brief Midpoint of 2 xyzTriples
2123 template< typename T >
2125 midpoint( xyzTriple< T > const & a, xyzTriple< T > const & b );
2126 
2127 
2128 /// @brief Midpoint of 2 xyzTriples: Return via argument (slightly faster)
2129 template< typename T >
2130 void
2131 midpoint( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > & m );
2132 
2133 
2134 /// @brief Center of 2 xyzTriples
2135 template< typename T >
2137 center( xyzTriple< T > const & a, xyzTriple< T > const & b );
2138 
2139 
2140 /// @brief Center of 2 xyzTriples: Return via argument (slightly faster)
2141 template< typename T >
2142 void
2143 center( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > & m );
2144 
2145 
2146 /// @brief Center of 3 xyzTriples
2147 template< typename T >
2149 center( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > const & c );
2150 
2151 
2152 /// @brief Center of 3 xyzTriples: Return via argument (slightly faster)
2153 template< typename T >
2154 void
2155 center( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > const & c, xyzTriple< T > & m );
2156 
2157 
2158 /// @brief Center of 4 xyzTriples
2159 template< typename T >
2161 center( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > const & c, xyzTriple< T > const & d );
2162 
2163 
2164 /// @brief Center of 4 xyzTriples: Return via argument (slightly faster)
2165 template< typename T >
2166 void
2167 center( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > const & c, xyzTriple< T > const & d, xyzTriple< T > & m );
2168 
2169 
2170 /// @brief Angle between two vectors (in radians on [ 0, pi ])
2171 template< typename T >
2172 T
2173 angle_of( xyzTriple< T > const & a, xyzTriple< T > const & b );
2174 
2175 
2176 /// @brief Angle formed by three consecutive points (in radians on [ 0, pi ])
2177 template< typename T >
2178 T
2179 angle_of( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > const & c );
2180 
2181 
2182 /// @brief Cosine of angle between two vectors
2183 template< typename T >
2184 T
2185 cos_of( xyzTriple< T > const & a, xyzTriple< T > const & b );
2186 
2187 
2188 /// @brief Cosine of angle formed by three consecutive points
2189 template< typename T >
2190 T
2191 cos_of( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > const & c );
2192 
2193 
2194 /// @brief Sine of angle between two vectors
2195 template< typename T >
2196 T
2197 sin_of( xyzTriple< T > const & a, xyzTriple< T > const & b );
2198 
2199 
2200 /// @brief Sine of angle formed by three consecutive points
2201 template< typename T >
2202 T
2203 sin_of( xyzTriple< T > const & a, xyzTriple< T > const & b, xyzTriple< T > const & c );
2204 
2205 
2206 /// @brief xyzTriple == xyzTriple
2207 template< typename T >
2208 bool
2209 operator ==( xyzTriple< T > const & a, xyzTriple< T > const & b );
2210 
2211 
2212 /// @brief xyzTriple != xyzTriple
2213 template< typename T >
2214 bool
2215 operator !=( xyzTriple< T > const & a, xyzTriple< T > const & b );
2216 
2217 
2218 /// @brief xyzTriple < xyzTriple
2219 template< typename T >
2220 bool
2221 operator <( xyzTriple< T > const & a, xyzTriple< T > const & b );
2222 
2223 
2224 /// @brief xyzTriple <= xyzTriple
2225 template< typename T >
2226 bool
2227 operator <=( xyzTriple< T > const & a, xyzTriple< T > const & b );
2228 
2229 
2230 /// @brief xyzTriple >= xyzTriple
2231 template< typename T >
2232 bool
2233 operator >=( xyzTriple< T > const & a, xyzTriple< T > const & b );
2234 
2235 
2236 /// @brief xyzTriple > xyzTriple
2237 template< typename T >
2238 bool
2239 operator >( xyzTriple< T > const & a, xyzTriple< T > const & b );
2240 
2241 
2242 /// @brief xyzTriple == T
2243 template< typename T >
2244 bool
2245 operator ==( xyzTriple< T > const & v, T const & t );
2246 
2247 
2248 /// @brief xyzTriple != T
2249 template< typename T >
2250 bool
2251 operator !=( xyzTriple< T > const & v, T const & t );
2252 
2253 
2254 /// @brief xyzTriple < T
2255 template< typename T >
2256 bool
2257 operator <( xyzTriple< T > const & v, T const & t );
2258 
2259 
2260 /// @brief xyzTriple <= T
2261 template< typename T >
2262 bool
2263 operator <=( xyzTriple< T > const & v, T const & t );
2264 
2265 
2266 /// @brief xyzTriple >= T
2267 template< typename T >
2268 bool
2269 operator >=( xyzTriple< T > const & v, T const & t );
2270 
2271 
2272 /// @brief xyzTriple > T
2273 template< typename T >
2274 bool
2275 operator >( xyzTriple< T > const & v, T const & t );
2276 
2277 
2278 /// @brief T == xyzTriple
2279 template< typename T >
2280 bool
2281 operator ==( T const & t, xyzTriple< T > const & v );
2282 
2283 
2284 /// @brief T != xyzTriple
2285 template< typename T >
2286 bool
2287 operator !=( T const & t, xyzTriple< T > const & v );
2288 
2289 
2290 /// @brief T < xyzTriple
2291 template< typename T >
2292 bool
2293 operator <( T const & t, xyzTriple< T > const & v );
2294 
2295 
2296 /// @brief T <= xyzTriple
2297 template< typename T >
2298 bool
2299 operator <=( T const & t, xyzTriple< T > const & v );
2300 
2301 
2302 /// @brief T >= xyzTriple
2303 template< typename T >
2304 bool
2305 operator >=( T const & t, xyzTriple< T > const & v );
2306 
2307 
2308 /// @brief T > xyzTriple
2309 template< typename T >
2310 bool
2311 operator >( T const & t, xyzTriple< T > const & v );
2312 
2313 
2314 /// @brief Equal length?
2315 template< typename T >
2316 bool
2317 equal_length( xyzTriple< T > const & a, xyzTriple< T > const & b );
2318 
2319 
2320 /// @brief Not equal length?
2321 template< typename T >
2322 bool
2323 not_equal_length( xyzTriple< T > const & a, xyzTriple< T > const & b );
2324 
2325 
2326 // PyRosetta work around for templates classes
2327 //class xyzTriple_Double : public xyzTriple< double >
2328 //{};
2329 
2330 
2331 } // namespace numeric
2332 
2333 
2334 #endif // INCLUDED_numeric_xyzTriple_HH
void normalized(xyzTriple &a) const
Normalized.
Definition: xyzTriple.hh:671
friend Value angle_of(xyzTriple const &a, xyzTriple const &b, xyzTriple const &c)
Angle formed by three consecutive points (in radians on [ 0, pi ])
Definition: xyzTriple.hh:1335
void normalized_or_zero(xyzTriple &a) const
Normalized: zero xyzTriple if length is zero.
Definition: xyzTriple.hh:705
Value dot_product(xyzTriple const &v) const
Dot product.
Definition: xyzTriple.hh:1089
friend void center(xyzTriple const &a, xyzTriple const &b, xyzTriple const &c, xyzTriple const &d, xyzTriple &m)
Center of 4 xyzTriples: Return via argument (slightly faster)
Definition: xyzTriple.hh:1310
xyzTriple normalized_any() const
Normalized copy: Arbitrary normalized xyzTriple if length is zero.
Definition: xyzTriple.hh:897
Value length_squared() const
Length squared.
Definition: xyzTriple.hh:1508
Value const & x() const
Value x const.
Definition: xyzTriple.hh:1445
xyzTriple cross(xyzTriple const &v) const
Cross product.
Definition: xyzTriple.hh:1137
xyzTriple & project_parallel(xyzTriple const &v)
Project parallel.
Definition: xyzTriple.hh:1000
friend xyzTriple center(xyzTriple const &a, xyzTriple const &b)
Center of 2 xyzTriples.
Definition: xyzTriple.hh:1242
friend Value angle_of(xyzTriple const &a, xyzTriple const &b)
Angle between two vectors (in radians on [ 0, pi ])
Definition: xyzTriple.hh:1322
void negated(xyzTriple &a) const
Negated: Return via argument (slightly faster)
Definition: xyzTriple.hh:391
bool operator==(BodyPosition< T > const &p1, BodyPosition< T > const &p2)
BodyPosition == BodyPosition.
void normalized(Value const &length_a, xyzTriple &a) const
Normalized to a length.
Definition: xyzTriple.hh:778
Value magnitude() const
Magnitude.
Definition: xyzTriple.hh:1535
T const * ConstPointer
Definition: xyzTriple.hh:61
xyzTriple(xyzTriple< U > const &v)
Copy constructor.
Definition: xyzTriple.hh:97
T const & ConstReference
Definition: xyzTriple.hh:59
void normalized_any(Value const &length_a, xyzTriple &a) const
Normalized to a length: arbitrary normalized xyzTriple if length is zero.
Definition: xyzTriple.hh:851
xyzTriple(Value const &t)
Uniform value constructor.
Definition: xyzTriple.hh:107
xyzTriple normalized_or_zero(Value const &length_a) const
Normalized to a length copy: Zero xyzTriple if length is zero.
Definition: xyzTriple.hh:924
xyzTriple cross_product(xyzTriple const &v) const
Cross product.
Definition: xyzTriple.hh:1150
friend Value cos_of(xyzTriple const &a, xyzTriple const &b)
Cosine of angle between two vectors.
Definition: xyzTriple.hh:1345
xyzTriple & project_normal(xyzTriple const &v)
Project normal.
Definition: xyzTriple.hh:956
xyzTriple & normalize(Value const &length_a)
Normalize to a length.
Definition: xyzTriple.hh:763
friend xyzTriple midpoint(xyzTriple const &a, xyzTriple const &b)
Midpoint of 2 xyzTriples.
Definition: xyzTriple.hh:1216
void subtract(xyzTriple< T > const &a, xyzTriple< T > const &b, xyzTriple< T > &r)
Subtract: xyzTriple - xyzTriple.
friend void add(Value const &t, xyzTriple const &v, xyzTriple &r)
Add: Value + xyzTriple.
Definition: xyzTriple.hh:519
Value & x()
Value x.
Definition: xyzTriple.hh:1454
Value & z()
Value z.
Definition: xyzTriple.hh:1490
Value & y()
Value y.
Definition: xyzTriple.hh:1472
T sin_of(xyzTriple< T > const &a, xyzTriple< T > const &b)
Sine of angle between two vectors.
xyzTriple & operator*=(Value const &t)
*= Value
Definition: xyzTriple.hh:296
friend void multiply(xyzTriple const &v, Value const &t, xyzTriple &r)
Multiply: xyzTriple * Value.
Definition: xyzTriple.hh:567
T cos_of(xyzTriple< T > const &a, xyzTriple< T > const &b)
Cosine of angle between two vectors.
friend Value sin_of(xyzTriple const &a, xyzTriple const &b, xyzTriple const &c)
Sine of angle formed by three consecutive points.
Definition: xyzTriple.hh:1380
xyzTriple operator-() const
-xyzTriple (negated copy)
Definition: xyzTriple.hh:373
friend xyzTriple operator+(xyzTriple const &a, xyzTriple const &b)
xyzTriple + xyzTriple
Definition: xyzTriple.hh:403
bool is_unit(Value const &tol) const
Is a unit vector to within a tolerance?
Definition: xyzTriple.hh:1431
T const & const_reference
Definition: xyzTriple.hh:66
~xyzTriple()
Destructor.
Definition: xyzTriple.hh:143
xyzTriple & zero()
Zero.
Definition: xyzTriple.hh:351
Value const & at(int const i) const
xyzVector.at: 0-based index with bounds checking
Definition: xyzTriple.hh:1585
Value const & z() const
Value z const.
Definition: xyzTriple.hh:1481
MathMatrix< T > operator*(const MathMatrix< T > &MATRIX_LHS, const MathMatrix< T > &MATRIX_RHS)
multiply two matrixs of equal size by building the inner product yielding the scalar product ...
void multiply(xyzTriple< T > const &v, T const &t, xyzTriple< T > &r)
Multiply: xyzTriple * T.
friend bool operator!=(xyzTriple const &a, xyzTriple const &b)
xyzTriple != xyzTriple
Definition: xyzTriple.hh:1663
void y(Value const &y_a)
y assignment
Definition: xyzTriple.hh:1565
T angle_of(xyzTriple< T > const &a, xyzTriple< T > const &b)
Angle between two vectors (in radians on [ 0, pi ])
void z(Value const &z_a)
z assignment
Definition: xyzTriple.hh:1574
Value norm() const
Norm.
Definition: xyzTriple.hh:1517
Value dot(xyzTriple const &v) const
Dot product.
Definition: xyzTriple.hh:1080
friend Value dot(xyzTriple const &a, xyzTriple const &b)
Dot product.
Definition: xyzTriple.hh:1108
xyzTriple & normalize_or_zero(Value const &length_a)
Normalize to a length: zero xyzTriple if length is zero.
Definition: xyzTriple.hh:792
xyzTriple & negate()
Negate.
Definition: xyzTriple.hh:361
friend void add(xyzTriple const &v, Value const &t, xyzTriple &r)
Add: xyzTriple + Value.
Definition: xyzTriple.hh:507
friend void center(xyzTriple const &a, xyzTriple const &b, xyzTriple const &c, xyzTriple &m)
Center of 3 xyzTriples: Return via argument (slightly faster)
Definition: xyzTriple.hh:1283
Value const & operator[](int const i) const
xyzTriple[ i ] const: 0-based index
Definition: xyzTriple.hh:1609
xyzTriple & min(xyzTriple const &v)
Set minimum coordinates wrt another xyzTriple.
Definition: xyzTriple.hh:604
Value length() const
Length.
Definition: xyzTriple.hh:1499
xyzTriple & operator/=(Value const &t)
/= Value
Definition: xyzTriple.hh:308
xyzTriple< T > center(xyzTriple< T > const &a, xyzTriple< T > const &b)
Center of 2 xyzTriples.
friend xyzTriple cross_product(xyzTriple const &a, xyzTriple const &b)
Cross product.
Definition: xyzTriple.hh:1178
void x(Value const &x_a)
x assignment
Definition: xyzTriple.hh:1556
bool longer(xyzTriple const &v)
Longer?
Definition: xyzTriple.hh:1890
MathMatrix< T > operator-(const MathMatrix< T > &MATRIX_LHS, const MathMatrix< T > &MATRIX_RHS)
subtract two matrixs of equal size
bool is_normalized(Value const &tol) const
Is normalized to within a tolerance?
Definition: xyzTriple.hh:1411
T distance_squared(xyzTriple< T > const &a, xyzTriple< T > const &b)
Distance squared.
friend void subtract(Value const &t, xyzTriple const &v, xyzTriple &r)
Subtract: Value - xyzTriple.
Definition: xyzTriple.hh:555
xyzTriple & max(xyzTriple const &v)
Set maximum coordinates wrt another xyzTriple.
Definition: xyzTriple.hh:616
friend bool equal_length(xyzTriple const &a, xyzTriple const &b)
Equal length?
Definition: xyzTriple.hh:1862
T sin_cos_range(T const &x, T const &tol=T(.001))
Adjust a sine or cosine value to the valid [-1,1] range if within a specified tolerance or exit with ...
Value norm_squared() const
Norm squared.
Definition: xyzTriple.hh:1526
friend void subtract(xyzTriple const &a, xyzTriple const &b, xyzTriple &r)
Subtract: xyzTriple - xyzTriple.
Definition: xyzTriple.hh:531
xyzTriple & clear()
Clear.
Definition: xyzTriple.hh:341
xyzTriple< T > midpoint(xyzTriple< T > const &a, xyzTriple< T > const &b)
Midpoint of 2 xyzTriples.
friend void midpoint(xyzTriple const &a, xyzTriple const &b, xyzTriple &m)
Midpoint of 2 xyzTriples: Return via argument (slightly faster)
Definition: xyzTriple.hh:1230
bool shorter(xyzTriple const &v)
Shorter?
Definition: xyzTriple.hh:1908
Fast (x,y,z)-coordinate vector container.
friend void cross_product(xyzTriple const &a, xyzTriple const &b, xyzTriple &c)
Cross product: Return via argument (slightly faster)
Definition: xyzTriple.hh:1204
xyzTriple normalized(Value const &length_a) const
Normalized to a length copy.
Definition: xyzTriple.hh:912
xyzTriple & normalize_any()
Normalize: arbitrary normalized xyzTriple if length is zero.
Definition: xyzTriple.hh:724
bool operator>=(xyzMatrix< T > const &a, xyzMatrix< T > const &b)
xyzMatrix >= xyzMatrix
xyzTriple< T > cross_product(xyzTriple< T > const &a, xyzTriple< T > const &b)
Cross product.
bool is_unit() const
Is exactly a unit vector?
Definition: xyzTriple.hh:1422
friend xyzTriple cross(xyzTriple const &a, xyzTriple const &b)
Cross product.
Definition: xyzTriple.hh:1164
short int min(short int const a, short int const b)
min( short int, short int )
void add(xyzTriple< T > const &a, xyzTriple< T > const &b, xyzTriple< T > &r)
Add: xyzTriple + xyzTriple.
short int max(short int const a, short int const b)
max( short int, short int )
MathMatrix< T > operator/(const MathMatrix< T > &MATRIX_LHS, const T &SCALAR_RHS)
divide matrix with scalar
xyzTriple & scaled_sub(Value const &t, xyzTriple< U > const &v)
Subtract Value * xyzTriple.
Definition: xyzTriple.hh:250
xyzTriple & operator+=(xyzTriple< U > const &v)
+= xyzTriple
Definition: xyzTriple.hh:195
friend xyzTriple center(xyzTriple const &a, xyzTriple const &b, xyzTriple const &c)
Center of 3 xyzTriples.
Definition: xyzTriple.hh:1268
tuple p
Definition: docking.py:9
friend bool operator>(xyzTriple const &a, xyzTriple const &b)
xyzTriple > xyzTriple
Definition: xyzTriple.hh:1718
friend xyzTriple max(xyzTriple const &a, xyzTriple const &b)
xyzTriple with max coordinates of two xyzTriples
Definition: xyzTriple.hh:643
bool is_zero() const
Is zero?
Definition: xyzTriple.hh:1392
xyzTriple normalized_any(Value const &length_a) const
Normalized to a length copy: Arbitrary normalized xyzTriple if length is zero.
Definition: xyzTriple.hh:939
bool longer_or_equal(xyzTriple const &v)
Longer or equal length?
Definition: xyzTriple.hh:1899
T const * const_pointer
Definition: xyzTriple.hh:68
void normalized_or_zero(Value const &length_a, xyzTriple &a) const
Normalized to a length: zero xyzTriple if length is zero.
Definition: xyzTriple.hh:812
friend xyzTriple center(xyzTriple const &a, xyzTriple const &b, xyzTriple const &c, xyzTriple const &d)
Center of 4 xyzTriples.
Definition: xyzTriple.hh:1296
friend void cross(xyzTriple const &a, xyzTriple const &b, xyzTriple &c)
Cross product: Return via argument (slightly faster)
Definition: xyzTriple.hh:1192
friend void add(xyzTriple const &a, xyzTriple const &b, xyzTriple &r)
Add: xyzTriple + xyzTriple.
Definition: xyzTriple.hh:495
xyzTriple normalized() const
Normalized copy.
Definition: xyzTriple.hh:870
xyzTriple(U const *p)
Pointer to contiguous values constructor.
Definition: xyzTriple.hh:134
friend Value cos_of(xyzTriple const &a, xyzTriple const &b, xyzTriple const &c)
Cosine of angle formed by three consecutive points.
Definition: xyzTriple.hh:1358
xyzTriple & scaled_assign(Value const &t, xyzTriple< U > const &v)
Assign Value * xyzTriple.
Definition: xyzTriple.hh:222
xyzTriple(xyzTriple const &v)
Copy constructor.
Definition: xyzTriple.hh:87
Value distance_squared(xyzTriple const &v) const
Distance squared.
Definition: xyzTriple.hh:1061
friend void multiply(Value const &t, xyzTriple const &v, xyzTriple &r)
Multiply: Value * xyzTriple.
Definition: xyzTriple.hh:579
T inner_product(xyzTriple< T > const &a, xyzTriple< T > const &b)
Inner product ( == dot product )
xyzTriple negated() const
Negated copy.
Definition: xyzTriple.hh:382
friend Value dot_product(xyzTriple const &a, xyzTriple const &b)
Dot product.
Definition: xyzTriple.hh:1118
friend xyzTriple operator*(xyzTriple const &v, Value const &t)
xyzTriple * Value
Definition: xyzTriple.hh:463
friend void divide(xyzTriple const &v, Value const &t, xyzTriple &r)
Divide: xyzTriple / Value.
Definition: xyzTriple.hh:591
T distance(MathVector< T > const &VECTOR_A, MathVector< T > const &VECTOR_B)
bool shorter_or_equal(xyzTriple const &v)
Shorter or equal length?
Definition: xyzTriple.hh:1917
bool operator>(xyzMatrix< T > const &a, xyzMatrix< T > const &b)
xyzMatrix > xyzMatrix
bool not_equal_length(xyzTriple const &v)
Not equal length?
Definition: xyzTriple.hh:1871
xyzTriple & normalize()
Normalize.
Definition: xyzTriple.hh:656
xyzTriple & operator-=(xyzTriple< U > const &v)
-= xyzTriple
Definition: xyzTriple.hh:208
xyzTriple(Value const &x_a, Value const &y_a, Value const &z_a)
Triple value constructor.
Definition: xyzTriple.hh:116
friend bool operator==(xyzTriple const &a, xyzTriple const &b)
xyzTriple == xyzTriple
Definition: xyzTriple.hh:1653
friend void subtract(xyzTriple const &v, Value const &t, xyzTriple &r)
Subtract: xyzTriple - Value.
Definition: xyzTriple.hh:543
xyzTriple< T > cross(xyzTriple< T > const &a, xyzTriple< T > const &b)
Cross product.
xyzTriple & normalize_any(Value const &length_a)
Normalize to a length: arbitrary normalized xyzTriple if length is zero.
Definition: xyzTriple.hh:831
xyzTriple normalized_or_zero() const
Normalized copy: Zero xyzTriple if length is zero.
Definition: xyzTriple.hh:882
friend xyzTriple min(xyzTriple const &a, xyzTriple const &b)
xyzTriple with min coordinates of two xyzTriples
Definition: xyzTriple.hh:629
bool operator!=(BodyPosition< T > const &p1, BodyPosition< T > const &p2)
BodyPosition != BodyPosition.
friend bool operator<(xyzTriple const &a, xyzTriple const &b)
xyzTriple < xyzTriple: Lexicographic order
Definition: xyzTriple.hh:1673
Value magnitude_squared() const
Magnitude squared.
Definition: xyzTriple.hh:1544
T dot_product(Quaternion< T > const &q1, Quaternion< T > const &q2)
Dot product.
numeric::xyzTriple forward declarations
xyzTriple projected_parallel(xyzTriple const &v) const
Projected parallel copy.
Definition: xyzTriple.hh:1016
Value inner_product(xyzTriple const &v) const
Inner product ( == dot product )
Definition: xyzTriple.hh:1098
xyzTriple & scaled_add(Value const &t, xyzTriple< U > const &v)
Add Value * xyzTriple.
Definition: xyzTriple.hh:236
float tol
Definition: loops_kic.py:75
MathMatrix< T > operator+(const MathMatrix< T > &MATRIX_LHS, const MathMatrix< T > &MATRIX_RHS)
sum two matrixs of equal size
void normalized_any(xyzTriple &a) const
Normalized: arbitrary normalized xyzTriple if length is zero.
Definition: xyzTriple.hh:744
Value distance(xyzTriple const &v) const
Distance.
Definition: xyzTriple.hh:1042
friend Value distance(xyzTriple const &a, xyzTriple const &b)
Distance.
Definition: xyzTriple.hh:1052
xyzTriple & assign(Value const &x_a, Value const &y_a, Value const &z_a)
Triple value assignment.
Definition: xyzTriple.hh:322
static Value square(Value const &t)
square( t ) == t * t
Definition: xyzTriple.hh:1930
void projected_parallel(xyzTriple const &v, xyzTriple &a)
Projected parallel.
Definition: xyzTriple.hh:1029
bool is_normalized() const
Is exactly normalized?
Definition: xyzTriple.hh:1402
friend xyzTriple operator/(xyzTriple const &v, Value const &t)
xyzTriple / Value
Definition: xyzTriple.hh:483
friend Value sin_of(xyzTriple const &a, xyzTriple const &b)
Sine of angle between two vectors.
Definition: xyzTriple.hh:1368
void projected_normal(xyzTriple const &v, xyzTriple &a) const
Projected normal.
Definition: xyzTriple.hh:985
bool not_equal_length(xyzTriple< T > const &a, xyzTriple< T > const &b)
Not equal length?
xyzTriple & normalize_or_zero()
Normalize: zero xyzTriple if length is zero.
Definition: xyzTriple.hh:685
Value const & operator()(int const i) const
xyzTriple( i ) const: 1-based index
Definition: xyzTriple.hh:1629
friend bool operator<=(xyzTriple const &a, xyzTriple const &b)
xyzTriple <= xyzTriple
Definition: xyzTriple.hh:1688
friend bool operator>=(xyzTriple const &a, xyzTriple const &b)
xyzTriple >= xyzTriple
Definition: xyzTriple.hh:1703
Trigonometric functions.
void divide(xyzTriple< T > const &v, T const &t, xyzTriple< T > &r)
Divide: xyzTriple / T.
xyzTriple & operator=(xyzTriple const &v)
Copy assignment.
Definition: xyzTriple.hh:153
T dot(Quaternion< T > const &q1, Quaternion< T > const &q2)
Dot product.
friend bool not_equal_length(xyzTriple const &a, xyzTriple const &b)
Not equal length?
Definition: xyzTriple.hh:1881
Value const & y() const
Value y const.
Definition: xyzTriple.hh:1463
friend Value distance_squared(xyzTriple const &a, xyzTriple const &b)
Distance squared.
Definition: xyzTriple.hh:1071
xyzTriple()
Default constructor.
Definition: xyzTriple.hh:81
Value & at(int const i)
xyzVector.at: 0-based index with bounds checking
Definition: xyzTriple.hh:1597
bool equal_length(xyzTriple< T > const &a, xyzTriple< T > const &b)
Equal length?
Value x_
Coordinates of the 3 coordinate vector.
Definition: xyzTriple.hh:1940
friend void center(xyzTriple const &a, xyzTriple const &b, xyzTriple &m)
Center of 2 xyzTriples: Return via argument (slightly faster)
Definition: xyzTriple.hh:1256
xyzTriple projected_normal(xyzTriple const &v) const
Projected normal copy.
Definition: xyzTriple.hh:972
friend Value inner_product(xyzTriple const &a, xyzTriple const &b)
Inner product ( == dot product )
Definition: xyzTriple.hh:1128
bool equal_length(xyzTriple const &v)
Equal length?
Definition: xyzTriple.hh:1852