Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MatrixAffine2.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012, The Cinder Project: http://libcinder.org All rights reserved.
3  This code is intended for use with the Cinder C++ library: http://libcinder.org
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 
24 #pragma once
25 
26 #include "cinder/Cinder.h"
27 #include "cinder/CinderMath.h"
28 #include "cinder/Vector.h"
29 
30 #include <iomanip>
31 
32 namespace cinder {
33 
35 // MatrixAffine2
37 template<typename T>
39 {
40  public:
41  typedef T TYPE;
42  typedef T value_type;
43  //
44  static const size_t MEM_LEN = sizeof(T)*6;
45 
46  //
47  // This class is OpenGL friendly and stores the m as how OpenGL would expect it.
48  // m[i,j]:
49  // | m[0,0] m[0,1] m[0,2] |
50  // | m[1,0] m[1,1] m[1,2] |
51  //
52  // m[idx]
53  // | m[0] m[2] m[4] |
54  // | m[1] m[3] m[5] |
55  //
56  // mathematically this is:
57  // | m[0] m[2] m[4] |
58  // | m[1] m[3] m[5] |
59  // | 0 0 1 |
60  union {
61  T m[6];
62  struct {
63  // This looks like it's transposed from the above, but it's really not.
64  // It just has to be written this way so it follows the right ordering
65  // in the memory layout as well as being mathematically correct.
66  T m00, m10;
67  T m01, m11;
68  T m02, m12;
69  };
70  // [Cols][Rows]
71  T mcols[3][2];
72  };
73 
74  MatrixAffine2();
75  MatrixAffine2( T s );
76  MatrixAffine2( const T *dt );
77  // m[0]=d0, m[1]=d1, m[2]=d2 ... m[5]=d5
78  MatrixAffine2( T d0, T d1, T d2, T d3, T d4, T d5 );
79  // Creates matrix with column vectors vx, vy and z
80  MatrixAffine2( const Vec2<T> &vx, const Vec2<T> &vy, const Vec2<T> &vz );
81 
82  template<typename FromT>
85 
87  MatrixAffine2<T>& operator=( T rhs );
88 
89  template<typename FromT>
91 
92  bool equalCompare( const MatrixAffine2<T>& rhs, T epsilon ) const;
93  bool operator==( const MatrixAffine2<T> &rhs ) const { return equalCompare( rhs, (T)EPSILON ); }
94  bool operator!=( const MatrixAffine2<T> &rhs ) const { return ! ( *this == rhs ); }
95 
99 
104 
105  const MatrixAffine2<T> operator*( const MatrixAffine2<T> &rhs ) const;
106  const MatrixAffine2<T> operator+( const MatrixAffine2<T> &rhs ) const;
107  const MatrixAffine2<T> operator-( const MatrixAffine2<T> &rhs ) const;
108 
110  Vec2<T> transformPoint( const Vec2<T> &rhs ) const;
112  const Vec2<T> operator*( const Vec2<T> &rhs ) const;
114  Vec2<T> transformVec( const Vec2<T> &v ) const;
115 
116  const MatrixAffine2<T> operator*( T rhs ) const;
117  const MatrixAffine2<T> operator/( T rhs ) const;
118  const MatrixAffine2<T> operator+( T rhs ) const;
119  const MatrixAffine2<T> operator-( T rhs ) const;
120 
121  // Accessors
122  T& at( int row, int col );
123  const T& at( int row, int col ) const;
124 
125  T& operator[]( int idx ) { return m[idx]; }
126  const T& operator[]( int idx ) const { return m[idx]; }
127 
128 
129  void set( const T *dt );
130  // m[0]=d0, m[1]=d1, m[2]=d2 ... m[5]=d5
131  void set( T d0, T d1, T d2, T d3, T d4, T d5 );
132 
133  Vec2<T> getColumn( int col ) const;
134  void setColumn( int col, const Vec2<T> &v );
135 
136  Vec3<T> getRow( int row ) const;
137  void setRow( int row, const Vec3<T> &v );
138 
139  void getColumns( Vec2<T> *c0, Vec2<T> *c1, Vec2<T> *c2 ) const;
140  void setColumns( const Vec2<T> &c0, const Vec2<T> &c1, const Vec2<T> &c2 );
141 
142  void getRows( Vec3<T> *r0, Vec3<T> *r1, Vec3<T> *r2 ) const;
143  void setRows( const Vec3<T> &r0, const Vec3<T> &r1, const Vec3<T> &r2 );
144 
146  void setToNull();
148  void setToIdentity();
149 
151  bool isSingular() const;
152 
154  void invert(T epsilon = EPSILON ) { *this = invertCopy( epsilon ); }
156  MatrixAffine2<T> invertCopy( T epsilon = EPSILON ) const;
157 
159  void translate( const Vec2<T> &v );
161  MatrixAffine2 translateCopy( const Vec2<T> &v ) const { MatrixAffine2 result = *this; result.translate( v ); return result; }
162 
164  void rotate( T radians ) { *this *= MatrixAffine2<T>::makeRotate( radians ); }
166  void rotate( T radians, const Vec2<T> &pt ) { *this *= MatrixAffine2<T>::makeRotate( radians, pt ); }
168  MatrixAffine2 rotateCopy( T radians ) const { MatrixAffine2 result = *this; result.rotate( radians ); return result; }
170  MatrixAffine2 rotateCopy( T radians, const Vec2<T> &pt ) const { MatrixAffine2 result = *this; result.rotate( radians, pt ); return result; }
171 
173  void scale( T s );
175  void scale( const Vec2<T> &v );
177  MatrixAffine2 scaleCopy( T s ) const { MatrixAffine2 result = *this; result.scale( s ); return result; }
179  MatrixAffine2 scaleCopy( const Vec2<T> &v ) const { MatrixAffine2 result = *this; result.scale( v ); return result; }
180 
181  // returns an identity matrix
182  static MatrixAffine2<T> identity() { return MatrixAffine2( 1, 0, 0, 1, 0, 0 ); }
183  // returns 1 filled matrix
184  static MatrixAffine2<T> one() { return MatrixAffine2( (T)1 ); }
185  // returns 0 filled matrix
186  static MatrixAffine2<T> zero() { return MatrixAffine2( (T)0 ); }
187 
188  // creates translation matrix
189  static MatrixAffine2<T> makeTranslate( const Vec2<T> &v );
190 
191  // creates rotation matrix by \a radians
192  static MatrixAffine2<T> makeRotate( T radians );
193  // creates rotation matrix by \a radians around the point \a pt
194  static MatrixAffine2<T> makeRotate( T radians, const Vec2<T> &pt );
195 
196  // creates scale matrix
197  static MatrixAffine2<T> makeScale( T s );
198  static MatrixAffine2<T> makeScale( const Vec2<T> &v );
199 
200  static MatrixAffine2<T> makeSkewX( T radians );
201  static MatrixAffine2<T> makeSkewY( T radians );
202 
203  friend std::ostream& operator<<( std::ostream &lhs, const MatrixAffine2<T> &rhs )
204  {
205  for( int i = 0; i < 2; i++) {
206  lhs << " |";
207  for( int j = 0; j < 3; j++) {
208  lhs << std::setw( 12 ) << std::setprecision( 5 ) << rhs.m[j*2+i];
209  }
210  lhs << "|" << std::endl;
211  }
212 
213  return lhs;
214  }
215 };
216 
217 template<typename T>
219 {
220  setToIdentity();
221 }
222 
223 template<typename T>
225 {
226  for( int i = 0; i < 6; ++i )
227  m[i] = s;
228 }
229 
230 template<typename T>
232 {
233  set( dt );
234 }
235 
236 template<typename T>
237 MatrixAffine2<T>::MatrixAffine2( T d0, T d1, T d2, T d3, T d4, T d5 )
238 {
239  set( d0, d1, d2, d3, d4, d5 );
240 }
241 
242 template<typename T>
243 MatrixAffine2<T>::MatrixAffine2( const Vec2<T> &vx, const Vec2<T> &vy, const Vec2<T> &vz )
244 {
245  m00 = vx.x; m01 = vy.x; m02 = vz.x;
246  m10 = vx.y; m11 = vy.y; m12 = vz.y;
247 }
248 
249 template<typename T>
250 template<typename FromT >
252 {
253  for( int i = 0; i < 6; ++i ) {
254  m[i] = static_cast<T>( src.m[i] );
255  }
256 }
257 
258 template<typename T>
260 {
261  std::memcpy( m, src.m, MEM_LEN );
262 }
263 
264 template<typename T>
266 {
267  memcpy( m, rhs.m, MEM_LEN );
268  return *this;
269 }
270 
271 template<typename T>
273 {
274  for( int i = 0; i < 6; ++i ) {
275  m[i] = rhs;
276  }
277  return *this;
278 }
279 
280 template<typename T>
281 template<typename FromT >
283 {
284  for( int i = 0; i < 6; i++ ) {
285  m[i] = static_cast<T>(rhs.m[i]);
286  }
287  return *this;
288 }
289 
290 template<typename T>
291 bool MatrixAffine2<T>::equalCompare( const MatrixAffine2<T>& rhs, T epsilon ) const
292 {
293  for( int i = 0; i < 6; ++i ) {
294  if( math<T>::abs(m[i] - rhs.m[i]) >= epsilon )
295  return false;
296  }
297  return true;
298 }
299 
300 template<typename T>
302 {
303  MatrixAffine2<T> mat;
304 
305  mat.m[0] = m[0]*rhs.m[0] + m[2]*rhs.m[1];
306  mat.m[1] = m[1]*rhs.m[0] + m[3]*rhs.m[1];
307 
308  mat.m[2] = m[0]*rhs.m[2] + m[2]*rhs.m[3];
309  mat.m[3] = m[1]*rhs.m[2] + m[3]*rhs.m[3];
310 
311  mat.m[4] = m[0]*rhs.m[4] + m[2]*rhs.m[5] + m[4];
312  mat.m[5] = m[1]*rhs.m[4] + m[3]*rhs.m[5] + m[5];
313 
314  *this = mat;
315  return *this;
316 }
317 
318 template<typename T>
320 {
321  for( int i = 0; i < 6; ++i )
322  m[i] += rhs.m[i];
323  return *this;
324 }
325 
326 template<typename T>
328 {
329  for( int i = 0; i < 6; ++i )
330  m[i] -= rhs.m[i];
331  return *this;
332 }
333 
334 template<typename T>
336 {
337  for( int i = 0; i < 6; ++i )
338  m[i] *= s;
339  return *this;
340 }
341 
342 template<typename T>
344 {
345  T invS = 1 / s;
346  for( int i = 0; i < 6; ++i )
347  m[i] *= invS;
348  return *this;
349 }
350 
351 template<typename T>
353 {
354  for( int i = 0; i < 6; ++i )
355  m[i] += s;
356  return *this;
357 }
358 
359 template<typename T>
361 {
362  for( int i = 0; i < 6; ++i )
363  m[i] -= s;
364  return *this;
365 }
366 
367 template<typename T>
369 {
370  MatrixAffine2<T> ret;
371 
372  ret.m[0] = m[0]*rhs.m[0] + m[2]*rhs.m[1];
373  ret.m[1] = m[1]*rhs.m[0] + m[3]*rhs.m[1];
374 
375  ret.m[2] = m[0]*rhs.m[2] + m[2]*rhs.m[3];
376  ret.m[3] = m[1]*rhs.m[2] + m[3]*rhs.m[3];
377 
378  ret.m[4] = m[0]*rhs.m[4] + m[2]*rhs.m[5] + m[4];
379  ret.m[5] = m[1]*rhs.m[4] + m[3]*rhs.m[5] + m[5];
380 
381  return ret;
382 }
383 
384 template<typename T>
386 {
387  MatrixAffine2<T> ret;
388  for( int i = 0; i < 6; ++i )
389  ret.m[i] = m[i] + rhs.m[i];
390  return ret;
391 }
392 
393 template<typename T>
395 {
396  MatrixAffine2<T> ret;
397  for( int i = 0; i < 6; ++i )
398  ret.m[i] = m[i] - rhs.m[i];
399  return ret;
400 }
401 
402 template<typename T>
404 {
405  return Vec2<T>( rhs.x * m[0] + rhs.y * m[2] + m[4], rhs.x * m[1] + rhs.y * m[3] + m[5] );
406 }
407 
408 template<typename T>
409 const Vec2<T> MatrixAffine2<T>::operator*( const Vec2<T> &rhs ) const
410 {
411  return Vec2<T>( rhs.x * m[0] + rhs.y * m[2] + m[4], rhs.x * m[1] + rhs.y * m[3] + m[5] );
412 }
413 
414 template<typename T>
416 {
417  return Vec2<T>( v.x * m[0] + v.y * m[2], v.x * m[1] + v.y * m[3] );
418 }
419 
420 template<typename T>
422 {
423  MatrixAffine2<T> ret;
424  for( int i = 0; i < 6; ++i )
425  ret.m[i] = m[i]*rhs;
426  return ret;
427 }
428 
429 template<typename T>
431 {
432  MatrixAffine2<T> ret;
433  T invS = 1 / rhs;
434  for( int i = 0; i < 6; ++i )
435  ret.m[i] = m[i] * invS;
436  return ret;
437 }
438 
439 template<typename T>
441 {
442  MatrixAffine2<T> ret;
443  for( int i = 0; i < 6; ++i )
444  ret.m[i] = m[i] + rhs;
445  return ret;
446 }
447 
448 template<typename T>
450 {
451  MatrixAffine2<T> ret;
452  for( int i = 0; i < 6; ++i )
453  ret.m[i] = m[i] - rhs;
454  return ret;
455 }
456 
457 template<typename T>
458 T& MatrixAffine2<T>::at( int row, int col )
459 {
460  assert(row >= 0 && row < 2);
461  assert(col >= 0 && col < 3);
462  return m[col*2 + row];
463 }
464 
465 template<typename T>
466 const T& MatrixAffine2<T>::at( int row, int col ) const
467 {
468  assert(row >= 0 && row < 2);
469  assert(col >= 0 && col < 3);
470  return m[col*2 + row];
471 }
472 
473 template<typename T>
474 void MatrixAffine2<T>::set( const T *d )
475 {
476  m[0] = d[0]; m[3] = d[3];
477  m[1] = d[1]; m[4] = d[4];
478  m[2] = d[2]; m[5] = d[5];
479 }
480 
481 template<typename T>
482 void MatrixAffine2<T>::set( T d0, T d1, T d2, T d3, T d4, T d5 )
483 {
484  m[0] = d0; m[3] = d3;
485  m[1] = d1; m[4] = d4;
486  m[2] = d2; m[5] = d5;
487 }
488 
489 template<typename T>
491 {
492  size_t i = col*2;
493  return Vec2<T>(
494  m[i + 0],
495  m[i + 1]
496  );
497 }
498 
499 template<typename T>
500 void MatrixAffine2<T>::setColumn( int col, const Vec2<T> &v )
501 {
502  size_t i = col*2;
503  m[i + 0] = v.x;
504  m[i + 1] = v.y;
505 }
506 
507 template<typename T>
509 {
510  return Vec3<T>(
511  m[row + 0],
512  m[row + 3],
513  m[row + 6]
514  );
515 }
516 
517 template<typename T>
518 void MatrixAffine2<T>::setRow( int row, const Vec3<T> &v )
519 {
520  m[row + 0] = v.x;
521  m[row + 3] = v.y;
522  m[row + 6] = v.z;
523 }
524 
525 template<typename T>
527 {
528  *c0 = getColumn( 0 );
529  *c1 = getColumn( 1 );
530  *c2 = getColumn( 2 );
531 }
532 
533 template<typename T>
534 void MatrixAffine2<T>::setColumns( const Vec2<T> &c0, const Vec2<T> &c1, const Vec2<T> &c2 )
535 {
536  setColumn( 0, c0 );
537  setColumn( 1, c1 );
538  setColumn( 2, c2 );
539 }
540 
541 template<typename T>
543 {
544  *r0 = getRow( 0 );
545  *r1 = getRow( 1 );
546  *r2 = getRow( 2 );
547 }
548 
549 template<typename T>
550 void MatrixAffine2<T>::setRows( const Vec3<T> &r0, const Vec3<T> &r1, const Vec3<T> &r2 )
551 {
552  setRow( 0, r0 );
553  setRow( 1, r1 );
554  setRow( 2, r2 );
555 }
556 
557 template<typename T>
559 {
560  std::memset( m, 0, MEM_LEN );
561 }
562 
563 template<typename T>
565 {
566  m[0] = 1; m[2] = 0; m[4] = 0;
567  m[1] = 0; m[3] = 1; m[5] = 0;
568 }
569 
570 template<typename T>
572 {
573  return fabs( m[0] * m[3] - m[2] * m[1] ) <= (T)EPSILON;
574 }
575 
576 template<typename T>
578 {
579  MatrixAffine2<T> inv;
580 
581  inv.m[0] = m[3];
582  inv.m[1] = -m[1];
583  inv.m[2] = -m[2];
584  inv.m[3] = m[0];
585  inv.m[4] = m[2]*m[5] - m[3]*m[4];
586  inv.m[5] = m[1]*m[4] - m[0]*m[5];
587 
588  T det = m[0]*inv.m[0] + m[1]*inv.m[2];
589 
590  if( fabs( det ) > epsilon ) {
591  T invDet = 1 / det;
592  inv.m[0] *= invDet;
593  inv.m[1] *= invDet;
594  inv.m[2] *= invDet;
595  inv.m[3] *= invDet;
596  inv.m[4] *= invDet;
597  inv.m[5] *= invDet;
598  }
599 
600  return inv;
601 }
602 
603 template<typename T>
605 {
606  m[4] += m[0]*v.x + m[2]*v.y;
607  m[5] += m[1]*v.x + m[3]*v.y;
608 }
609 
610 template<typename T>
612 {
613  m[0] *= s;
614  m[1] *= s;
615 
616  m[2] *= s;
617  m[3] *= s;
618 }
619 
620 template<typename T>
622 {
623  m[0] *= s.x;
624  m[1] *= s.x;
625 
626  m[2] *= s.y;
627  m[3] *= s.y;
628 }
629 
630 template<typename T>
632 {
633  MatrixAffine2<T> ret;
634 
635  ret.m[0] = 1;
636  ret.m[1] = 0;
637 
638  ret.m[2] = 0;
639  ret.m[3] = 1;
640 
641  ret.m[4] = v.x;
642  ret.m[5] = v.y;
643 
644  return ret;
645 }
646 
647 template<typename T>
649 {
650  T sine = math<T>::sin( radians );
651  T cosine = math<T>::cos( radians );
652 
653  MatrixAffine2<T> ret;
654 
655  ret.m[0] = cosine;
656  ret.m[1] = sine;
657 
658  ret.m[2] = -sine;
659  ret.m[3] = cosine;
660 
661  ret.m[4] = 0;
662  ret.m[5] = 0;
663 
664  return ret;
665 }
666 
667 template<typename T>
669 {
670  T sine = math<T>::sin( radians );
671  T cosine = math<T>::cos( radians );
672 
673  MatrixAffine2<T> ret;
674 
675  ret.m[0] = cosine;
676  ret.m[1] = sine;
677 
678  ret.m[2] = -sine;
679  ret.m[3] = cosine;
680 
681  ret.m[4] = pt.x - cosine * pt.x + sine * pt.y;
682  ret.m[5] = pt.y - sine * pt.x - cosine * pt.y;
683 
684  return ret;
685 }
686 
687 template<typename T>
689 {
690  MatrixAffine2<T> ret;
691 
692  ret.m[0] = s;
693  ret.m[1] = 0;
694 
695  ret.m[2] = 0;
696  ret.m[3] = s;
697 
698  ret.m[4] = 0;
699  ret.m[5] = 0;
700 
701  return ret;
702 }
703 
704 template<typename T>
706 {
707  MatrixAffine2<T> ret;
708 
709  ret.m[0] = s.x;
710  ret.m[1] = 0;
711 
712  ret.m[2] = 0;
713  ret.m[3] = s.y;
714 
715  ret.m[4] = 0;
716  ret.m[5] = 0;
717 
718  return ret;
719 }
720 
721 template<typename T>
723 {
724  MatrixAffine2<T> ret;
725 
726  ret.m[0] = 1;
727  ret.m[1] = 0;
728 
729  ret.m[2] = math<T>::tan( radians );
730  ret.m[3] = 1;
731 
732  ret.m[4] = 0;
733  ret.m[5] = 0;
734 
735  return ret;
736 }
737 
738 template<typename T>
740 {
741  MatrixAffine2<T> ret;
742 
743  ret.m[0] = 1;
744  ret.m[1] = math<T>::tan( radians );
745 
746  ret.m[2] = 0;
747  ret.m[3] = 1;
748 
749  ret.m[4] = 0;
750  ret.m[5] = 0;
751 
752  return ret;
753 }
754 
755 
757 // Typedefs
760 
761 } // namespace cinder
const MatrixAffine2< T > operator*(const MatrixAffine2< T > &rhs) const
Definition: MatrixAffine2.h:368
Definition: CinderMath.h:40
void translate(const Vec2< T > &v)
concatenate translation by v (conceptually, translate is before 'this')
Definition: MatrixAffine2.h:604
static MatrixAffine2< T > makeScale(T s)
Definition: MatrixAffine2.h:688
static T cos(T x)
Definition: CinderMath.h:46
MatrixAffine2< T > & operator=(const MatrixAffine2< T > &rhs)
Definition: MatrixAffine2.h:265
static MatrixAffine2< T > makeRotate(T radians)
Definition: MatrixAffine2.h:648
void invert(T epsilon=EPSILON)
Returns a copy of the matrix inverted. epsilon specifies the tolerance for testing for singularity...
Definition: MatrixAffine2.h:154
void setColumn(int col, const Vec2< T > &v)
Definition: MatrixAffine2.h:500
MatrixAffine2< T > & operator+=(const MatrixAffine2< T > &rhs)
Definition: MatrixAffine2.h:319
MatrixAffine2 translateCopy(const Vec2< T > &v) const
Returns a copy of the matrix translated by v.
Definition: MatrixAffine2.h:161
static T sin(T x)
Definition: CinderMath.h:47
#define EPSILON
Definition: CinderMath.h:125
Vec2< T > getColumn(int col) const
Definition: MatrixAffine2.h:490
T m11
Definition: MatrixAffine2.h:67
MatrixAffine2< T > & operator/=(T s)
Definition: MatrixAffine2.h:343
T z
Definition: Vector.h:321
bool equalCompare(const MatrixAffine2< T > &rhs, T epsilon) const
Definition: MatrixAffine2.h:291
T m00
Definition: MatrixAffine2.h:66
GLuint src
Definition: GLee.h:10873
MatrixAffine2 rotateCopy(T radians, const Vec2< T > &pt) const
Returns a copy of the matrix rotate by radians around the point pt.
Definition: MatrixAffine2.h:170
T x
Definition: Vector.h:321
bool operator==(const MatrixAffine2< T > &rhs) const
Definition: MatrixAffine2.h:93
T x
Definition: Vector.h:71
void setColumns(const Vec2< T > &c0, const Vec2< T > &c1, const Vec2< T > &c2)
Definition: MatrixAffine2.h:534
T y
Definition: Vector.h:321
MatrixAffine2 scaleCopy(T s) const
Returns a copy of the matrix scaled by s.
Definition: MatrixAffine2.h:177
T mcols[3][2]
Definition: MatrixAffine2.h:71
T value_type
Definition: MatrixAffine2.h:42
Definition: Vector.h:68
GLenum GLenum GLvoid * row
Definition: GLee.h:1089
void getColumns(Vec2< T > *c0, Vec2< T > *c1, Vec2< T > *c2) const
Definition: MatrixAffine2.h:526
void setRow(int row, const Vec3< T > &v)
Definition: MatrixAffine2.h:518
static MatrixAffine2< T > makeTranslate(const Vec2< T > &v)
Definition: MatrixAffine2.h:631
MatrixAffine2< T > & operator-=(const MatrixAffine2< T > &rhs)
Definition: MatrixAffine2.h:327
MatrixAffine2< T > invertCopy(T epsilon=EPSILON) const
Returns a copy of the matrix inverted. epsilon specifies the tolerance for testing for singularity...
Definition: MatrixAffine2.h:577
Definition: Vector.h:65
Vec2< T > transformPoint(const Vec2< T > &rhs) const
post-multiplies column vector [rhs.x rhs.y 1]
Definition: MatrixAffine2.h:403
T & at(int row, int col)
Definition: MatrixAffine2.h:458
bool isSingular() const
Returns whether the matrix is singular (and consequently not invertible) or not.
Definition: MatrixAffine2.h:571
T m02
Definition: MatrixAffine2.h:68
const MatrixAffine2< T > operator-(const MatrixAffine2< T > &rhs) const
Definition: MatrixAffine2.h:394
MatrixAffine2 scaleCopy(const Vec2< T > &v) const
Returns a copy of the matrix scaled by v.
Definition: MatrixAffine2.h:179
bool operator!=(const MatrixAffine2< T > &rhs) const
Definition: MatrixAffine2.h:94
void setToIdentity()
Sets the matrix to the identity matrix.
Definition: MatrixAffine2.h:564
T TYPE
Definition: MatrixAffine2.h:41
MatrixAffine2()
Definition: MatrixAffine2.h:218
const GLdouble * v
Definition: GLee.h:1384
void setRows(const Vec3< T > &r0, const Vec3< T > &r1, const Vec3< T > &r2)
Definition: MatrixAffine2.h:550
static T tan(T x)
Definition: CinderMath.h:48
T y
Definition: Vector.h:71
T & operator[](int idx)
Definition: MatrixAffine2.h:125
void scale(T s)
concatenate scale (conceptually, scale is before 'this')
Definition: MatrixAffine2.h:611
MatrixAffine2 rotateCopy(T radians) const
Returns a copy of the matrix rotate by radians.
Definition: MatrixAffine2.h:168
void rotate(T radians)
concatenate rotation by radians (conceptually, rotate is before 'this')
Definition: MatrixAffine2.h:164
Represents a two dimensional affine transformation.
Definition: MatrixAffine2.h:38
T m12
Definition: MatrixAffine2.h:68
void setToNull()
Sets the matrix to all zeros.
Definition: MatrixAffine2.h:558
static MatrixAffine2< T > zero()
Definition: MatrixAffine2.h:186
const MatrixAffine2< T > operator/(T rhs) const
Definition: MatrixAffine2.h:430
T m10
Definition: MatrixAffine2.h:66
MatrixAffine2< T > & operator*=(const MatrixAffine2< T > &rhs)
Definition: MatrixAffine2.h:301
static MatrixAffine2< T > one()
Definition: MatrixAffine2.h:184
T m[6]
Definition: MatrixAffine2.h:61
MatrixAffine2< double > MatrixAffine2d
Definition: MatrixAffine2.h:759
static const size_t MEM_LEN
Definition: MatrixAffine2.h:44
void rotate(T radians, const Vec2< T > &pt)
concatenate rotation by radians around the point pt (conceptually, rotate is before 'this') ...
Definition: MatrixAffine2.h:166
static MatrixAffine2< T > identity()
Definition: MatrixAffine2.h:182
static MatrixAffine2< T > makeSkewX(T radians)
Definition: MatrixAffine2.h:722
const GLfloat * m
Definition: GLee.h:13493
static MatrixAffine2< T > makeSkewY(T radians)
Definition: MatrixAffine2.h:739
Vec3< T > getRow(int row) const
Definition: MatrixAffine2.h:508
T m01
Definition: MatrixAffine2.h:67
MatrixAffine2< float > MatrixAffine2f
Definition: MatrixAffine2.h:758
GLdouble s
Definition: GLee.h:1378
Vec2< T > transformVec(const Vec2< T > &v) const
post-multiplies column vector [rhs.x rhs.y 0]
Definition: MatrixAffine2.h:415
const MatrixAffine2< T > operator+(const MatrixAffine2< T > &rhs) const
Definition: MatrixAffine2.h:385
const T & operator[](int idx) const
Definition: MatrixAffine2.h:126
void set(const T *dt)
Definition: MatrixAffine2.h:474
void getRows(Vec3< T > *r0, Vec3< T > *r1, Vec3< T > *r2) const
Definition: MatrixAffine2.h:542