Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Vector.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Cinder Project
3  All rights reserved.
4 
5  This code is designed for use with the Cinder C++ library, http://libcinder.org
6 
7  Portions Copyright (c) 2010, The Barbarian Group
8  All rights reserved.
9 
10  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
11  the following conditions are met:
12 
13  * Redistributions of source code must retain the above copyright notice, this list of conditions and
14  the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
16  the following disclaimer in the documentation and/or other materials provided with the distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
19  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #pragma once
29 
30 #include <cmath>
31 #include <cstring>
32 #include <iostream>
33 #include <cassert>
34 #include <limits>
35 
36 #include "cinder/CinderMath.h"
37 
38 namespace cinder {
39 
41 template<typename T>
42 struct VECTRAIT {
43  typedef float DIST;
44 };
45 
46 template<>
47 struct VECTRAIT<double> {
48  typedef double DIST;
49 };
50 
51 template<>
52 struct VECTRAIT<int32_t> {
53  typedef float DIST;
54 };
55 
56 template<typename T, typename Y>
57 struct VEC3CONV {
58  static T getX( const Y &v ) { return static_cast<T>( v.x ); }
59  static T getY( const Y &v ) { return static_cast<T>( v.y ); }
60  static T getZ( const Y &v ) { return static_cast<T>( v.z ); }
61 };
62 
64 
65 template<typename T> class Vec3;
66 
67 template<typename T>
68 class Vec2
69 {
70  public:
71  T x,y;
72 
73  typedef T TYPE;
74  typedef T value_type;
75  typedef typename VECTRAIT<T>::DIST DIST;
76  static const int DIM = 2;
77 
78  Vec2() :x(0), y(0) {}
79  Vec2( T nx, T ny ) : x( nx ), y( ny ) {}
80  Vec2( const Vec2<T>& src ) : x( src.x ), y( src.y ) {}
81  explicit Vec2( const T *d ) : x( d[0] ), y( d[1] ) {}
82 
83  template<typename FromT>
84  Vec2( const Vec2<FromT>& src )
85  : x( static_cast<T>( src.x ) ),y( static_cast<T>( src.y ) )
86  {}
87 
88  void set( T ax, T ay )
89  {
90  x = ax; y = ay;
91  }
92 
93  void set( const Vec2<T> &rhs )
94  {
95  x = rhs.x; y = rhs.y;
96  }
97 
98  // Operators
99  template<typename FromT>
101  {
102  x = static_cast<T>( rhs.x );
103  y = static_cast<T>( rhs.y );
104  return * this;
105  }
106 
107  Vec2<T>& operator=( const Vec2<T>& rhs )
108  {
109  x = rhs.x;
110  y = rhs.y;
111  return * this;
112  }
113 
114  T& operator[]( int n )
115  {
116  assert( n >= 0 && n <= 1 );
117  return (&x)[n];
118  }
119 
120  const T& operator[]( int n ) const
121  {
122  assert( n >= 0 && n <= 1 );
123  return (&x)[n];
124  }
125 
126  T* ptr() const { return &(const_cast<Vec2*>( this )->x); }
127 
128  const Vec2<T> operator+( const Vec2<T>& rhs ) const { return Vec2<T>( x + rhs.x, y + rhs.y ); }
129  const Vec2<T> operator-( const Vec2<T>& rhs ) const { return Vec2<T>( x - rhs.x, y - rhs.y ); }
130  const Vec2<T> operator*( const Vec2<T>& rhs ) const { return Vec2<T>( x * rhs.x, y * rhs.y ); }
131  const Vec2<T> operator/( const Vec2<T>& rhs ) const { return Vec2<T>( x / rhs.x, y / rhs.y ); }
132  Vec2<T>& operator+=( const Vec2<T>& rhs ) { x += rhs.x; y += rhs.y; return *this; }
133  Vec2<T>& operator-=( const Vec2<T>& rhs ) { x -= rhs.x; y -= rhs.y; return *this; }
134  Vec2<T>& operator*=( const Vec2<T>& rhs ) { x *= rhs.x; y *= rhs.y; return *this; }
135  Vec2<T>& operator/=( const Vec2<T>& rhs ) { x /= rhs.x; y /= rhs.y; return *this; }
136  const Vec2<T> operator/( T rhs ) const { return Vec2<T>( x / rhs, y / rhs ); }
137  Vec2<T>& operator+=( T rhs ) { x += rhs; y += rhs; return *this; }
138  Vec2<T>& operator-=( T rhs ) { x -= rhs; y -= rhs; return *this; }
139  Vec2<T>& operator*=( T rhs ) { x *= rhs; y *= rhs; return *this; }
140  Vec2<T>& operator/=( T rhs ) { x /= rhs; y /= rhs; return *this; }
141 
142  Vec2<T> operator-() const { return Vec2<T>( -x, -y ); } // unary negation
143 
144  bool operator==( const Vec2<T> &rhs ) const
145  {
146  return ( x == rhs.x ) && ( y == rhs.y );
147  }
148 
149  bool operator!=( const Vec2<T> &rhs ) const
150  {
151  return ! ( *this == rhs );
152  }
153 
154  T dot( const Vec2<T> &rhs ) const
155  {
156  return x * rhs.x + y * rhs.y;
157  }
158 
160  T cross( const Vec2<T> &rhs ) const
161  {
162  return x * rhs.y - y * rhs.x;
163  }
164 
165  DIST distance( const Vec2<T> &rhs ) const
166  {
167  return ( *this - rhs ).length();
168  }
169 
170  T distanceSquared( const Vec2<T> &rhs ) const
171  {
172  return ( *this - rhs ).lengthSquared();
173  }
174 
175  DIST length() const
176  {
177  return math<DIST>::sqrt( x*x + y*y );
178  }
179 
180  void normalize()
181  {
182  DIST invS = 1 / length();
183  x *= invS;
184  y *= invS;
185  }
186 
188  {
189  DIST invS = 1 / length();
190  return Vec2<T>( x * invS, y * invS );
191  }
192 
193  // tests for zero-length
195  {
196  T s = lengthSquared();
197  if( s > 0 ) {
198  DIST invL = 1 / math<DIST>::sqrt( s );
199  x *= invL;
200  y *= invL;
201  }
202  }
203 
205  {
206  T s = lengthSquared();
207  if( s > 0 ) {
208  DIST invL = 1 / math<DIST>::sqrt( s );
209  return Vec2<T>( x * invL, y * invL );
210  }
211  else
212  return Vec2<T>::zero();
213  }
214 
215  void rotate( DIST radians )
216  {
217  T cosa = math<T>::cos( radians );
218  T sina = math<T>::sin( radians );
219  T rx = x * cosa - y * sina;
220  y = x * sina + y * cosa;
221  x = rx;
222  }
223 
224  T lengthSquared() const
225  {
226  return x * x + y * y;
227  }
228 
231  {
232  T lengthSquared = x * x + y * y;
233 
234  if( ( lengthSquared > maxLength * maxLength ) && ( lengthSquared > 0 ) ) {
235  DIST ratio = maxLength / math<DIST>::sqrt( lengthSquared );
236  x *= ratio;
237  y *= ratio;
238  }
239  }
240 
243  {
244  T lengthSquared = x * x + y * y;
245 
246  if( ( lengthSquared > maxLength * maxLength ) && ( lengthSquared > 0 ) ) {
247  DIST ratio = maxLength / math<DIST>::sqrt( lengthSquared );
248  return Vec2<T>( x * ratio, y * ratio );
249  }
250  else
251  return *this;
252  }
253 
254  void invert()
255  {
256  x = -x;
257  y = -y;
258  }
259 
260  Vec2<T> inverse() const
261  {
262  return Vec2<T>( -x, -y );
263  }
264 
265  Vec2<T> lerp( T fact, const Vec2<T>& r ) const
266  {
267  return (*this) + ( r - (*this) ) * fact;
268  }
269 
270  void lerpEq( T fact, const Vec2<T> &rhs )
271  {
272  x = x + ( rhs.x - x ) * fact; y = y + ( rhs.y - y ) * fact;
273  }
274 
275  // GLSL inspired swizzling functions.
276  Vec2<T> xx() const { return Vec2<T>(x, x); }
277  Vec2<T> xy() const { return Vec2<T>(x, y); }
278  Vec2<T> yx() const { return Vec2<T>(y, x); }
279  Vec2<T> yy() const { return Vec2<T>(y, y); }
280 
281  Vec3<T> xxx() const { return Vec3<T>(x, x, x); }
282  Vec3<T> xxy() const { return Vec3<T>(x, x, y); }
283  Vec3<T> xyx() const { return Vec3<T>(x, y, x); }
284  Vec3<T> xyy() const { return Vec3<T>(x, y, y); }
285  Vec3<T> yxx() const { return Vec3<T>(y, x, x); }
286  Vec3<T> yxy() const { return Vec3<T>(y, x, y); }
287  Vec3<T> yyx() const { return Vec3<T>(y, y, x); }
288  Vec3<T> yyy() const { return Vec3<T>(y, y, y); }
289 
290  static Vec2<T> max()
291  {
293  }
294 
295  static Vec2<T> zero()
296  {
297  return Vec2<T>( 0, 0 );
298  }
299 
300  static Vec2<T> one()
301  {
302  return Vec2<T>( 1, 1 );
303  }
304 
305  friend std::ostream& operator<<( std::ostream& lhs, const Vec2<T>& rhs )
306  {
307  lhs << "[" << rhs.x << "," << rhs.y << "]";
308  return lhs;
309  }
310 
311  static Vec2<T> xAxis() { return Vec2<T>( 1, 0 ); }
312  static Vec2<T> yAxis() { return Vec2<T>( 0, 1 ); }
313 
314  static Vec2<T> NaN() { return Vec2<T>( math<T>::NaN(), math<T>::NaN() ); }
315 };
316 
317 template<typename T>
318 class Vec3
319 {
320 public:
321  T x,y,z;
322 
323  typedef T TYPE;
324  typedef T value_type;
325  static const int DIM = 3;
326 
327  Vec3() :x(0), y(0), z(0) {}
328  Vec3( T nx, T ny, T nz )
329  : x( nx ), y( ny ), z( nz )
330  {}
331  Vec3( const Vec3<T> &src )
332  : x( src.x ), y( src.y ), z( src.z )
333  {}
334  Vec3( const Vec2<T> &v2, T aZ )
335  : x( v2.x ), y( v2.y ), z( aZ )
336  {}
337  explicit Vec3( const Vec2<T> &v2 )
338  : x( v2.x ), y( v2.y ), z( 0 )
339  {}
340  explicit Vec3( const T *d ) : x( d[0] ), y( d[1] ), z( d[2] ) {}
341  template<typename FromT>
342  Vec3( const Vec3<FromT> &src )
343  : x( static_cast<T>( src.x ) ), y( static_cast<T>( src.y ) ), z( static_cast<T>( src.z ) )
344  {}
345  template<typename Y>
346  explicit Vec3( const Y &v )
347  : x( VEC3CONV<Vec3<typename T::TYPE>,Y>::getX( v ) ), y( VEC3CONV<typename T::TYPE,Y>::getY( v ) ), z( VEC3CONV<typename T::TYPE,Y>::getZ( v ) )
348  {
349  }
350 
351  void set( T ax, T ay, T az )
352  {
353  x = ax; y = ay; z = az;
354  }
355 
356  void set( const Vec3<T> &rhs )
357  {
358  x = rhs.x; y = rhs.y; z = rhs.z;
359  }
360 
361  Vec3<T>& operator=( const Vec3<T> &rhs )
362  {
363  x = rhs.x;
364  y = rhs.y;
365  z = rhs.z;
366  return * this;
367  }
368 
369  template<typename FromT>
371  {
372  x = static_cast<T>( rhs.x );
373  y = static_cast<T>( rhs.y );
374  z = static_cast<T>( rhs.z );
375  return * this;
376  }
377 
378  T& operator[]( int n )
379  {
380  assert( n >= 0 && n <= 2 );
381  return (&x)[n];
382  }
383 
384  const T& operator[]( int n ) const
385  {
386  assert( n >= 0 && n <= 2 );
387  return (&x)[n];
388  }
389 
390  T* ptr() const { return &(const_cast<Vec3*>( this )->x); }
391 
392  const Vec3<T> operator+( const Vec3<T>& rhs ) const { return Vec3<T>( x + rhs.x, y + rhs.y, z + rhs.z ); }
393  const Vec3<T> operator-( const Vec3<T>& rhs ) const { return Vec3<T>( x - rhs.x, y - rhs.y, z - rhs.z ); }
394  const Vec3<T> operator*( const Vec3<T>& rhs ) const { return Vec3<T>( x * rhs.x, y * rhs.y, z * rhs.z ); }
395  const Vec3<T> operator/( const Vec3<T>& rhs ) const { return Vec3<T>( x / rhs.x, y / rhs.y, z / rhs.z ); }
396  Vec3<T>& operator+=( const Vec3<T>& rhs ) { x += rhs.x; y += rhs.y; z += rhs.z; return *this; }
397  Vec3<T>& operator-=( const Vec3<T>& rhs ) { x -= rhs.x; y -= rhs.y; z -= rhs.z; return *this; }
398  Vec3<T>& operator*=( const Vec3<T>& rhs ) { x *= rhs.x; y *= rhs.y; z *= rhs.z; return *this; }
399  Vec3<T>& operator/=( const Vec3<T>& rhs ) { x /= rhs.x; y /= rhs.y; z /= rhs.z; return *this; }
400  const Vec3<T> operator/( T rhs ) const { T invRhs = static_cast<T>( 1.0 ) / rhs; return Vec3<T>( x * invRhs, y * invRhs, z * invRhs ); }
401  Vec3<T>& operator+=( T rhs ) { x += rhs; y += rhs; z += rhs; return *this; }
402  Vec3<T>& operator-=( T rhs ) { x -= rhs; y -= rhs; z -= rhs; return *this; }
403  Vec3<T>& operator*=( T rhs ) { x *= rhs; y *= rhs; z *= rhs; return *this; }
404  Vec3<T>& operator/=( T rhs ) { x /= rhs; y /= rhs; z /= rhs; return *this; }
405 
406  Vec3<T> operator-() const { return Vec3<T>( -x, -y, -z ); } // unary negation
407 
408  bool operator==( const Vec3<T>& rhs ) const
409  {
410  return ( x == rhs.x ) && ( y == rhs.y ) && ( z == rhs.z );
411  }
412 
413  bool operator!=( const Vec3<T>& rhs ) const
414  {
415  return !( *this == rhs );
416  }
417 
418  T dot( const Vec3<T> &rhs ) const
419  {
420  return x*rhs.x + y*rhs.y + z*rhs.z;
421  }
422 
423  Vec3<T> cross( const Vec3<T> &rhs ) const
424  {
425  return Vec3<T>( y * rhs.z - rhs.y * z, z * rhs.x - rhs.z * x, x * rhs.y - rhs.x * y );
426  }
427 
428  T distance( const Vec3<T> &rhs ) const
429  {
430  return ( *this - rhs ).length();
431  }
432 
433  T distanceSquared( const Vec3<T> &rhs ) const
434  {
435  return ( *this - rhs ).lengthSquared();
436  }
437 
438  T length() const
439  {
440  return math<T>::sqrt( x*x + y*y + z*z );
441  }
442 
443  T lengthSquared() const
444  {
445  return x*x + y*y + z*z;
446  }
447 
449  void limit( T maxLength )
450  {
451  T lengthSquared = x * x + y * y + z * z;
452 
453  if( ( lengthSquared > maxLength * maxLength ) && ( lengthSquared > 0 ) ) {
454  T ratio = maxLength / math<T>::sqrt( lengthSquared );
455  x *= ratio;
456  y *= ratio;
457  z *= ratio;
458  }
459  }
460 
463  {
464  T lengthSquared = x * x + y * y + z * z;
465 
466  if( ( lengthSquared > maxLength * maxLength ) && ( lengthSquared > 0 ) ) {
467  T ratio = maxLength / math<T>::sqrt( lengthSquared );
468  return Vec3<T>( x * ratio, y * ratio, z * ratio );
469  }
470  else
471  return *this;
472  }
473 
474  void invert()
475  {
476  x = -x; y = -y; z = -z;
477  }
478 
479  Vec3<T> inverse() const
480  {
481  return Vec3<T>( -x, -y, -z );
482  }
483 
484  void normalize()
485  {
486  T invS = ((T)1) / length();
487  x *= invS;
488  y *= invS;
489  z *= invS;
490  }
491 
493  {
494  T invS = ((T)1) / length();
495  return Vec3<T>( x * invS, y * invS, z * invS );
496  }
497 
498  // tests for zero-length
500  {
501  T s = lengthSquared();
502  if( s > 0 ) {
503  T invS = ((T)1) / math<T>::sqrt( s );
504  x *= invS;
505  y *= invS;
506  z *= invS;
507  }
508  }
509 
511  {
512  T s = lengthSquared();
513  if( s > 0 ) {
514  float invS = ((T)1) / math<T>::sqrt( s );
515  return Vec3<T>( x * invS, y * invS, z * invS );
516  }
517  else
518  return *this;
519  }
520 
523  {
524  if( math<T>::abs( y ) < (T)0.99 ) // abs(dot(u, Y)), somewhat arbitrary epsilon
525  return Vec3<T>( -z, 0, x ); // cross( this, Y )
526  else
527  return Vec3<T>( 0, z, -y ); // cross( this, X )
528  }
529 
530  void rotateX( T angle )
531  {
532  T sina = math<T>::sin(angle);
533  T cosa = math<T>::cos(angle);
534  T ry = y * cosa - z * sina;
535  T rz = y * sina + z * cosa;
536  y = ry;
537  z = rz;
538  }
539 
540  void rotateY( T angle )
541  {
542  T sina = math<T>::sin(angle);
543  T cosa = math<T>::cos(angle);
544  T rx = x * cosa - z * sina;
545  T rz = x * sina + z * cosa;
546  x = rx;
547  z = rz;
548  }
549 
550  void rotateZ( T angle )
551  {
552  T sina = math<T>::sin(angle);
553  T cosa = math<T>::cos(angle);
554  T rx = x * cosa - y * sina;
555  T ry = x * sina + y * cosa;
556  x = rx;
557  y = ry;
558  }
559 
560  void rotate( Vec3<T> axis, T angle )
561  {
562  T cosa = math<T>::cos(angle);
563  T sina = math<T>::sin(angle);
564 
565  T rx = (cosa + (1 - cosa) * axis.x * axis.x) * x;
566  rx += ((1 - cosa) * axis.x * axis.y - axis.z * sina) * y;
567  rx += ((1 - cosa) * axis.x * axis.z + axis.y * sina) * z;
568 
569  T ry = ((1 - cosa) * axis.x * axis.y + axis.z * sina) * x;
570  ry += (cosa + (1 - cosa) * axis.y * axis.y) * y;
571  ry += ((1 - cosa) * axis.y * axis.z - axis.x * sina) * z;
572 
573  T rz = ((1 - cosa) * axis.x * axis.z - axis.y * sina) * x;
574  rz += ((1 - cosa) * axis.y * axis.z + axis.x * sina) * y;
575  rz += (cosa + (1 - cosa) * axis.z * axis.z) * z;
576 
577  x = rx;
578  y = ry;
579  z = rz;
580  }
581 
582  Vec3<T> lerp( T fact, const Vec3<T> &rhs ) const
583  {
584  return (*this) + (rhs - (*this)) * fact;
585  }
586 
587  void lerpEq( T fact, const Vec3<T> &rhs )
588  {
589  x = x + ( rhs.x - x ) * fact; y = y + ( rhs.y - y ) * fact; z = z + ( rhs.z - z ) * fact;
590  }
591 
592  static Vec3<T> max()
593  {
595  }
596 
597  static Vec3<T> zero()
598  {
599  return Vec3<T>( static_cast<T>( 0 ), static_cast<T>( 0 ), static_cast<T>( 0 ) );
600  }
601 
602  static Vec3<T> one()
603  {
604  return Vec3<T>( static_cast<T>( 1 ), static_cast<T>( 1 ), static_cast<T>( 1 ) );
605  }
606 
607  Vec3<T> slerp( T fact, const Vec3<T> &r ) const
608  {
609  T cosAlpha, alpha, sinAlpha;
610  T t1, t2;
611  Vec3<T> result;
612 
613  // get cosine of angle between vectors (-1 -> 1)
614  cosAlpha = this->dot( r );
615 
616  // get angle (0 -> pi)
617  alpha = math<T>::acos( cosAlpha );
618 
619  // get sine of angle between vectors (0 -> 1)
620  sinAlpha = math<T>::sin( alpha );
621 
622  // this breaks down when sinAlpha = 0, i.e. alpha = 0 or pi
623  t1 = math<T>::sin( ((T)1 - fact) * alpha) / sinAlpha;
624  t2 = math<T>::sin( fact * alpha ) / sinAlpha;
625 
626  // interpolate src vectors
627  return *this * t1 + r * t2;
628  }
629 
630  // derived from but not equivalent to Quaternion::squad
631  Vec3<T> squad( T t, const Vec3<T> &tangentA, const Vec3<T> &tangentB, const Vec3<T> &end ) const
632  {
633  Vec3<T> r1 = this->slerp( t, end );
634  Vec3<T> r2 = tangentA.slerp( t, tangentB );
635  return r1.slerp( 2 * t * (1-t), r2 );
636  }
637 
638  // GLSL inspired swizzling functions.
639  Vec2<T> xx() const { return Vec2<T>(x, x); }
640  Vec2<T> xy() const { return Vec2<T>(x, y); }
641  Vec2<T> xz() const { return Vec2<T>(x, z); }
642  Vec2<T> yx() const { return Vec2<T>(y, x); }
643  Vec2<T> yy() const { return Vec2<T>(y, y); }
644  Vec2<T> yz() const { return Vec2<T>(y, z); }
645  Vec2<T> zx() const { return Vec2<T>(z, x); }
646  Vec2<T> zy() const { return Vec2<T>(z, y); }
647  Vec2<T> zz() const { return Vec2<T>(z, z); }
648 
649  Vec3<T> xxx() const { return Vec3<T>(x, x, x); }
650  Vec3<T> xxy() const { return Vec3<T>(x, x, y); }
651  Vec3<T> xxz() const { return Vec3<T>(x, x, z); }
652  Vec3<T> xyx() const { return Vec3<T>(x, y, x); }
653  Vec3<T> xyy() const { return Vec3<T>(x, y, y); }
654  Vec3<T> xyz() const { return Vec3<T>(x, y, z); }
655  Vec3<T> xzx() const { return Vec3<T>(x, z, x); }
656  Vec3<T> xzy() const { return Vec3<T>(x, z, y); }
657  Vec3<T> xzz() const { return Vec3<T>(x, z, z); }
658  Vec3<T> yxx() const { return Vec3<T>(y, x, x); }
659  Vec3<T> yxy() const { return Vec3<T>(y, x, y); }
660  Vec3<T> yxz() const { return Vec3<T>(y, x, z); }
661  Vec3<T> yyx() const { return Vec3<T>(y, y, x); }
662  Vec3<T> yyy() const { return Vec3<T>(y, y, y); }
663  Vec3<T> yyz() const { return Vec3<T>(y, y, z); }
664  Vec3<T> yzx() const { return Vec3<T>(y, z, x); }
665  Vec3<T> yzy() const { return Vec3<T>(y, z, y); }
666  Vec3<T> yzz() const { return Vec3<T>(y, z, z); }
667  Vec3<T> zxx() const { return Vec3<T>(z, x, x); }
668  Vec3<T> zxy() const { return Vec3<T>(z, x, y); }
669  Vec3<T> zxz() const { return Vec3<T>(z, x, z); }
670  Vec3<T> zyx() const { return Vec3<T>(z, y, x); }
671  Vec3<T> zyy() const { return Vec3<T>(z, y, y); }
672  Vec3<T> zyz() const { return Vec3<T>(z, y, z); }
673  Vec3<T> zzx() const { return Vec3<T>(z, z, x); }
674  Vec3<T> zzy() const { return Vec3<T>(z, z, y); }
675  Vec3<T> zzz() const { return Vec3<T>(z, z, z); }
676 
677  friend std::ostream& operator<<( std::ostream& lhs, const Vec3<T> rhs )
678  {
679  lhs << "[" << rhs.x << "," << rhs.y << "," << rhs.z << "]";
680  return lhs;
681  }
682 
683  static Vec3<T> xAxis() { return Vec3<T>( 1, 0, 0 ); }
684  static Vec3<T> yAxis() { return Vec3<T>( 0, 1, 0 ); }
685  static Vec3<T> zAxis() { return Vec3<T>( 0, 0, 1 ); }
686 
687  static Vec3<T> NaN() { return Vec3<T>( math<T>::NaN(), math<T>::NaN(), math<T>::NaN() ); }
688 };
689 
690 template <class T>
691 class Vec4
692 {
693  public:
694  T x,y,z,w;
695 
696  typedef T TYPE;
697  typedef T value_type;
698  static const int DIM = 4;
699 
701  : x( 0 ), y( 0 ), z( 0 ), w( 0 )
702  {}
703  Vec4( T nx, T ny, T nz, T nw = 0 )
704  : x( nx ), y( ny ), z( nz ), w( nw )
705  {}
706  Vec4( const Vec3<T>& src, T aW = 0 )
707  : x( src.x ), y( src.y ), z( src.z ), w( aW )
708  {}
709  Vec4( const Vec4<T>& src )
710  : x( src.x ), y( src.y ), z( src.z ), w( src.w )
711  {}
712  template<typename FromT>
713  Vec4( const Vec4<FromT>& src )
714  : x( static_cast<T>( src.x ) ), y( static_cast<T>( src.y ) ), z( static_cast<T>( src.z ) ),w( static_cast<T>( src.w ) )
715  {}
716  explicit Vec4( const T *d ) : x( d[0] ), y( d[1] ), z( d[2] ), w( d[3] ) {}
717 
718  void set( T ax, T ay, T az, T aw )
719  {
720  x = ax; y = ay; z = az; w = aw;
721  }
722 
723  void set( const Vec4<T> &rhs )
724  {
725  x = rhs.x; y = rhs.y; z = rhs.z; w = rhs.w;
726  }
727 
728  Vec4<T>& operator=( const Vec4<T>& rhs )
729  {
730  x = rhs.x; y = rhs.y; z = rhs.z; w = rhs.w;
731  return *this;
732  }
733 
734  template<typename FromT>
736  {
737  x = static_cast<T>(rhs.x); y = static_cast<T>(rhs.y); z = static_cast<T>(rhs.z); w = static_cast<T>(rhs.w);
738  return *this;
739  }
740 
741  T& operator[]( int n )
742  {
743  assert( n >= 0 && n <= 3 );
744  return (&x)[n];
745  }
746 
747  const T& operator[]( int n ) const
748  {
749  assert( n >= 0 && n <= 3 );
750  return (&x)[n];
751  }
752 
753  T* ptr() const { return &(const_cast<Vec4*>( this )->x); }
754 
755  const Vec4<T> operator+( const Vec4<T>& rhs ) const { return Vec4<T>( x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w ); }
756  const Vec4<T> operator-( const Vec4<T>& rhs ) const { return Vec4<T>( x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w ); }
757  const Vec4<T> operator*( const Vec4<T>& rhs ) const { return Vec4<T>( x * rhs.x, y * rhs.y, z * rhs.z, w * rhs.w ); }
758  const Vec4<T> operator/( const Vec4<T>& rhs ) const { return Vec4<T>( x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w ); }
759  Vec4<T>& operator+=( const Vec4<T>& rhs ) { x += rhs.x; y += rhs.y; z += rhs.z; w += rhs.w; return *this; }
760  Vec4<T>& operator-=( const Vec4<T>& rhs ) { x -= rhs.x; y -= rhs.y; z -= rhs.z; w -= rhs.w; return *this; }
761  Vec4<T>& operator*=( const Vec4<T>& rhs ) { x *= rhs.x; y *= rhs.y; z *= rhs.z; w *= rhs.w; return *this; }
762  Vec4<T>& operator/=( const Vec4<T>& rhs ) { x /= rhs.x; y /= rhs.y; z /= rhs.z; w /= rhs.w; return *this; }
763  const Vec4<T> operator/( T rhs ) const { return Vec4<T>( x / rhs, y / rhs, z / rhs, w / rhs ); }
764  Vec4<T>& operator+=( T rhs ) { x += rhs; y += rhs; z += rhs; w += rhs; return *this; }
765  Vec4<T>& operator-=( T rhs ) { x -= rhs; y -= rhs; z -= rhs; w -= rhs; return * this; }
766  Vec4<T>& operator*=( T rhs ) { x *= rhs; y *= rhs; z *= rhs; w *= rhs; return * this; }
767  Vec4<T>& operator/=( T rhs ) { x /= rhs; y /= rhs; z /= rhs; w /= rhs; return * this; }
768 
769  Vec4<T> operator-() const { return Vec4<T>( -x, -y, -z, -w ); } // unary negation
770 
771  bool operator==( const Vec4<T>& rhs ) const
772  {
773  return ( x == rhs.x ) && ( y == rhs.y ) && ( z == rhs.z ) && ( w == rhs.w );
774  }
775 
776  bool operator!=( const Vec4<T>& rhs ) const
777  {
778  return ! (*this == rhs);
779  }
780 
781  T dot( const Vec4<T> &rhs ) const
782  {
783  return x*rhs.x + y*rhs.y + z*rhs.z;
784  }
785 
786  Vec4<T> cross( const Vec4<T> &rhs ) const
787  {
788  return Vec4<T>( y*rhs.z - rhs.y*z, z*rhs.x - rhs.z*x, x*rhs.y - rhs.x*y );
789  }
790 
791  T distance( const Vec4<T> &rhs ) const
792  {
793  return ( *this - rhs ).length();
794  }
795 
796  T distanceSquared( const Vec4<T> &rhs ) const
797  {
798  return ( *this - rhs ).lengthSquared();
799  }
800 
801  T length() const
802  {
803  // For most vector operations, this assumes w to be zero.
804  return math<T>::sqrt( x*x + y*y + z*z + w*w );
805  }
806 
807  T lengthSquared() const
808  {
809  // For most vector operations, this assumes w to be zero.
810  return x*x + y*y + z*z + w*w;
811  }
812 
813  void normalize()
814  {
815  T invS = ((T)1) / length();
816  x *= invS;
817  y *= invS;
818  z *= invS;
819  w *= invS;
820  }
821 
823  {
824  T invS = ((T)1) / length();
825  return Vec4<T>( x*invS, y*invS, z*invS, w*invS );
826  }
827 
828  // Tests for zero-length
830  {
831  T s = lengthSquared();
832  if( s > 0 ) {
833  T invS = ((T)1) / math<T>::sqrt( s );
834  x *= invS;
835  y *= invS;
836  z *= invS;
837  w = (T)0;
838  }
839  }
840 
842  void limit( T maxLength )
843  {
844  T lenSq = lengthSquared();
845 
846  if( ( lenSq > maxLength * maxLength ) && ( lenSq > 0 ) ) {
847  T ratio = maxLength / math<T>::sqrt( lenSq );
848  x *= ratio;
849  y *= ratio;
850  z *= ratio;
851  w *= ratio;
852  }
853 
854  /*
855  T lengthSquared = x * x + y * y + z * z + w * w;
856 
857  if( ( lengthSquared > maxLength * maxLength ) && ( lengthSquared > 0 ) ) {
858  T ratio = maxLength / math<T>::sqrt( lengthSquared );
859  x *= ratio;
860  y *= ratio;
861  z *= ratio;
862  w *= ratio;
863  }
864  */
865  }
866 
869  {
870  T lenSq = lengthSquared();
871 
872  if( ( lenSq > maxLength * maxLength ) && ( lenSq > 0 ) ) {
873  T ratio = maxLength / math<T>::sqrt( lenSq );
874  return Vec4<T>( x * ratio, y * ratio, z * ratio, w * ratio );
875  }
876  else
877  return *this;
878 
879  /*
880  T lengthSquared = x * x + y * y + z * z + w * w;
881 
882  if( ( lengthSquared > maxLength * maxLength ) && ( lengthSquared > 0 ) ) {
883  T ratio = maxLength / math<T>::sqrt( lengthSquared );
884  return Vec4<T>( x * ratio, y * ratio, z * ratio, w * ratio );
885  }
886  else
887  return *this;
888  */
889  }
890 
891  void invert()
892  {
893  x = -x; y = -y; z = -z; w = -w;
894  }
895 
896  Vec4<T> inverse() const
897  {
898  return Vec4<T>( -x, -y, -z, -w );
899  }
900 
901  Vec4<T> lerp( T fact, const Vec4<T>& r ) const
902  {
903  return (*this) + ( r - (*this) ) * fact;
904  }
905 
906  void lerpEq( T fact, const Vec4<T> &rhs )
907  {
908  x = x + ( rhs.x - x ) * fact; y = y + ( rhs.y - y ) * fact; z = z + ( rhs.z - z ) * fact; w = w + ( rhs.w - w ) * fact;
909  }
910 
911  static Vec4<T> max()
912  {
914  }
915 
916  static Vec4<T> zero()
917  {
918  return Vec4<T>( static_cast<T>( 0 ), static_cast<T>( 0 ), static_cast<T>( 0 ), static_cast<T>( 0 ) );
919  }
920 
921  static Vec4<T> one()
922  {
923  return Vec4<T>( static_cast<T>( 1 ), static_cast<T>( 1 ), static_cast<T>( 1 ), static_cast<T>( 1 ) );
924  }
925 
926  Vec4<T> slerp( T fact, const Vec3<T> &r ) const
927  {
928  T cosAlpha, alpha, sinAlpha;
929  T t1, t2;
930  Vec4<T> result;
931 
932  // get cosine of angle between vectors (-1 -> 1)
933  cosAlpha = this->dot( r );
934 
935  // get angle (0 -> pi)
936  alpha = math<T>::acos( cosAlpha );
937 
938  // get sine of angle between vectors (0 -> 1)
939  sinAlpha = math<T>::sin( alpha );
940 
941  // this breaks down when sinAlpha = 0, i.e. alpha = 0 or pi
942  t1 = math<T>::sin( ((T)1 - fact) * alpha) / sinAlpha;
943  t2 = math<T>::sin( fact * alpha ) / sinAlpha;
944 
945  // interpolate src vectors
946  return *this * t1 + r * t2;
947  }
948 
949  // derived from but not equivalent to Quaternion::squad
950  Vec4<T> squad( T t, const Vec4<T> &tangentA, const Vec4<T> &tangentB, const Vec4<T> &end ) const
951  {
952  Vec4<T> r1 = this->slerp( t, end );
953  Vec4<T> r2 = tangentA.slerp( t, tangentB );
954  return r1.slerp( 2 * t * (1-t), r2 );
955  }
956 
957  // GLSL inspired swizzling functions.
958  Vec2<T> xx() const { return Vec2<T>(x, x); }
959  Vec2<T> xy() const { return Vec2<T>(x, y); }
960  Vec2<T> xz() const { return Vec2<T>(x, z); }
961  Vec2<T> yx() const { return Vec2<T>(y, x); }
962  Vec2<T> yy() const { return Vec2<T>(y, y); }
963  Vec2<T> yz() const { return Vec2<T>(y, z); }
964  Vec2<T> zx() const { return Vec2<T>(z, x); }
965  Vec2<T> zy() const { return Vec2<T>(z, y); }
966  Vec2<T> zz() const { return Vec2<T>(z, z); }
967 
968  Vec3<T> xxx() const { return Vec3<T>(x, x, x); }
969  Vec3<T> xxy() const { return Vec3<T>(x, x, y); }
970  Vec3<T> xxz() const { return Vec3<T>(x, x, z); }
971  Vec3<T> xyx() const { return Vec3<T>(x, y, x); }
972  Vec3<T> xyy() const { return Vec3<T>(x, y, y); }
973  Vec3<T> xyz() const { return Vec3<T>(x, y, z); }
974  Vec3<T> xzx() const { return Vec3<T>(x, z, x); }
975  Vec3<T> xzy() const { return Vec3<T>(x, z, y); }
976  Vec3<T> xzz() const { return Vec3<T>(x, z, z); }
977  Vec3<T> yxx() const { return Vec3<T>(y, x, x); }
978  Vec3<T> yxy() const { return Vec3<T>(y, x, y); }
979  Vec3<T> yxz() const { return Vec3<T>(y, x, z); }
980  Vec3<T> yyx() const { return Vec3<T>(y, y, x); }
981  Vec3<T> yyy() const { return Vec3<T>(y, y, y); }
982  Vec3<T> yyz() const { return Vec3<T>(y, y, z); }
983  Vec3<T> yzx() const { return Vec3<T>(y, z, x); }
984  Vec3<T> yzy() const { return Vec3<T>(y, z, y); }
985  Vec3<T> yzz() const { return Vec3<T>(y, z, z); }
986  Vec3<T> zxx() const { return Vec3<T>(z, x, x); }
987  Vec3<T> zxy() const { return Vec3<T>(z, x, y); }
988  Vec3<T> zxz() const { return Vec3<T>(z, x, z); }
989  Vec3<T> zyx() const { return Vec3<T>(z, y, x); }
990  Vec3<T> zyy() const { return Vec3<T>(z, y, y); }
991  Vec3<T> zyz() const { return Vec3<T>(z, y, z); }
992  Vec3<T> zzx() const { return Vec3<T>(z, z, x); }
993  Vec3<T> zzy() const { return Vec3<T>(z, z, y); }
994  Vec3<T> zzz() const { return Vec3<T>(z, z, z); }
995 
996  Vec4<T> xxxx() const { return Vec4<T>(x, x, x, x); }
997  Vec4<T> xxxy() const { return Vec4<T>(x, x, x, y); }
998  Vec4<T> xxxz() const { return Vec4<T>(x, x, x, z); }
999  Vec4<T> xxxw() const { return Vec4<T>(x, x, x, w); }
1000  Vec4<T> xxyx() const { return Vec4<T>(x, x, y, x); }
1001  Vec4<T> xxyy() const { return Vec4<T>(x, x, y, y); }
1002  Vec4<T> xxyz() const { return Vec4<T>(x, x, y, z); }
1003  Vec4<T> xxyw() const { return Vec4<T>(x, x, y, w); }
1004  Vec4<T> xxzx() const { return Vec4<T>(x, x, z, x); }
1005  Vec4<T> xxzy() const { return Vec4<T>(x, x, z, y); }
1006  Vec4<T> xxzz() const { return Vec4<T>(x, x, z, z); }
1007  Vec4<T> xxzw() const { return Vec4<T>(x, x, z, w); }
1008  Vec4<T> xxwx() const { return Vec4<T>(x, x, w, x); }
1009  Vec4<T> xxwy() const { return Vec4<T>(x, x, w, y); }
1010  Vec4<T> xxwz() const { return Vec4<T>(x, x, w, z); }
1011  Vec4<T> xxww() const { return Vec4<T>(x, x, w, w); }
1012  Vec4<T> xyxx() const { return Vec4<T>(x, y, x, x); }
1013  Vec4<T> xyxy() const { return Vec4<T>(x, y, x, y); }
1014  Vec4<T> xyxz() const { return Vec4<T>(x, y, x, z); }
1015  Vec4<T> xyxw() const { return Vec4<T>(x, y, x, w); }
1016  Vec4<T> xyyx() const { return Vec4<T>(x, y, y, x); }
1017  Vec4<T> xyyy() const { return Vec4<T>(x, y, y, y); }
1018  Vec4<T> xyyz() const { return Vec4<T>(x, y, y, z); }
1019  Vec4<T> xyyw() const { return Vec4<T>(x, y, y, w); }
1020  Vec4<T> xyzx() const { return Vec4<T>(x, y, z, x); }
1021  Vec4<T> xyzy() const { return Vec4<T>(x, y, z, y); }
1022  Vec4<T> xyzz() const { return Vec4<T>(x, y, z, z); }
1023  Vec4<T> xyzw() const { return Vec4<T>(x, y, z, w); }
1024  Vec4<T> xywx() const { return Vec4<T>(x, y, w, x); }
1025  Vec4<T> xywy() const { return Vec4<T>(x, y, w, y); }
1026  Vec4<T> xywz() const { return Vec4<T>(x, y, w, z); }
1027  Vec4<T> xyww() const { return Vec4<T>(x, y, w, w); }
1028  Vec4<T> xzxx() const { return Vec4<T>(x, z, x, x); }
1029  Vec4<T> xzxy() const { return Vec4<T>(x, z, x, y); }
1030  Vec4<T> xzxz() const { return Vec4<T>(x, z, x, z); }
1031  Vec4<T> xzxw() const { return Vec4<T>(x, z, x, w); }
1032  Vec4<T> xzyx() const { return Vec4<T>(x, z, y, x); }
1033  Vec4<T> xzyy() const { return Vec4<T>(x, z, y, y); }
1034  Vec4<T> xzyz() const { return Vec4<T>(x, z, y, z); }
1035  Vec4<T> xzyw() const { return Vec4<T>(x, z, y, w); }
1036  Vec4<T> xzzx() const { return Vec4<T>(x, z, z, x); }
1037  Vec4<T> xzzy() const { return Vec4<T>(x, z, z, y); }
1038  Vec4<T> xzzz() const { return Vec4<T>(x, z, z, z); }
1039  Vec4<T> xzzw() const { return Vec4<T>(x, z, z, w); }
1040  Vec4<T> xzwx() const { return Vec4<T>(x, z, w, x); }
1041  Vec4<T> xzwy() const { return Vec4<T>(x, z, w, y); }
1042  Vec4<T> xzwz() const { return Vec4<T>(x, z, w, z); }
1043  Vec4<T> xzww() const { return Vec4<T>(x, z, w, w); }
1044  Vec4<T> xwxx() const { return Vec4<T>(x, w, x, x); }
1045  Vec4<T> xwxy() const { return Vec4<T>(x, w, x, y); }
1046  Vec4<T> xwxz() const { return Vec4<T>(x, w, x, z); }
1047  Vec4<T> xwxw() const { return Vec4<T>(x, w, x, w); }
1048  Vec4<T> xwyx() const { return Vec4<T>(x, w, y, x); }
1049  Vec4<T> xwyy() const { return Vec4<T>(x, w, y, y); }
1050  Vec4<T> xwyz() const { return Vec4<T>(x, w, y, z); }
1051  Vec4<T> xwyw() const { return Vec4<T>(x, w, y, w); }
1052  Vec4<T> xwzx() const { return Vec4<T>(x, w, z, x); }
1053  Vec4<T> xwzy() const { return Vec4<T>(x, w, z, y); }
1054  Vec4<T> xwzz() const { return Vec4<T>(x, w, z, z); }
1055  Vec4<T> xwzw() const { return Vec4<T>(x, w, z, w); }
1056  Vec4<T> xwwx() const { return Vec4<T>(x, w, w, x); }
1057  Vec4<T> xwwy() const { return Vec4<T>(x, w, w, y); }
1058  Vec4<T> xwwz() const { return Vec4<T>(x, w, w, z); }
1059  Vec4<T> xwww() const { return Vec4<T>(x, w, w, w); }
1060  Vec4<T> yxxx() const { return Vec4<T>(y, x, x, x); }
1061  Vec4<T> yxxy() const { return Vec4<T>(y, x, x, y); }
1062  Vec4<T> yxxz() const { return Vec4<T>(y, x, x, z); }
1063  Vec4<T> yxxw() const { return Vec4<T>(y, x, x, w); }
1064  Vec4<T> yxyx() const { return Vec4<T>(y, x, y, x); }
1065  Vec4<T> yxyy() const { return Vec4<T>(y, x, y, y); }
1066  Vec4<T> yxyz() const { return Vec4<T>(y, x, y, z); }
1067  Vec4<T> yxyw() const { return Vec4<T>(y, x, y, w); }
1068  Vec4<T> yxzx() const { return Vec4<T>(y, x, z, x); }
1069  Vec4<T> yxzy() const { return Vec4<T>(y, x, z, y); }
1070  Vec4<T> yxzz() const { return Vec4<T>(y, x, z, z); }
1071  Vec4<T> yxzw() const { return Vec4<T>(y, x, z, w); }
1072  Vec4<T> yxwx() const { return Vec4<T>(y, x, w, x); }
1073  Vec4<T> yxwy() const { return Vec4<T>(y, x, w, y); }
1074  Vec4<T> yxwz() const { return Vec4<T>(y, x, w, z); }
1075  Vec4<T> yxww() const { return Vec4<T>(y, x, w, w); }
1076  Vec4<T> yyxx() const { return Vec4<T>(y, y, x, x); }
1077  Vec4<T> yyxy() const { return Vec4<T>(y, y, x, y); }
1078  Vec4<T> yyxz() const { return Vec4<T>(y, y, x, z); }
1079  Vec4<T> yyxw() const { return Vec4<T>(y, y, x, w); }
1080  Vec4<T> yyyx() const { return Vec4<T>(y, y, y, x); }
1081  Vec4<T> yyyy() const { return Vec4<T>(y, y, y, y); }
1082  Vec4<T> yyyz() const { return Vec4<T>(y, y, y, z); }
1083  Vec4<T> yyyw() const { return Vec4<T>(y, y, y, w); }
1084  Vec4<T> yyzx() const { return Vec4<T>(y, y, z, x); }
1085  Vec4<T> yyzy() const { return Vec4<T>(y, y, z, y); }
1086  Vec4<T> yyzz() const { return Vec4<T>(y, y, z, z); }
1087  Vec4<T> yyzw() const { return Vec4<T>(y, y, z, w); }
1088  Vec4<T> yywx() const { return Vec4<T>(y, y, w, x); }
1089  Vec4<T> yywy() const { return Vec4<T>(y, y, w, y); }
1090  Vec4<T> yywz() const { return Vec4<T>(y, y, w, z); }
1091  Vec4<T> yyww() const { return Vec4<T>(y, y, w, w); }
1092  Vec4<T> yzxx() const { return Vec4<T>(y, z, x, x); }
1093  Vec4<T> yzxy() const { return Vec4<T>(y, z, x, y); }
1094  Vec4<T> yzxz() const { return Vec4<T>(y, z, x, z); }
1095  Vec4<T> yzxw() const { return Vec4<T>(y, z, x, w); }
1096  Vec4<T> yzyx() const { return Vec4<T>(y, z, y, x); }
1097  Vec4<T> yzyy() const { return Vec4<T>(y, z, y, y); }
1098  Vec4<T> yzyz() const { return Vec4<T>(y, z, y, z); }
1099  Vec4<T> yzyw() const { return Vec4<T>(y, z, y, w); }
1100  Vec4<T> yzzx() const { return Vec4<T>(y, z, z, x); }
1101  Vec4<T> yzzy() const { return Vec4<T>(y, z, z, y); }
1102  Vec4<T> yzzz() const { return Vec4<T>(y, z, z, z); }
1103  Vec4<T> yzzw() const { return Vec4<T>(y, z, z, w); }
1104  Vec4<T> yzwx() const { return Vec4<T>(y, z, w, x); }
1105  Vec4<T> yzwy() const { return Vec4<T>(y, z, w, y); }
1106  Vec4<T> yzwz() const { return Vec4<T>(y, z, w, z); }
1107  Vec4<T> yzww() const { return Vec4<T>(y, z, w, w); }
1108  Vec4<T> ywxx() const { return Vec4<T>(y, w, x, x); }
1109  Vec4<T> ywxy() const { return Vec4<T>(y, w, x, y); }
1110  Vec4<T> ywxz() const { return Vec4<T>(y, w, x, z); }
1111  Vec4<T> ywxw() const { return Vec4<T>(y, w, x, w); }
1112  Vec4<T> ywyx() const { return Vec4<T>(y, w, y, x); }
1113  Vec4<T> ywyy() const { return Vec4<T>(y, w, y, y); }
1114  Vec4<T> ywyz() const { return Vec4<T>(y, w, y, z); }
1115  Vec4<T> ywyw() const { return Vec4<T>(y, w, y, w); }
1116  Vec4<T> ywzx() const { return Vec4<T>(y, w, z, x); }
1117  Vec4<T> ywzy() const { return Vec4<T>(y, w, z, y); }
1118  Vec4<T> ywzz() const { return Vec4<T>(y, w, z, z); }
1119  Vec4<T> ywzw() const { return Vec4<T>(y, w, z, w); }
1120  Vec4<T> ywwx() const { return Vec4<T>(y, w, w, x); }
1121  Vec4<T> ywwy() const { return Vec4<T>(y, w, w, y); }
1122  Vec4<T> ywwz() const { return Vec4<T>(y, w, w, z); }
1123  Vec4<T> ywww() const { return Vec4<T>(y, w, w, w); }
1124  Vec4<T> zxxx() const { return Vec4<T>(z, x, x, x); }
1125  Vec4<T> zxxy() const { return Vec4<T>(z, x, x, y); }
1126  Vec4<T> zxxz() const { return Vec4<T>(z, x, x, z); }
1127  Vec4<T> zxxw() const { return Vec4<T>(z, x, x, w); }
1128  Vec4<T> zxyx() const { return Vec4<T>(z, x, y, x); }
1129  Vec4<T> zxyy() const { return Vec4<T>(z, x, y, y); }
1130  Vec4<T> zxyz() const { return Vec4<T>(z, x, y, z); }
1131  Vec4<T> zxyw() const { return Vec4<T>(z, x, y, w); }
1132  Vec4<T> zxzx() const { return Vec4<T>(z, x, z, x); }
1133  Vec4<T> zxzy() const { return Vec4<T>(z, x, z, y); }
1134  Vec4<T> zxzz() const { return Vec4<T>(z, x, z, z); }
1135  Vec4<T> zxzw() const { return Vec4<T>(z, x, z, w); }
1136  Vec4<T> zxwx() const { return Vec4<T>(z, x, w, x); }
1137  Vec4<T> zxwy() const { return Vec4<T>(z, x, w, y); }
1138  Vec4<T> zxwz() const { return Vec4<T>(z, x, w, z); }
1139  Vec4<T> zxww() const { return Vec4<T>(z, x, w, w); }
1140  Vec4<T> zyxx() const { return Vec4<T>(z, y, x, x); }
1141  Vec4<T> zyxy() const { return Vec4<T>(z, y, x, y); }
1142  Vec4<T> zyxz() const { return Vec4<T>(z, y, x, z); }
1143  Vec4<T> zyxw() const { return Vec4<T>(z, y, x, w); }
1144  Vec4<T> zyyx() const { return Vec4<T>(z, y, y, x); }
1145  Vec4<T> zyyy() const { return Vec4<T>(z, y, y, y); }
1146  Vec4<T> zyyz() const { return Vec4<T>(z, y, y, z); }
1147  Vec4<T> zyyw() const { return Vec4<T>(z, y, y, w); }
1148  Vec4<T> zyzx() const { return Vec4<T>(z, y, z, x); }
1149  Vec4<T> zyzy() const { return Vec4<T>(z, y, z, y); }
1150  Vec4<T> zyzz() const { return Vec4<T>(z, y, z, z); }
1151  Vec4<T> zyzw() const { return Vec4<T>(z, y, z, w); }
1152  Vec4<T> zywx() const { return Vec4<T>(z, y, w, x); }
1153  Vec4<T> zywy() const { return Vec4<T>(z, y, w, y); }
1154  Vec4<T> zywz() const { return Vec4<T>(z, y, w, z); }
1155  Vec4<T> zyww() const { return Vec4<T>(z, y, w, w); }
1156  Vec4<T> zzxx() const { return Vec4<T>(z, z, x, x); }
1157  Vec4<T> zzxy() const { return Vec4<T>(z, z, x, y); }
1158  Vec4<T> zzxz() const { return Vec4<T>(z, z, x, z); }
1159  Vec4<T> zzxw() const { return Vec4<T>(z, z, x, w); }
1160  Vec4<T> zzyx() const { return Vec4<T>(z, z, y, x); }
1161  Vec4<T> zzyy() const { return Vec4<T>(z, z, y, y); }
1162  Vec4<T> zzyz() const { return Vec4<T>(z, z, y, z); }
1163  Vec4<T> zzyw() const { return Vec4<T>(z, z, y, w); }
1164  Vec4<T> zzzx() const { return Vec4<T>(z, z, z, x); }
1165  Vec4<T> zzzy() const { return Vec4<T>(z, z, z, y); }
1166  Vec4<T> zzzz() const { return Vec4<T>(z, z, z, z); }
1167  Vec4<T> zzzw() const { return Vec4<T>(z, z, z, w); }
1168  Vec4<T> zzwx() const { return Vec4<T>(z, z, w, x); }
1169  Vec4<T> zzwy() const { return Vec4<T>(z, z, w, y); }
1170  Vec4<T> zzwz() const { return Vec4<T>(z, z, w, z); }
1171  Vec4<T> zzww() const { return Vec4<T>(z, z, w, w); }
1172  Vec4<T> zwxx() const { return Vec4<T>(z, w, x, x); }
1173  Vec4<T> zwxy() const { return Vec4<T>(z, w, x, y); }
1174  Vec4<T> zwxz() const { return Vec4<T>(z, w, x, z); }
1175  Vec4<T> zwxw() const { return Vec4<T>(z, w, x, w); }
1176  Vec4<T> zwyx() const { return Vec4<T>(z, w, y, x); }
1177  Vec4<T> zwyy() const { return Vec4<T>(z, w, y, y); }
1178  Vec4<T> zwyz() const { return Vec4<T>(z, w, y, z); }
1179  Vec4<T> zwyw() const { return Vec4<T>(z, w, y, w); }
1180  Vec4<T> zwzx() const { return Vec4<T>(z, w, z, x); }
1181  Vec4<T> zwzy() const { return Vec4<T>(z, w, z, y); }
1182  Vec4<T> zwzz() const { return Vec4<T>(z, w, z, z); }
1183  Vec4<T> zwzw() const { return Vec4<T>(z, w, z, w); }
1184  Vec4<T> zwwx() const { return Vec4<T>(z, w, w, x); }
1185  Vec4<T> zwwy() const { return Vec4<T>(z, w, w, y); }
1186  Vec4<T> zwwz() const { return Vec4<T>(z, w, w, z); }
1187  Vec4<T> zwww() const { return Vec4<T>(z, w, w, w); }
1188  Vec4<T> wxxx() const { return Vec4<T>(w, x, x, x); }
1189  Vec4<T> wxxy() const { return Vec4<T>(w, x, x, y); }
1190  Vec4<T> wxxz() const { return Vec4<T>(w, x, x, z); }
1191  Vec4<T> wxxw() const { return Vec4<T>(w, x, x, w); }
1192  Vec4<T> wxyx() const { return Vec4<T>(w, x, y, x); }
1193  Vec4<T> wxyy() const { return Vec4<T>(w, x, y, y); }
1194  Vec4<T> wxyz() const { return Vec4<T>(w, x, y, z); }
1195  Vec4<T> wxyw() const { return Vec4<T>(w, x, y, w); }
1196  Vec4<T> wxzx() const { return Vec4<T>(w, x, z, x); }
1197  Vec4<T> wxzy() const { return Vec4<T>(w, x, z, y); }
1198  Vec4<T> wxzz() const { return Vec4<T>(w, x, z, z); }
1199  Vec4<T> wxzw() const { return Vec4<T>(w, x, z, w); }
1200  Vec4<T> wxwx() const { return Vec4<T>(w, x, w, x); }
1201  Vec4<T> wxwy() const { return Vec4<T>(w, x, w, y); }
1202  Vec4<T> wxwz() const { return Vec4<T>(w, x, w, z); }
1203  Vec4<T> wxww() const { return Vec4<T>(w, x, w, w); }
1204  Vec4<T> wyxx() const { return Vec4<T>(w, y, x, x); }
1205  Vec4<T> wyxy() const { return Vec4<T>(w, y, x, y); }
1206  Vec4<T> wyxz() const { return Vec4<T>(w, y, x, z); }
1207  Vec4<T> wyxw() const { return Vec4<T>(w, y, x, w); }
1208  Vec4<T> wyyx() const { return Vec4<T>(w, y, y, x); }
1209  Vec4<T> wyyy() const { return Vec4<T>(w, y, y, y); }
1210  Vec4<T> wyyz() const { return Vec4<T>(w, y, y, z); }
1211  Vec4<T> wyyw() const { return Vec4<T>(w, y, y, w); }
1212  Vec4<T> wyzx() const { return Vec4<T>(w, y, z, x); }
1213  Vec4<T> wyzy() const { return Vec4<T>(w, y, z, y); }
1214  Vec4<T> wyzz() const { return Vec4<T>(w, y, z, z); }
1215  Vec4<T> wyzw() const { return Vec4<T>(w, y, z, w); }
1216  Vec4<T> wywx() const { return Vec4<T>(w, y, w, x); }
1217  Vec4<T> wywy() const { return Vec4<T>(w, y, w, y); }
1218  Vec4<T> wywz() const { return Vec4<T>(w, y, w, z); }
1219  Vec4<T> wyww() const { return Vec4<T>(w, y, w, w); }
1220  Vec4<T> wzxx() const { return Vec4<T>(w, z, x, x); }
1221  Vec4<T> wzxy() const { return Vec4<T>(w, z, x, y); }
1222  Vec4<T> wzxz() const { return Vec4<T>(w, z, x, z); }
1223  Vec4<T> wzxw() const { return Vec4<T>(w, z, x, w); }
1224  Vec4<T> wzyx() const { return Vec4<T>(w, z, y, x); }
1225  Vec4<T> wzyy() const { return Vec4<T>(w, z, y, y); }
1226  Vec4<T> wzyz() const { return Vec4<T>(w, z, y, z); }
1227  Vec4<T> wzyw() const { return Vec4<T>(w, z, y, w); }
1228  Vec4<T> wzzx() const { return Vec4<T>(w, z, z, x); }
1229  Vec4<T> wzzy() const { return Vec4<T>(w, z, z, y); }
1230  Vec4<T> wzzz() const { return Vec4<T>(w, z, z, z); }
1231  Vec4<T> wzzw() const { return Vec4<T>(w, z, z, w); }
1232  Vec4<T> wzwx() const { return Vec4<T>(w, z, w, x); }
1233  Vec4<T> wzwy() const { return Vec4<T>(w, z, w, y); }
1234  Vec4<T> wzwz() const { return Vec4<T>(w, z, w, z); }
1235  Vec4<T> wzww() const { return Vec4<T>(w, z, w, w); }
1236  Vec4<T> wwxx() const { return Vec4<T>(w, w, x, x); }
1237  Vec4<T> wwxy() const { return Vec4<T>(w, w, x, y); }
1238  Vec4<T> wwxz() const { return Vec4<T>(w, w, x, z); }
1239  Vec4<T> wwxw() const { return Vec4<T>(w, w, x, w); }
1240  Vec4<T> wwyx() const { return Vec4<T>(w, w, y, x); }
1241  Vec4<T> wwyy() const { return Vec4<T>(w, w, y, y); }
1242  Vec4<T> wwyz() const { return Vec4<T>(w, w, y, z); }
1243  Vec4<T> wwyw() const { return Vec4<T>(w, w, y, w); }
1244  Vec4<T> wwzx() const { return Vec4<T>(w, w, z, x); }
1245  Vec4<T> wwzy() const { return Vec4<T>(w, w, z, y); }
1246  Vec4<T> wwzz() const { return Vec4<T>(w, w, z, z); }
1247  Vec4<T> wwzw() const { return Vec4<T>(w, w, z, w); }
1248  Vec4<T> wwwx() const { return Vec4<T>(w, w, w, x); }
1249  Vec4<T> wwwy() const { return Vec4<T>(w, w, w, y); }
1250  Vec4<T> wwwz() const { return Vec4<T>(w, w, w, z); }
1251  Vec4<T> wwww() const { return Vec4<T>(w, w, w, w); }
1252 
1253  friend std::ostream& operator<<( std::ostream& lhs, const Vec4<T>& rhs )
1254  {
1255  lhs << "[" << rhs.x << "," << rhs.y << "," << rhs.z << "," << rhs.w << "]";
1256  return lhs;
1257  }
1258 
1259  static Vec4<T> xAxis() { return Vec4<T>( 1, 0, 0, 0 ); }
1260  static Vec4<T> yAxis() { return Vec4<T>( 0, 1, 0, 0 ); }
1261  static Vec4<T> zAxis() { return Vec4<T>( 0, 0, 1, 0 ); }
1262  static Vec4<T> wAxis() { return Vec4<T>( 0, 0, 0, 1 ); }
1263 
1265 };
1266 
1268 template<typename T>
1270 {
1271  const T epsilon = (T)0.0000001;
1272  T theta;
1273  if( math<T>::abs( car.x ) < epsilon ) { // x == 0
1274  if( math<T>::abs( car.y ) < epsilon ) theta = 0;
1275  else if( car.y > 0 ) theta = (T)M_PI / 2;
1276  else theta = ( (T)M_PI * 3 ) / 2;
1277  }
1278  else if ( car.x > 0 ) {
1279  if( car.y < 0 ) theta = math<T>::atan( car.y / car.x ) + 2 * (T)M_PI;
1280  else theta = math<T>::atan( car.y / car.x );
1281  }
1282  else // car.x < 0
1283  theta = (math<T>::atan( car.y / car.x ) + M_PI );
1284 
1285  return Vec2<T>( car.length(), theta );
1286 }
1287 
1289 template<typename T>
1291 {
1292  return Vec2<T>( math<T>::cos( pol.y ) * pol.x , math<T>::sin( pol.y ) * pol.x );
1293 }
1294 
1295 template<typename T,typename Y> inline Vec2<T> operator *( Y s, const Vec2<T> &v ) { return Vec2<T>( v.x * s, v.y * s ); }
1296 template<typename T,typename Y> inline Vec2<T> operator *( const Vec2<T> &v, Y s ) { return Vec2<T>( v.x * s, v.y * s ); }
1297 template<typename T,typename Y> inline Vec3<T> operator *( Y s, const Vec3<T> &v ) { return Vec3<T>( v.x * s, v.y * s, v.z * s ); }
1298 template<typename T,typename Y> inline Vec3<T> operator *( const Vec3<T> &v, Y s ) { return Vec3<T>( v.x * s, v.y * s, v.z * s ); }
1299 template<typename T,typename Y> inline Vec4<T> operator *( Y s, const Vec4<T> &v ) { return Vec4<T>( v.x * s, v.y * s, v.z * s, v.w * s ); }
1300 template<typename T,typename Y> inline Vec4<T> operator *( const Vec4<T> &v, Y s ) { return Vec4<T>( v.x * s, v.y * s, v.z * s, v.w * s ); }
1301 
1302 template <typename T> T dot( const Vec2<T>& a, const Vec2<T>& b ) { return a.dot( b ); }
1303 template <typename T> T dot( const Vec3<T>& a, const Vec3<T>& b ) { return a.dot( b ); }
1304 template <typename T> T dot( const Vec4<T>& a, const Vec4<T>& b ) { return a.dot( b ); }
1305 
1306 template <typename T> Vec3<T> cross( const Vec3<T>& a, const Vec3<T>& b ) { return a.cross( b ); }
1307 template <typename T> Vec4<T> cross( const Vec4<T>& a, const Vec4<T>& b ) { return a.cross( b ); }
1308 
1309 template <typename T> bool isNaN( const Vec2<T>& a ) { return std::isnan( a.x ) || std::isnan( a.y ); }
1310 template <typename T> bool isNaN( const Vec3<T>& a ) { return std::isnan( a.x ) || std::isnan( a.y ) || std::isnan( a.z ); }
1311 template <typename T> bool isNaN( const Vec4<T>& a ) { return std::isnan( a.x ) || std::isnan( a.y ) || std::isnan( a.z ) || std::isnan( a.w ); }
1312 
1322 
1323 } // namespace cinder
Vec4< T > zzzy() const
Definition: Vector.h:1165
Vec4< T > xzxw() const
Definition: Vector.h:1031
Vec4< T > yyyx() const
Definition: Vector.h:1080
Vec3< T > zxy() const
Definition: Vector.h:668
static T sqrt(T x)
Definition: CinderMath.h:63
static Vec4< T > one()
Definition: Vector.h:921
Vec4< T > zxzy() const
Definition: Vector.h:1133
GLdouble GLdouble GLdouble r
Definition: GLee.h:1474
Vec4< T > wzyx() const
Definition: Vector.h:1224
Vec4< T > xzxx() const
Definition: Vector.h:1028
bool operator!=(const Vec2< T > &rhs) const
Definition: Vector.h:149
const Vec3< T > operator/(const Vec3< T > &rhs) const
Definition: Vector.h:395
Vec4< T > zxzx() const
Definition: Vector.h:1132
Vec3< T > safeNormalized() const
Definition: Vector.h:510
Vec3< T > & operator=(const Vec3< FromT > &rhs)
Definition: Vector.h:370
T x
Definition: Vector.h:694
Vec4< T > yywx() const
Definition: Vector.h:1088
Vec4< T > normalized() const
Definition: Vector.h:822
Vec4< T > xzyz() const
Definition: Vector.h:1034
T * ptr() const
Definition: Vector.h:390
Vec4< T > wxyx() const
Definition: Vector.h:1192
Vec4< T > wwzw() const
Definition: Vector.h:1247
GLenum GLint GLint y
Definition: GLee.h:987
Vec2< T > xx() const
Definition: Vector.h:958
Vec4< T > zwxx() const
Definition: Vector.h:1172
Vec2< T > & operator=(const Vec2< T > &rhs)
Definition: Vector.h:107
T lengthSquared() const
Definition: Vector.h:443
void limit(DIST maxLength)
Limits the length of a Vec2 to maxLength, scaling it proportionally if necessary. ...
Definition: Vector.h:230
Definition: CinderMath.h:40
Vec2< T > xy() const
Definition: Vector.h:640
static T cos(T x)
Definition: CinderMath.h:46
void invert()
Definition: Vector.h:891
Vec3< T > xxz() const
Definition: Vector.h:651
Vec4< T > xyzw() const
Definition: Vector.h:1023
bool isNaN(const Vec2< T > &a)
Definition: Vector.h:1309
Vec4< T > zzwx() const
Definition: Vector.h:1168
Vec4< T > wwwy() const
Definition: Vector.h:1249
Vec4< T > xyyx() const
Definition: Vector.h:1016
Vec4< T > yzww() const
Definition: Vector.h:1107
Vec2< T > xx() const
Definition: Vector.h:276
Vec3< T > yzy() const
Definition: Vector.h:984
Vec4< T > yzwz() const
Definition: Vector.h:1106
Vec4< T > xyxw() const
Definition: Vector.h:1015
const Vec2< T > operator+(const Vec2< T > &rhs) const
Definition: Vector.h:128
Vec4< T > wzyz() const
Definition: Vector.h:1226
Vec4< T > wwyx() const
Definition: Vector.h:1240
void safeNormalize()
Definition: Vector.h:194
Vec4< T > xxyw() const
Definition: Vector.h:1003
Vec4< T > yzzx() const
Definition: Vector.h:1100
Vec4< T > yyzx() const
Definition: Vector.h:1084
Vec4< T > wzxy() const
Definition: Vector.h:1221
GLfloat GLfloat nz
Definition: GLee.h:8437
const Vec3< T > operator/(T rhs) const
Definition: Vector.h:400
Vec3< T > zzx() const
Definition: Vector.h:992
Vec3< T > zzx() const
Definition: Vector.h:673
Vec3< T > yzz() const
Definition: Vector.h:666
T dot(const Vec3< T > &rhs) const
Definition: Vector.h:418
Vec4< T > xxyx() const
Definition: Vector.h:1000
Vec3< T > operator-() const
Definition: Vector.h:406
int int * max
Definition: GLee.h:17208
Vec3(const Vec3< FromT > &src)
Definition: Vector.h:342
Vec3< T > yzy() const
Definition: Vector.h:665
Vec4< T > xzyw() const
Definition: Vector.h:1035
void normalize()
Definition: Vector.h:484
Vec2< float > Vec2f
Definition: Vector.h:1314
const Vec4< T > operator+(const Vec4< T > &rhs) const
Definition: Vector.h:755
Vec4< T > wxzw() const
Definition: Vector.h:1199
const Vec4< T > operator/(T rhs) const
Definition: Vector.h:763
T value_type
Definition: Vector.h:697
Vec4< T > yzyz() const
Definition: Vector.h:1098
void safeNormalize()
Definition: Vector.h:499
Vec4< T > yxxz() const
Definition: Vector.h:1062
Vec2< T > & operator/=(const Vec2< T > &rhs)
Definition: Vector.h:135
T dot(const Vec2< T > &a, const Vec2< T > &b)
Definition: Vector.h:1302
Vec4< T > yxwx() const
Definition: Vector.h:1072
Vec3< T > & operator+=(T rhs)
Definition: Vector.h:401
Vec4< T > xwyz() const
Definition: Vector.h:1050
Vec4(const Vec3< T > &src, T aW=0)
Definition: Vector.h:706
static Vec2< T > yAxis()
Definition: Vector.h:312
Vec4< T > zyxz() const
Definition: Vector.h:1142
static T sin(T x)
Definition: CinderMath.h:47
Vec4< T > zzwy() const
Definition: Vector.h:1169
Vec4< T > xxyy() const
Definition: Vector.h:1001
Vec4< T > zwzz() const
Definition: Vector.h:1182
T y
Definition: Vector.h:694
Vec4< T > xyzy() const
Definition: Vector.h:1021
Vec4< T > ywyw() const
Definition: Vector.h:1115
Vec4(const Vec4< T > &src)
Definition: Vector.h:709
Vec3< T > xzy() const
Definition: Vector.h:975
const T & operator[](int n) const
Definition: Vector.h:384
Vec4< T > zwyx() const
Definition: Vector.h:1176
Vec3< T > zxx() const
Definition: Vector.h:667
void invert()
Definition: Vector.h:474
Vec4< T > xyyy() const
Definition: Vector.h:1017
void set(T ax, T ay, T az)
Definition: Vector.h:351
Vec4< T > xyzz() const
Definition: Vector.h:1022
Vec4< T > wyzy() const
Definition: Vector.h:1213
T value_type
Definition: Vector.h:324
Vec3< T > lerp(T fact, const Vec3< T > &rhs) const
Definition: Vector.h:582
Vec3()
Definition: Vector.h:327
DIST distance(const Vec2< T > &rhs) const
Definition: Vector.h:165
Vec4< T > xzxz() const
Definition: Vector.h:1030
Vec4< T > wxww() const
Definition: Vector.h:1203
Vec4< T > xyzx() const
Definition: Vector.h:1020
Vec4< T > zyzx() const
Definition: Vector.h:1148
Vec4< T > yyxw() const
Definition: Vector.h:1079
T z
Definition: Vector.h:694
Vec4< T > ywzz() const
Definition: Vector.h:1118
Vec3< T > & operator/=(const Vec3< T > &rhs)
Definition: Vector.h:399
T & operator[](int n)
Definition: Vector.h:741
Vec4< T > wxxz() const
Definition: Vector.h:1190
void normalize()
Definition: Vector.h:180
void set(const Vec4< T > &rhs)
Definition: Vector.h:723
T z
Definition: Vector.h:321
Vec2< T > toPolar(Vec2< T > car)
Converts a coordinate from rectangular (Cartesian) coordinates to polar coordinates of the form (radi...
Definition: Vector.h:1269
T w
Definition: Vector.h:694
Vec4(const Vec4< FromT > &src)
Definition: Vector.h:713
Vec4< T > wxxx() const
Definition: Vector.h:1188
Vec4< float > Vec4f
Definition: Vector.h:1320
bool operator==(const Vec4< T > &rhs) const
Definition: Vector.h:771
Vec3< T > xzy() const
Definition: Vector.h:656
GLuint src
Definition: GLee.h:10873
Vec4< T > cross(const Vec4< T > &rhs) const
Definition: Vector.h:786
Vec3< T > xyx() const
Definition: Vector.h:283
Vec4< T > & operator*=(T rhs)
Definition: Vector.h:766
T x
Definition: Vector.h:321
Vec4< T > zzyz() const
Definition: Vector.h:1162
Definition: Vector.h:691
static Vec2< T > NaN()
Definition: Vector.h:314
Vec4< T > xwxw() const
Definition: Vector.h:1047
Vec3< T > zyx() const
Definition: Vector.h:670
static Vec2< T > zero()
Definition: Vector.h:295
Vec3< T > yxx() const
Definition: Vector.h:658
GLfloat ny
Definition: GLee.h:8437
Vec3< T > xyz() const
Definition: Vector.h:654
Vec4< T > ywxz() const
Definition: Vector.h:1110
Vec4< T > & operator+=(T rhs)
Definition: Vector.h:764
Vec4< T > yywy() const
Definition: Vector.h:1089
Vec3< T > yxy() const
Definition: Vector.h:978
Vec3< T > limited(T maxLength) const
Returns a copy of the Vec3 with its length limited to maxLength, scaling it proportionally if necessa...
Definition: Vector.h:462
Vec3< T > xzz() const
Definition: Vector.h:657
Vec4< T > & operator=(const Vec4< FromT > &rhs)
Definition: Vector.h:735
T x
Definition: Vector.h:71
GLfloat angle
Definition: GLee.h:13523
Vec2< T > zz() const
Definition: Vector.h:966
Vec4< T > xxzw() const
Definition: Vector.h:1007
void limit(T maxLength)
Limits the length of a Vec4 to maxLength, scaling it proportionally if necessary. ...
Definition: Vector.h:842
Vec2< T > normalized() const
Definition: Vector.h:187
Vec3(const Vec2< T > &v2, T aZ)
Definition: Vector.h:334
Vec4< T > zxzw() const
Definition: Vector.h:1135
Vec4< T > wywz() const
Definition: Vector.h:1218
Vec4< T > & operator=(const Vec4< T > &rhs)
Definition: Vector.h:728
Vec3< T > xxy() const
Definition: Vector.h:969
Vec4< T > xwxz() const
Definition: Vector.h:1046
T y
Definition: Vector.h:321
Vec4< T > zyzy() const
Definition: Vector.h:1149
Vec4< T > yyww() const
Definition: Vector.h:1091
void rotateX(T angle)
Definition: Vector.h:530
Vec2(const Vec2< T > &src)
Definition: Vector.h:80
Vec4< T > yzxx() const
Definition: Vector.h:1092
Vec3< T > yzx() const
Definition: Vector.h:983
Vec4< T > wxzy() const
Definition: Vector.h:1197
T dot(const Vec2< T > &rhs) const
Definition: Vector.h:154
Vec3< T > yyx() const
Definition: Vector.h:980
Vec4< T > xxyz() const
Definition: Vector.h:1002
Vec4< T > wyzw() const
Definition: Vector.h:1215
Vec4< T > zyxx() const
Definition: Vector.h:1140
static Vec3< T > zero()
Definition: Vector.h:597
const Vec4< T > operator/(const Vec4< T > &rhs) const
Definition: Vector.h:758
Vec4< T > xwyw() const
Definition: Vector.h:1051
Vec4< T > ywyz() const
Definition: Vector.h:1114
static Vec4< T > xAxis()
Definition: Vector.h:1259
Vec4< T > wzwy() const
Definition: Vector.h:1233
Vec4< T > yzyw() const
Definition: Vector.h:1099
void lerpEq(T fact, const Vec2< T > &rhs)
Definition: Vector.h:270
Vec4< T > wyzx() const
Definition: Vector.h:1212
Vec2< T > zy() const
Definition: Vector.h:965
void set(const Vec3< T > &rhs)
Definition: Vector.h:356
Vec4< T > yzyy() const
Definition: Vector.h:1097
Vec3< T > zzy() const
Definition: Vector.h:993
Vec4< int > Vec4i
Definition: Vector.h:1319
ColorT< T > operator*(Y s, const ColorT< T > &c)
Definition: Color.h:391
T distance(const Vec3< T > &rhs) const
Definition: Vector.h:428
Vec4< T > wzzz() const
Definition: Vector.h:1230
Vec4< T > wyxx() const
Definition: Vector.h:1204
Vec3< T > yyy() const
Definition: Vector.h:981
Vec4< T > yzxw() const
Definition: Vector.h:1095
Vec4< T > xwww() const
Definition: Vector.h:1059
Vec3< T > yyz() const
Definition: Vector.h:982
const Vec2< T > operator/(const Vec2< T > &rhs) const
Definition: Vector.h:131
Vec3< T > zzz() const
Definition: Vector.h:675
T cross(const Vec2< T > &rhs) const
Returns the z component of the cross if the two operands were Vec3's on the XY plane, the equivalent of Vec3(*this).cross( Vec3(rhs) ).z.
Definition: Vector.h:160
Vec4< T > zwxz() const
Definition: Vector.h:1174
Vec3< T > yyz() const
Definition: Vector.h:663
Vec4< T > xwxy() const
Definition: Vector.h:1045
Vec4< T > xyww() const
Definition: Vector.h:1027
T TYPE
Definition: Vector.h:73
Vec4< T > xwwy() const
Definition: Vector.h:1057
Vec4< T > yxyw() const
Definition: Vector.h:1067
Vec4< T > zwwy() const
Definition: Vector.h:1185
void normalize()
Definition: Vector.h:813
static Vec4< T > zAxis()
Definition: Vector.h:1261
Vec4()
Definition: Vector.h:700
Vec4< T > zwyy() const
Definition: Vector.h:1177
Vec4< T > wwwx() const
Definition: Vector.h:1248
Vec4< T > ywzy() const
Definition: Vector.h:1117
T & operator[](int n)
Definition: Vector.h:378
Vec4< T > wzwz() const
Definition: Vector.h:1234
Vec4< T > yywz() const
Definition: Vector.h:1090
T dot(const Vec4< T > &rhs) const
Definition: Vector.h:781
Vec4< T > xzzz() const
Definition: Vector.h:1038
Vec4< T > yyzz() const
Definition: Vector.h:1086
Vec4< T > & operator*=(const Vec4< T > &rhs)
Definition: Vector.h:761
const Vec2< T > operator-(const Vec2< T > &rhs) const
Definition: Vector.h:129
Definition: Vector.h:68
Vec4< T > xwzy() const
Definition: Vector.h:1053
const T & operator[](int n) const
Definition: Vector.h:120
const Vec4< T > operator*(const Vec4< T > &rhs) const
Definition: Vector.h:757
Vec3< T > xzz() const
Definition: Vector.h:976
Vec4< T > ywzx() const
Definition: Vector.h:1116
Vec4< T > & operator-=(T rhs)
Definition: Vector.h:765
Vec4< T > squad(T t, const Vec4< T > &tangentA, const Vec4< T > &tangentB, const Vec4< T > &end) const
Definition: Vector.h:950
Vec3< T > zyx() const
Definition: Vector.h:989
const T & operator[](int n) const
Definition: Vector.h:747
void rotate(Vec3< T > axis, T angle)
Definition: Vector.h:560
static const int DIM
Definition: Vector.h:325
Vec4< T > wxxw() const
Definition: Vector.h:1191
Vec3< float > Vec3f
Definition: Vector.h:1317
static Vec3< T > yAxis()
Definition: Vector.h:684
Vec4< T > zxxx() const
Definition: Vector.h:1124
Vec4< T > zyzz() const
Definition: Vector.h:1150
Vec4< T > zxyz() const
Definition: Vector.h:1130
Vec4< T > ywxw() const
Definition: Vector.h:1111
Vec2< T > xz() const
Definition: Vector.h:641
Vec4< T > ywzw() const
Definition: Vector.h:1119
Vec4< T > yxzy() const
Definition: Vector.h:1069
Vec3< T > yyx() const
Definition: Vector.h:287
T lengthSquared() const
Definition: Vector.h:807
Vec4< double > Vec4d
Definition: Vector.h:1321
Vec2< T > zx() const
Definition: Vector.h:964
void lerpEq(T fact, const Vec4< T > &rhs)
Definition: Vector.h:906
Vec4< T > yzwy() const
Definition: Vector.h:1105
Vec4< T > ywww() const
Definition: Vector.h:1123
const Vec3< T > operator-(const Vec3< T > &rhs) const
Definition: Vector.h:393
Vec4< T > wwxy() const
Definition: Vector.h:1237
Vec4< T > zzxx() const
Definition: Vector.h:1156
Definition: Vector.h:65
Vec2< T > & operator=(const Vec2< FromT > &rhs)
Definition: Vector.h:100
Vec4< T > xxzx() const
Definition: Vector.h:1004
Vec2< double > Vec2d
Definition: Vector.h:1315
Vec4< T > xwyy() const
Definition: Vector.h:1049
Vec4< T > wyxz() const
Definition: Vector.h:1206
static Vec2< T > xAxis()
Definition: Vector.h:311
Vec4< T > ywyy() const
Definition: Vector.h:1113
Vec3< T > & operator/=(T rhs)
Definition: Vector.h:404
Vec2< T > yz() const
Definition: Vector.h:644
Vec3< T > getOrthogonal() const
Returns a vector which is orthogonal to this.
Definition: Vector.h:522
Vec2()
Definition: Vector.h:78
Vec4< T > wwxw() const
Definition: Vector.h:1239
Vec4< T > xzwx() const
Definition: Vector.h:1040
Vec4< T > wwxz() const
Definition: Vector.h:1238
Vec4< T > xxwz() const
Definition: Vector.h:1010
Vec4< T > wyzz() const
Definition: Vector.h:1214
Vec4< T > wwyz() const
Definition: Vector.h:1242
Vec3< T > yzz() const
Definition: Vector.h:985
Vec2(const Vec2< FromT > &src)
Definition: Vector.h:84
Vec3< T > yzx() const
Definition: Vector.h:664
Vec4< T > xxxy() const
Definition: Vector.h:997
Vec4< T > zyxy() const
Definition: Vector.h:1141
Vec4< T > & operator/=(T rhs)
Definition: Vector.h:767
Vec4< T > zwzy() const
Definition: Vector.h:1181
Vec4< T > zzxw() const
Definition: Vector.h:1159
Vec3(const T *d)
Definition: Vector.h:340
Vec4< T > wxwy() const
Definition: Vector.h:1201
Vec4< T > wxxy() const
Definition: Vector.h:1189
GLclampf GLclampf GLclampf alpha
Definition: GLee.h:951
Vec2< T > xx() const
Definition: Vector.h:639
Vec4< T > ywwz() const
Definition: Vector.h:1122
Vec2< T > safeNormalized() const
Definition: Vector.h:204
Vec3< T > cross(const Vec3< T > &a, const Vec3< T > &b)
Definition: Vector.h:1306
Vec4< T > wywx() const
Definition: Vector.h:1216
static T acos(T x)
Definition: CinderMath.h:42
T TYPE
Definition: Vector.h:323
void rotate(DIST radians)
Definition: Vector.h:215
static Vec4< T > NaN()
Definition: Vector.h:1264
bool operator==(const Vec3< T > &rhs) const
Definition: Vector.h:408
Vec4< T > xywx() const
Definition: Vector.h:1024
Vec4(const T *d)
Definition: Vector.h:716
Vec4< T > xyyw() const
Definition: Vector.h:1019
Vec3(const Vec2< T > &v2)
Definition: Vector.h:337
Vec3< T > xzx() const
Definition: Vector.h:655
Vec4< T > xyxz() const
Definition: Vector.h:1014
Vec4< T > zzzw() const
Definition: Vector.h:1167
Vec3< T > slerp(T fact, const Vec3< T > &r) const
Definition: Vector.h:607
Vec4< T > wxzz() const
Definition: Vector.h:1198
Vec3< T > yyy() const
Definition: Vector.h:288
Vec3< T > yyy() const
Definition: Vector.h:662
Vec4< T > wyyw() const
Definition: Vector.h:1211
Vec3< T > xxy() const
Definition: Vector.h:650
Vec4< T > xywz() const
Definition: Vector.h:1026
Vec4< T > wyxw() const
Definition: Vector.h:1207
Vec4< T > xxwx() const
Definition: Vector.h:1008
Vec4< T > yzwx() const
Definition: Vector.h:1104
Vec4< T > wyww() const
Definition: Vector.h:1219
Vec4< T > ywwx() const
Definition: Vector.h:1120
Vec4< T > wzzx() const
Definition: Vector.h:1228
Vec4< T > limited(T maxLength) const
Returns a copy of the Vec4 with its length limited to maxLength, scaling it proportionally if necessa...
Definition: Vector.h:868
GLfloat GLfloat GLfloat v2
Definition: GLee.h:2451
bool operator!=(const Vec3< T > &rhs) const
Definition: Vector.h:413
Vec3< T > xzx() const
Definition: Vector.h:974
Vec4< T > xwzz() const
Definition: Vector.h:1054
Vec4< T > zywy() const
Definition: Vector.h:1153
GLenum GLint x
Definition: GLee.h:987
Vec4< T > wwzz() const
Definition: Vector.h:1246
Vec4< T > wzzw() const
Definition: Vector.h:1231
Vec3< T > zyy() const
Definition: Vector.h:671
Vec4< T > xwwz() const
Definition: Vector.h:1058
Vec4< T > wzyw() const
Definition: Vector.h:1227
static Vec4< T > wAxis()
Definition: Vector.h:1262
Vec3< T > xyy() const
Definition: Vector.h:972
Vec3< T > yxy() const
Definition: Vector.h:659
Vec4< T > xwwx() const
Definition: Vector.h:1056
GLenum GLsizei n
Definition: GLee.h:5780
Vec4< T > zyyx() const
Definition: Vector.h:1144
Vec4< T > xwxx() const
Definition: Vector.h:1044
Vec4< T > wzxx() const
Definition: Vector.h:1220
void lerpEq(T fact, const Vec3< T > &rhs)
Definition: Vector.h:587
Vec4< T > ywyx() const
Definition: Vector.h:1112
Vec2< T > & operator+=(T rhs)
Definition: Vector.h:137
Vec3< T > zzz() const
Definition: Vector.h:994
Vec4< T > xzzw() const
Definition: Vector.h:1039
Vec4< T > zxwy() const
Definition: Vector.h:1137
void safeNormalize()
Definition: Vector.h:829
GLfloat GLfloat GLfloat GLfloat nx
Definition: GLee.h:8449
Vec4< T > xzwz() const
Definition: Vector.h:1042
Vec3< T > xxx() const
Definition: Vector.h:968
Vec4< T > ywwy() const
Definition: Vector.h:1121
Vec4< T > zxzz() const
Definition: Vector.h:1134
Vec4< T > xxxz() const
Definition: Vector.h:998
Vec4< T > wzwx() const
Definition: Vector.h:1232
VECTRAIT< T >::DIST DIST
Definition: Vector.h:75
Vec4< T > xyyz() const
Definition: Vector.h:1018
Vec3< T > xyz() const
Definition: Vector.h:973
Vec4< T > xxwy() const
Definition: Vector.h:1009
Vec4< T > xxxx() const
Definition: Vector.h:996
Vec2< T > & operator/=(T rhs)
Definition: Vector.h:140
Vec4< T > xzzx() const
Definition: Vector.h:1036
Vec2< T > inverse() const
Definition: Vector.h:260
Vec2< T > xy() const
Definition: Vector.h:959
const GLdouble * v
Definition: GLee.h:1384
Vec2< T > & operator-=(const Vec2< T > &rhs)
Definition: Vector.h:133
Vec4< T > wxyw() const
Definition: Vector.h:1195
Vec4< T > ywxy() const
Definition: Vector.h:1109
Vec4< T > yxww() const
Definition: Vector.h:1075
Vec2< T > & operator+=(const Vec2< T > &rhs)
Definition: Vector.h:132
T distanceSquared(const Vec4< T > &rhs) const
Definition: Vector.h:796
GLdouble GLdouble z
Definition: GLee.h:1911
GLboolean GLboolean GLboolean b
Definition: GLee.h:2964
Vec4< T > xyxx() const
Definition: Vector.h:1012
Vec4< T > zzww() const
Definition: Vector.h:1171
Vec2< T > yy() const
Definition: Vector.h:643
Vec3< T > zyz() const
Definition: Vector.h:672
T distanceSquared(const Vec3< T > &rhs) const
Definition: Vector.h:433
Vec3< T > xyx() const
Definition: Vector.h:652
Vec4< T > wxyy() const
Definition: Vector.h:1193
DIST length() const
Definition: Vector.h:175
Vec4< T > wxwx() const
Definition: Vector.h:1200
Vec4< T > xzww() const
Definition: Vector.h:1043
Vec4< T > ywxx() const
Definition: Vector.h:1108
const Vec3< T > operator*(const Vec3< T > &rhs) const
Definition: Vector.h:394
T lengthSquared() const
Definition: Vector.h:224
Vec2< T > xz() const
Definition: Vector.h:960
Vec4< T > xyxy() const
Definition: Vector.h:1013
T y
Definition: Vector.h:71
Vec4< T > yyyy() const
Definition: Vector.h:1081
Vec4< T > zzzx() const
Definition: Vector.h:1164
Vec4< T > wwwz() const
Definition: Vector.h:1250
Vec4< T > zwyz() const
Definition: Vector.h:1178
Vec2(T nx, T ny)
Definition: Vector.h:79
Vec3< T > xxx() const
Definition: Vector.h:281
const Vec2< T > operator*(const Vec2< T > &rhs) const
Definition: Vector.h:130
Vec4< T > zwxw() const
Definition: Vector.h:1175
Vec3< T > yxz() const
Definition: Vector.h:660
GLuint GLuint end
Definition: GLee.h:963
Vec4< T > yxyz() const
Definition: Vector.h:1066
Vec3< T > yxy() const
Definition: Vector.h:286
Vec4< T > zxyy() const
Definition: Vector.h:1129
T & operator[](int n)
Definition: Vector.h:114
Vec4< T > zxwz() const
Definition: Vector.h:1138
Vec4< T > wwzy() const
Definition: Vector.h:1245
Vec4< T > wyyx() const
Definition: Vector.h:1208
Vec3< T > zxz() const
Definition: Vector.h:669
Vec3< T > xxz() const
Definition: Vector.h:970
Vec2< T > yy() const
Definition: Vector.h:962
Vec2< T > & operator*=(const Vec2< T > &rhs)
Definition: Vector.h:134
Vec3< double > Vec3d
Definition: Vector.h:1318
bool operator==(const Vec2< T > &rhs) const
Definition: Vector.h:144
const Vec3< T > operator+(const Vec3< T > &rhs) const
Definition: Vector.h:392
Vec3< T > zxy() const
Definition: Vector.h:987
T value_type
Definition: Vector.h:74
#define M_PI
Definition: CinderMath.h:121
Vec4< T > wywy() const
Definition: Vector.h:1217
Vec3< T > zxz() const
Definition: Vector.h:988
Vec4< T > yxxw() const
Definition: Vector.h:1063
Vec4< T > wwxx() const
Definition: Vector.h:1236
Vec4< T > zxww() const
Definition: Vector.h:1139
Vec4< T > wxzx() const
Definition: Vector.h:1196
Vec3< T > xyx() const
Definition: Vector.h:971
Vec4< T > zzwz() const
Definition: Vector.h:1170
Vec4< T > yyzw() const
Definition: Vector.h:1087
Vec4(T nx, T ny, T nz, T nw=0)
Definition: Vector.h:703
Vec4< T > yzzw() const
Definition: Vector.h:1103
Vec4< T > yyyz() const
Definition: Vector.h:1082
Vec3< T > cross(const Vec3< T > &rhs) const
Definition: Vector.h:423
Vec4< T > yxzz() const
Definition: Vector.h:1070
Vec4< T > xzwy() const
Definition: Vector.h:1041
static Vec3< T > xAxis()
Definition: Vector.h:683
Vec4< T > wzyy() const
Definition: Vector.h:1225
GLboolean GLboolean GLboolean GLboolean a
Definition: GLee.h:2964
static T atan(T x)
Definition: CinderMath.h:44
Vec4< T > & operator-=(const Vec4< T > &rhs)
Definition: Vector.h:760
Vec4< T > yxzx() const
Definition: Vector.h:1068
Vec4< T > xwzx() const
Definition: Vector.h:1052
Vec4< T > zzyx() const
Definition: Vector.h:1160
Vec4< T > zzxy() const
Definition: Vector.h:1157
Vec4< T > wwyw() const
Definition: Vector.h:1243
Vec4< T > xxww() const
Definition: Vector.h:1011
Vec4< T > wyyz() const
Definition: Vector.h:1210
Vec4< T > zxxw() const
Definition: Vector.h:1127
Vec4< T > zzyy() const
Definition: Vector.h:1161
void set(T ax, T ay, T az, T aw)
Definition: Vector.h:718
Vec3< T > xxy() const
Definition: Vector.h:282
Vec4< T > & operator/=(const Vec4< T > &rhs)
Definition: Vector.h:762
Vec4< T > xzyy() const
Definition: Vector.h:1033
Vec2< T > yx() const
Definition: Vector.h:961
Vec4< T > zxxy() const
Definition: Vector.h:1125
static Vec4< T > yAxis()
Definition: Vector.h:1260
Vec4< T > yyxy() const
Definition: Vector.h:1077
Vec2< T > zy() const
Definition: Vector.h:646
Vec3< T > zxx() const
Definition: Vector.h:986
Vec4< T > zyyw() const
Definition: Vector.h:1147
Vec4< T > xxzy() const
Definition: Vector.h:1005
Vec4< T > yxyy() const
Definition: Vector.h:1065
Vec4< T > zyxw() const
Definition: Vector.h:1143
Vec4< T > wyxy() const
Definition: Vector.h:1205
Vec3< T > yyx() const
Definition: Vector.h:661
void invert()
Definition: Vector.h:254
Vec4< T > yyxx() const
Definition: Vector.h:1076
static Vec4< T > max()
Definition: Vector.h:911
Vec4< T > & operator+=(const Vec4< T > &rhs)
Definition: Vector.h:759
Vec2< T > yy() const
Definition: Vector.h:279
Vec4< T > zxxz() const
Definition: Vector.h:1126
void set(const Vec2< T > &rhs)
Definition: Vector.h:93
Vec3(const Vec3< T > &src)
Definition: Vector.h:331
Vec2< T > yx() const
Definition: Vector.h:278
Vec4< T > wzxw() const
Definition: Vector.h:1223
Vec2(const T *d)
Definition: Vector.h:81
Vec4< T > wxyz() const
Definition: Vector.h:1194
Vec4< T > xzxy() const
Definition: Vector.h:1029
bool operator!=(const Vec4< T > &rhs) const
Definition: Vector.h:776
Vec4< T > zyyz() const
Definition: Vector.h:1146
void rotateY(T angle)
Definition: Vector.h:540
Vec4< T > xxzz() const
Definition: Vector.h:1006
Vec4< T > zywx() const
Definition: Vector.h:1152
Vec4< T > yzxz() const
Definition: Vector.h:1094
Vec4< T > yyxz() const
Definition: Vector.h:1078
Vec4< T > yzzy() const
Definition: Vector.h:1101
Vec3< T > xxx() const
Definition: Vector.h:649
Vec4< T > xywy() const
Definition: Vector.h:1025
static Vec3< T > NaN()
Definition: Vector.h:687
Vec4< T > zywz() const
Definition: Vector.h:1154
Vec4< T > zzzz() const
Definition: Vector.h:1166
Vec2< T > lerp(T fact, const Vec2< T > &r) const
Definition: Vector.h:265
static Vec3< T > one()
Definition: Vector.h:602
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:2685
static const int DIM
Definition: Vector.h:76
Vec4< T > yxyx() const
Definition: Vector.h:1064
void rotateZ(T angle)
Definition: Vector.h:550
T length() const
Definition: Vector.h:438
Vec4< T > wzww() const
Definition: Vector.h:1235
Vec4< T > zxyx() const
Definition: Vector.h:1128
T * ptr() const
Definition: Vector.h:753
Vec4< T > wwzx() const
Definition: Vector.h:1244
static Vec2< T > max()
Definition: Vector.h:290
Vec4< T > zwwz() const
Definition: Vector.h:1186
Vec3< T > & operator+=(const Vec3< T > &rhs)
Definition: Vector.h:396
Vec4< T > yxxx() const
Definition: Vector.h:1060
Vec2< T > & operator-=(T rhs)
Definition: Vector.h:138
void set(T ax, T ay)
Definition: Vector.h:88
Vec4< T > yzxy() const
Definition: Vector.h:1093
static Vec4< T > zero()
Definition: Vector.h:916
Vec3< T > xyy() const
Definition: Vector.h:653
Vec2< T > zz() const
Definition: Vector.h:647
Vec3(const Y &v)
Definition: Vector.h:346
const Vec2< T > operator/(T rhs) const
Definition: Vector.h:136
Vec2< T > limited(T maxLength) const
Returns a copy of the Vec2 with its length limited to maxLength, scaling it proportionally if necessa...
Definition: Vector.h:242
T TYPE
Definition: Vector.h:696
Vec4< T > yyyw() const
Definition: Vector.h:1083
Vec4< T > slerp(T fact, const Vec3< T > &r) const
Definition: Vector.h:926
Vec4< T > yzzz() const
Definition: Vector.h:1102
Vec2< T > xy() const
Definition: Vector.h:277
Vec2< T > yx() const
Definition: Vector.h:642
Vec4< T > zxyw() const
Definition: Vector.h:1131
Vec4< T > wzzy() const
Definition: Vector.h:1229
Vec4< T > zwwx() const
Definition: Vector.h:1184
void limit(T maxLength)
Limits the length of a Vec3 to maxLength, scaling it proportionally if necessary. ...
Definition: Vector.h:449
Vec4< T > zyzw() const
Definition: Vector.h:1151
GLdouble GLdouble t
Definition: GLee.h:1426
Vec2< T > operator-() const
Definition: Vector.h:142
Vec4< T > xxxw() const
Definition: Vector.h:999
GLdouble s
Definition: GLee.h:1378
Vec3< T > & operator*=(const Vec3< T > &rhs)
Definition: Vector.h:398
Vec4< T > yxwz() const
Definition: Vector.h:1074
Vec4< T > wwww() const
Definition: Vector.h:1251
Vec4< T > inverse() const
Definition: Vector.h:896
Vec3< T > zzy() const
Definition: Vector.h:674
Vec2< T > zx() const
Definition: Vector.h:645
Vec4< T > xzyx() const
Definition: Vector.h:1032
Vec3< T > xyy() const
Definition: Vector.h:284
Vec4< T > zwxy() const
Definition: Vector.h:1173
Vec3< T > & operator=(const Vec3< T > &rhs)
Definition: Vector.h:361
Vec4< T > zwzx() const
Definition: Vector.h:1180
Vec4< T > yxzw() const
Definition: Vector.h:1071
Vec4< T > zyyy() const
Definition: Vector.h:1145
Vec4< T > zwzw() const
Definition: Vector.h:1183
Vec3< T > squad(T t, const Vec3< T > &tangentA, const Vec3< T > &tangentB, const Vec3< T > &end) const
Definition: Vector.h:631
Vec3< T > yxz() const
Definition: Vector.h:979
Vec2< T > yz() const
Definition: Vector.h:963
Vec4< T > wyyy() const
Definition: Vector.h:1209
Vec3< T > yxx() const
Definition: Vector.h:285
Vec4< T > wxwz() const
Definition: Vector.h:1202
Vec4< T > xwzw() const
Definition: Vector.h:1055
Vec3< T > inverse() const
Definition: Vector.h:479
Vec3< T > & operator*=(T rhs)
Definition: Vector.h:403
Vec4< T > xzzy() const
Definition: Vector.h:1037
Vec3< T > yxx() const
Definition: Vector.h:977
Vec4< T > zyww() const
Definition: Vector.h:1155
T distance(const Vec4< T > &rhs) const
Definition: Vector.h:791
Vec4< T > wzxz() const
Definition: Vector.h:1222
Vec3< T > & operator-=(const Vec3< T > &rhs)
Definition: Vector.h:397
static Vec3< T > max()
Definition: Vector.h:592
Vec4< T > xwyx() const
Definition: Vector.h:1048
Vec3< T > zyy() const
Definition: Vector.h:990
Vec2< T > fromPolar(Vec2< T > pol)
Converts a coordinate from polar coordinates of the form (radius, theta) to rectangular coordinates...
Definition: Vector.h:1290
Vec3(T nx, T ny, T nz)
Definition: Vector.h:328
Vec2< T > & operator*=(T rhs)
Definition: Vector.h:139
T length() const
Definition: Vector.h:801
Vec4< T > yzyx() const
Definition: Vector.h:1096
static const int DIM
Definition: Vector.h:698
T distanceSquared(const Vec2< T > &rhs) const
Definition: Vector.h:170
Vec4< T > zzxz() const
Definition: Vector.h:1158
static Vec2< T > one()
Definition: Vector.h:300
Vec3< int > Vec3i
Definition: Vector.h:1316
Vec4< T > zwww() const
Definition: Vector.h:1187
Vec4< T > wwyy() const
Definition: Vector.h:1241
Vec4< T > lerp(T fact, const Vec4< T > &r) const
Definition: Vector.h:901
GLsizei maxLength
Definition: GLee.h:4974
Vec4< T > yxwy() const
Definition: Vector.h:1073
Vec4< T > zzyw() const
Definition: Vector.h:1163
Vec3< T > & operator-=(T rhs)
Definition: Vector.h:402
Vec4< T > operator-() const
Definition: Vector.h:769
Vec4< T > yxxy() const
Definition: Vector.h:1061
T * ptr() const
Definition: Vector.h:126
Vec4< T > zwyw() const
Definition: Vector.h:1179
Vec2< int > Vec2i
Definition: Vector.h:1313
Vec3< T > normalized() const
Definition: Vector.h:492
const Vec4< T > operator-(const Vec4< T > &rhs) const
Definition: Vector.h:756
Vec3< T > zyz() const
Definition: Vector.h:991
Vec4< T > zxwx() const
Definition: Vector.h:1136
Vec4< T > yyzy() const
Definition: Vector.h:1085
static Vec3< T > zAxis()
Definition: Vector.h:685