HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_Matrix2.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  */
7 
8 #pragma once
9 
10 #ifndef __UT_Matrix2_h__
11 #define __UT_Matrix2_h__
12 
13 #include "UT_API.h"
14 #include "UT_Assert.h"
15 #include "UT_FixedVector.h"
16 #include "UT_VectorTypes.h"
17 
18 #include <SYS/SYS_Types.h>
19 #include <SYS/SYS_Math.h>
20 #include <SYS/SYS_StaticAssert.h>
21 #include <iosfwd>
22 
23 class UT_IStream;
24 class UT_JSONWriter;
25 class UT_JSONValue;
26 class UT_JSONParser;
27 
28 // Free floating operators that return a UT_Matrix2T<T> object.
29 template <typename T> UT_API
31 template <typename T, typename S> UT_API
33 template <typename T, typename S> UT_API
35 template <typename T> UT_API
37 template <typename T> UT_API
39 
40 template <typename T> UT_API
42 template <typename T, typename S> UT_API
44 template <typename T, typename S> UT_API
46 template <typename T> UT_API
48 template <typename T> UT_API
50 
51 template <typename T> UT_API
53 template <typename T,typename S> UT_API
55 template <typename T,typename S> UT_API
57 
58 template <typename T> UT_API
60 template <typename T> UT_API
62 
63 template <typename T>
64 inline UT_Matrix2T<T> SYSmin (const UT_Matrix2T<T> &v1, const UT_Matrix2T<T> &v2);
65 template <typename T>
66 inline UT_Matrix2T<T> SYSmax (const UT_Matrix2T<T> &v1, const UT_Matrix2T<T> &v2);
67 template <typename T,typename S>
68 inline UT_Matrix2T<T> SYSlerp(const UT_Matrix2T<T> &v1, const UT_Matrix2T<T> &v2, S t);
69 template <typename T,typename S>
70 inline UT_Matrix2T<T> SYSbilerp(const UT_Matrix2T<T> &u0v0, const UT_Matrix2T<T> &u1v0,
71  const UT_Matrix2T<T> &u0v1, const UT_Matrix2T<T> &u1v1,
72  S u, S v)
73 { return SYSlerp(SYSlerp(u0v0, u0v1, v), SYSlerp(u1v0, u1v1, v), u); }
74 
75 /// This class implements a 2x2 matrix in row-major order.
76 ///
77 /// Most of Houdini operates with row vectors that are left-multiplied with
78 /// matrices. e.g., z = v * M
79 template <typename T>
81 {
82 public:
83 
84  typedef T value_type;
85  static const int tuple_size = 4;
86 
87  /// Construct uninitialized matrix.
88  SYS_FORCE_INLINE UT_Matrix2T() = default;
89 
90  /// Default copy constructor
91  constexpr UT_Matrix2T(const UT_Matrix2T &) = default;
92 
93  /// Default move constructor
94  constexpr UT_Matrix2T(UT_Matrix2T &&) = default;
95 
96  /// Construct identity matrix, multipled by scalar.
97  explicit constexpr UT_Matrix2T(T val) noexcept
98  : matx{{val,T(0)},{T(0),val}}
99  {
100  SYS_STATIC_ASSERT(sizeof(UT_Matrix2T<T>) == tuple_size * sizeof(T));
101  }
102  /// Construct a deep copy of the input row-major data.
103  /// @{
104  explicit constexpr UT_Matrix2T(const fpreal32 m[2][2]) noexcept
105  : matx{{T(m[0][0]),T(m[0][1])},{T(m[1][0]),T(m[1][1])}}
106  {}
107  explicit constexpr UT_Matrix2T(const fpreal64 m[2][2]) noexcept
108  : matx{{T(m[0][0]),T(m[0][1])},{T(m[1][0]),T(m[1][1])}}
109  {}
110  /// @}
111 
112  /// Arbitrary UT_FixedVector of the same size
113  template <typename S>
115  : matx{{T(v[0]),T(v[1])},{T(v[2]),T(v[3])}}
116  {}
117 
118  /// This constructor is for convenience.
119  constexpr UT_Matrix2T(T val00, T val01, T val10, T val11) noexcept
120  : matx{{val00,val01},{val10,val11}}
121  {}
122 
123  /// Base type conversion constructor
124  template <typename S>
125  UT_Matrix2T(const UT_Matrix2T<S> &m) noexcept
126  : matx{{T(m(0,0)),T(m(0,1))},{T(m(1,0)),T(m(1,1))}}
127  {}
128 
129  /// Conversion to a 2x2 from a 3x3 matrix by ignoring the
130  /// last row and last column.
131  template <typename S>
132  explicit UT_Matrix2T(const UT_Matrix3T<S> &m) noexcept
133  : matx{{T(m(0,0)),T(m(0,1))},{T(m(1,0)),T(m(1,1))}}
134  {}
135 
136  /// Default copy assignment operator
137  UT_Matrix2T<T> &operator=(const UT_Matrix2T<T> &m) = default;
138 
139  /// Default move assignment operator
140  UT_Matrix2T<T> &operator=(UT_Matrix2T<T> &&m) = default;
141 
142  /// Conversion operator that returns a 2x2 from a 3x3 matrix by ignoring the
143  /// last row and last column.
144  template <typename S>
145  UT_Matrix2T<T> &operator=(const UT_Matrix3T<S> &m);
146 
148  {
149  return UT_Matrix2T<T>(
150  -matx[0][0], -matx[0][1],
151  -matx[1][0], -matx[1][1]);
152  }
153 
155  {
156  matx[0][0]+=m.matx[0][0]; matx[0][1]+=m.matx[0][1];
157  matx[1][0]+=m.matx[1][0]; matx[1][1]+=m.matx[1][1];
158  return *this;
159  }
161  {
162  matx[0][0]-=m.matx[0][0]; matx[0][1]-=m.matx[0][1];
163  matx[1][0]-=m.matx[1][0]; matx[1][1]-=m.matx[1][1];
164  return *this;
165  }
167 
168  constexpr bool operator==(const UT_Matrix2T<T> &m) const noexcept
169  {
170  return (&m == this) || (
171  matx[0][0]==m(0,0) && matx[0][1]==m(0,1) &&
172  matx[1][0]==m(1,0) && matx[1][1]==m(1,1) );
173  }
174  constexpr bool operator!=(const UT_Matrix2T<T> &m) const noexcept
175  {
176  return !(*this == m);
177  }
178 
180  {
181  matx[0][0] = val; matx[0][1] = 0;
182  matx[1][0] = 0; matx[1][1] = val;
183  return *this;
184  }
186  {
187  matx[0][0]+=scalar; matx[0][1]+=scalar;
188  matx[1][0]+=scalar; matx[1][1]+=scalar;
189  return *this;
190  }
192  {
193  return operator+=(-scalar);
194  }
196  {
197  matx[0][0]*=scalar; matx[0][1]*=scalar;
198  matx[1][0]*=scalar; matx[1][1]*=scalar;
199  return *this;
200  }
202  {
203  return operator*=( 1.0f/scalar );
204  }
205 
206  // Vector2 operators:
207  template <typename S>
208  inline
209  UT_Matrix2T<T> &operator=(const UT_Vector2T<S> &vec);
210  template <typename S>
211  inline
212  UT_Matrix2T<T> &operator+=(const UT_Vector2T<S> &vec);
213  template <typename S>
214  inline
215  UT_Matrix2T<T> &operator-=(const UT_Vector2T<S> &vec);
216 
217  constexpr T determinant() const noexcept
218  {
219  return matx[0][0]*matx[1][1] - matx[0][1]*matx[1][0];
220  }
221  constexpr T trace() const noexcept
222  { return matx[0][0] + matx[1][1]; }
223 
224  /// Returns eigenvalues of this matrix
225  template <typename S>
226  int eigenvalues(UT_Vector2T<S> &r, UT_Vector2T<S> &i) const;
227 
228  /// Invert this matrix and return 0 if OK, 1 if singular.
229  int invert()
230  {
231  // NOTE: The other invert function should work on *this,
232  // since it does all reading before all writing.
233  return invert(*this);
234  }
235 
236  /// Invert the matrix and return 0 if OK, 1 if singular.
237  /// Puts the inverted matrix in m, and leaves this matrix unchanged.
238  int invert(UT_Matrix2T<T> &m) const
239  {
240  // Effectively rescale the matrix for the determinant check,
241  // because if the whole matrix is close to zero, having a
242  // small determinant may be fine.
243  T scale2 = SYSmax(matx[0][0]*matx[0][0],
244  matx[0][1]*matx[0][1],
245  matx[1][0]*matx[1][0],
246  matx[1][1]*matx[1][1]);
247  T det = determinant();
248  if (!SYSequalZero(det, tolerance()*scale2))
249  {
250  // Finish all reading before writing to m,
251  // so that invert() can call invert(*this)
252  m = UT_Matrix2T<T>( matx[1][1],-matx[0][1],
253  -matx[1][0], matx[0][0]);
254  m *= (1.0f/det);
255 
256  return 0;
257  }
258  return 1;
259  }
260 
261  /// Returns the tolerance of our class.
262  T tolerance() const;
263 
264  // Solve a 2x2 system of equations Ax=b, where A is this matrix, b is
265  // given and x is unknown. The method returns 0 if the determinant is not
266  // 0, and 1 otherwise.
267  template <typename S>
268  int solve(const UT_Vector2T<S> &b, UT_Vector2T<S> &x) const
269  {
270  // Effectively rescale the matrix for the determinant check,
271  // because if the whole matrix is close to zero, having a
272  // small determinant may be fine.
273  T scale2 = SYSmax(matx[0][0]*matx[0][0],
274  matx[0][1]*matx[0][1],
275  matx[1][0]*matx[1][0],
276  matx[1][1]*matx[1][1]);
277  T det = determinant();
278  if (!SYSequalZero(det, tolerance()*scale2))
279  {
280  T recipdet = 1.0f/det;
281  x = UT_Vector2T<S>(
282  recipdet * (matx[1][1]*b.x() - matx[0][1]*b.y()),
283  recipdet * (matx[0][0]*b.y() - matx[1][0]*b.x()));
284  return 0;
285  }
286  return 1;
287  }
288 
289  // Transpose this matrix or return its transpose.
290  void transpose(void)
291  {
292  T tmp;
293  tmp=matx[0][1]; matx[0][1]=matx[1][0]; matx[1][0]=tmp;
294  }
295  UT_Matrix2T<T> transpose(void) const;
296 
297  // check for equality within a tolerance level
298  bool isEqual( const UT_Matrix2T<T> &m,
299  T tolerance=T(SYS_FTOLERANCE) ) const
300  {
301  return (&m == this) || (
302  SYSisEqual( matx[0][0], m.matx[0][0], tolerance ) &&
303  SYSisEqual( matx[0][1], m.matx[0][1], tolerance ) &&
304 
305  SYSisEqual( matx[1][0], m.matx[1][0], tolerance ) &&
306  SYSisEqual( matx[1][1], m.matx[1][1], tolerance ) );
307  }
308 
309  // Matrix += b * v1 * v2T
310  template <typename S>
312  const UT_Vector2T<S> &v1, const UT_Vector2T<S> &v2)
313  {
314  T bv1;
315  bv1 = b * v1.x();
316  matx[0][0]+=bv1*v2.x();
317  matx[0][1]+=bv1*v2.y();
318  bv1 = b * v1.y();
319  matx[1][0]+=bv1*v2.x();
320  matx[1][1]+=bv1*v2.y();
321  }
322 
323  /// Set the matrix to identity
324  void identity()
325  {
326  matx[0][0]=(T)1;matx[0][1]=(T)0;
327  matx[1][0]=(T)0;matx[1][1]=(T)1;
328  }
329  /// Set the matrix to zero
330  void zero() { *this = 0; }
331 
332  bool isIdentity() const
333  {
334  // NB: DO NOT USE TOLERANCES
335  return(
336  matx[0][0]==1.0f && matx[0][1]==0.0f &&
337  matx[1][0]==0.0f && matx[1][1]==1.0f);
338  }
339  bool isZero() const
340  {
341  // NB: DO NOT USE TOLERANCES
342  return (
343  matx[0][0]==0.0f && matx[0][1]==0.0f &&
344  matx[1][0]==0.0f && matx[1][1]==0.0f);
345  }
346 
347  /// Create a rotation matrix for the given angle in radians
348  static UT_Matrix2T<T> rotationMat(T theta);
349 
350  /// Rotate by theta radians
351  void rotate(T theta)
352  { (*this) *= rotationMat(theta); }
353 
354  /// Multiply this matrix by a scale matrix with diagonal (sx, sy):
355  /// @{
356  void scale(T sx, T sy)
357  {
358  matx[0][0] *= sx; matx[0][1] *= sy;
359  matx[1][0] *= sx; matx[1][1] *= sy;
360  }
361  inline void scale(const UT_Vector2T<T> &s)
362  { scale(s(0), s(1)); }
363  /// @}
364 
365  /// Initialize this matrix to zero.
366  void initialize()
367  {
368  matx[0][0]=matx[0][1]= (T)0;
369  matx[1][0]=matx[1][1]= (T)0;
370  }
371 
372  /// Return a matrix entry. No bounds checking on subscripts.
373  // @{
374  SYS_FORCE_INLINE T &operator()(unsigned row, unsigned col) noexcept
375  {
376  UT_ASSERT_P(row < 2 && col < 2);
377  return matx[row][col];
378  }
379  SYS_FORCE_INLINE T operator()(unsigned row, unsigned col) const noexcept
380  {
381  UT_ASSERT_P(row < 2 && col < 2);
382  return matx[row][col];
383  }
384  // @}
385 
386  /// Return the raw matrix data.
387  // @{
388  const T *data(void) const { return myFloats; }
389  T *data(void) { return myFloats; }
390  // @}
391 
392  /// Compute a hash
393  unsigned hash() const { return SYSvector_hash(data(), tuple_size); }
394 
395  /// Return a matrix row. No bounds checking on subscript.
396  // @{
397  T *operator()(unsigned row)
398  {
399  UT_ASSERT_P(row < 2);
400  return matx[row];
401  }
402  const T *operator()(unsigned row) const
403  {
404  UT_ASSERT_P(row < 2);
405  return matx[row];
406  }
407  inline
408  const UT_Vector2T<T> &operator[](unsigned row) const;
409  inline
410  UT_Vector2T<T> &operator[](unsigned row);
411  // @}
412 
413  /// Euclidean or Frobenius norm of a matrix.
414  /// Does sqrt(sum(a_ij ^2))
416  { return SYSsqrt(getEuclideanNorm2()); }
417  /// Euclidean norm squared.
418  T getEuclideanNorm2() const;
419 
420  // I/O methods. Return 0 if read/write successful, -1 if unsuccessful.
421  int save(std::ostream &os, int binary) const;
422  bool load(UT_IStream &is);
423 
424  void outAsciiNoName(std::ostream &os) const;
425 
426  /// @{
427  /// Methods to serialize to a JSON stream. The matrix is stored as an
428  /// array of 4 reals.
429  bool save(UT_JSONWriter &w) const;
430  bool save(UT_JSONValue &v) const;
431  bool load(UT_JSONParser &p);
432  /// @}
433 
434  // I/O friends:
435  friend std::ostream &operator<<(std::ostream &os, const UT_Matrix2T<T> &v)
436  {
437  // v.className(os);
438  v.outAsciiNoName(os);
439  return os;
440  }
441 
442  /// Returns the vector size
443  static int entries() { return tuple_size; }
444 
445 private:
446  void writeClassName(std::ostream &os) const;
447  static const char *className();
448 
449  union {
450  T matx[2][2];
451  T myFloats[tuple_size];
452  };
453 };
454 
455 #include "UT_Vector2.h"
456 
457 template <>
458 inline
460 {
461  return 1e-5f;
462 }
463 
464 template <>
465 inline
467 {
468  return 1e-11;
469 }
470 
471 // Special instantiations to handle the fact that we have UT_Vector2T<int64>::getBary()
472 template <>
473 inline
475 {
476  return 0;
477 }
478 
479 template <>
480 inline
482 {
483  return 0;
484 }
485 
486 template <typename T>
487 template <typename S>
488 inline
490 {
491  matx[0][0] = matx[0][1] = vec.x();
492  matx[1][0] = matx[1][1] = vec.y();
493  return *this;
494 }
495 
496 template <typename T>
497 template <typename S>
498 inline
500 {
501  matx[0][0]+=vec.x(); matx[0][1]+=vec.x();
502  matx[1][0]+=vec.y(); matx[1][1]+=vec.y();
503  return *this;
504 }
505 
506 template <typename T>
507 template <typename S>
508 inline
510 {
511  matx[0][0]-=vec.x(); matx[0][1]-=vec.x();
512  matx[1][0]-=vec.y(); matx[1][1]-=vec.y();
513  return *this;
514 }
515 
516 template <typename T>
517 inline
519 {
520  UT_ASSERT_P(row < 2);
521  return *(const UT_Vector2T<T>*)(matx[row]);
522 }
523 
524 template <typename T>
525 inline
527 {
528  UT_ASSERT_P(row < 2);
529  return *(UT_Vector2T<T>*)(matx[row]);
530 }
531 
532 
533 // Free floating functions:
534 template <typename T, typename S>
535 inline
537 {
538  return mat+vec;
539 }
540 
541 template <typename T>
542 inline
544 {
545  return m1+sc;
546 }
547 
548 template <typename T>
549 inline
551 {
552  return m1+(-sc);
553 }
554 
555 template <typename T,typename S>
556 inline
558 {
559  return m1*sc;
560 }
561 
562 template <typename T>
563 inline
565 {
566  return m1 * (1.0f/scalar);
567 }
568 
569 template <typename T>
570 inline
572 {
573  return UT_Matrix2T<T>(
574  SYSmin(v1(0,0), v2(0,0)),
575  SYSmin(v1(0,1), v2(0,1)),
576  SYSmin(v1(1,0), v2(1,0)),
577  SYSmin(v1(1,1), v2(1,1))
578  );
579 }
580 
581 template <typename T>
582 inline
584 {
585  return UT_Matrix2T<T>(
586  SYSmax(v1(0,0), v2(0,0)),
587  SYSmax(v1(0,1), v2(0,1)),
588  SYSmax(v1(1,0), v2(1,0)),
589  SYSmax(v1(1,1), v2(1,1))
590  );
591 }
592 
593 template <typename T,typename S>
594 inline
596 {
597  return UT_Matrix2T<T>(
598  SYSlerp(v1(0,0), v2(0,0), t),
599  SYSlerp(v1(0,1), v2(0,1), t),
600  SYSlerp(v1(1,0), v2(1,0), t),
601  SYSlerp(v1(1,1), v2(1,1), t)
602  );
603 }
604 
605 template<typename T>
607 {
609  typedef T DataType;
610  static const exint TupleSize = 4;
611  static const bool isVectorType = true;
612 };
613 
614 // Overload for custom formatting of UT_Matrix2T<T> with UTformat.
615 template<typename T>
616 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Matrix2T<T> &v);
617 
618 #endif
void identity()
Set the matrix to identity.
Definition: UT_Matrix2.h:324
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Returns M, where for .
Definition: Mat3.h:615
void rotate(T theta)
Rotate by theta radians.
Definition: UT_Matrix2.h:351
#define SYS_STATIC_ASSERT(expr)
void initialize()
Initialize this matrix to zero.
Definition: UT_Matrix2.h:366
constexpr UT_Matrix2T(const fpreal32 m[2][2]) noexcept
Definition: UT_Matrix2.h:104
constexpr T determinant() const noexcept
Definition: UT_Matrix2.h:217
T tolerance() const
Returns the tolerance of our class.
const T * operator()(unsigned row) const
Return a matrix row. No bounds checking on subscript.
Definition: UT_Matrix2.h:402
constexpr bool operator!=(const UT_Matrix2T< T > &m) const noexcept
Definition: UT_Matrix2.h:174
int solve(const UT_Vector2T< S > &b, UT_Vector2T< S > &x) const
Definition: UT_Matrix2.h:268
GLboolean invert
Definition: glcorearb.h:548
SYS_FORCE_INLINE T & operator()(unsigned row, unsigned col) noexcept
Return a matrix entry. No bounds checking on subscripts.
Definition: UT_Matrix2.h:374
const GLdouble * v
Definition: glcorearb.h:836
Mat3< typename promote< T0, T1 >::type > operator+(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Returns M, where for .
Definition: Mat3.h:631
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
UT_API size_t format(char *buffer, size_t buffer_size, const UT_Matrix2T< T > &v)
SYS_FORCE_INLINE T operator()(unsigned row, unsigned col) const noexcept
Return a matrix entry. No bounds checking on subscripts.
Definition: UT_Matrix2.h:379
T & x(void)
Definition: UT_Vector2.h:284
UT_Matrix2T< T > & operator=(T val)
Definition: UT_Matrix2.h:179
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:72
#define UT_API
Definition: UT_API.h:12
UT_Matrix2T< T > SYSbilerp(const UT_Matrix2T< T > &u0v0, const UT_Matrix2T< T > &u1v0, const UT_Matrix2T< T > &u0v1, const UT_Matrix2T< T > &u1v1, S u, S v)
Definition: UT_Matrix2.h:70
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
static const exint TupleSize
UT_Matrix2T< T > & operator/=(T scalar)
Definition: UT_Matrix2.h:201
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
UT_Matrix2T< T > SYSlerp(const UT_Matrix2T< T > &v1, const UT_Matrix2T< T > &v2, S t)
Definition: UT_Matrix2.h:595
void scale(T sx, T sy)
Definition: UT_Matrix2.h:356
2D Vector class.
Definition: UT_Vector2.h:137
const T * data(void) const
Return the raw matrix data.
Definition: UT_Matrix2.h:388
static int entries()
Returns the vector size.
Definition: UT_Matrix2.h:443
void scale(const UT_Vector2T< T > &s)
Definition: UT_Matrix2.h:361
GLuint buffer
Definition: glcorearb.h:659
png_uint_32 i
Definition: png.h:2877
unsigned hash() const
Compute a hash.
Definition: UT_Matrix2.h:393
constexpr UT_Matrix2T(T val) noexcept
Construct identity matrix, multipled by scalar.
Definition: UT_Matrix2.h:97
void transpose(void)
Definition: UT_Matrix2.h:290
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:101
T * operator()(unsigned row)
Return a matrix row. No bounds checking on subscript.
Definition: UT_Matrix2.h:397
GLsizei GLboolean transpose
Definition: glcorearb.h:831
long long int64
Definition: SYS_Types.h:106
GA_API const UT_StringHolder scale
GLfloat f
Definition: glcorearb.h:1925
T getEuclideanNorm() const
Definition: UT_Matrix2.h:415
Mat3< typename promote< T0, T1 >::type > operator-(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Returns M, where for .
Definition: Mat3.h:641
int64 exint
Definition: SYS_Types.h:115
double fpreal64
Definition: SYS_Types.h:191
static const bool isVectorType
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
T matx[2][2]
Definition: UT_Matrix2.h:450
bool isZero() const
Definition: UT_Matrix2.h:339
UT_Matrix2T< T > & operator=(UT_Matrix2T< T > &&m)=default
Default move assignment operator.
GLboolean * data
Definition: glcorearb.h:130
png_bytepp row
Definition: png.h:1836
UT_Matrix2T< T > & operator+=(const UT_Matrix2T< T > &m)
Definition: UT_Matrix2.h:154
int int32
Definition: SYS_Types.h:34
const Vec2< S > & operator*=(Vec2< S > &v, const Matrix33< T > &m)
Definition: ImathMatrix.h:3330
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
int invert(UT_Matrix2T< T > &m) const
Definition: UT_Matrix2.h:238
bool isIdentity() const
Definition: UT_Matrix2.h:332
class UT_API UT_Matrix2T
UT_Matrix2T< T > & operator-=(const UT_Matrix2T< T > &m)
Definition: UT_Matrix2.h:160
const UT_Vector2T< T > & operator[](unsigned row) const
Return a matrix row. No bounds checking on subscript.
Definition: UT_Matrix2.h:518
void zero()
Set the matrix to zero.
Definition: UT_Matrix2.h:330
UT_API UT_Matrix2T< T > operator/(const UT_Matrix2T< T > &mat, T sc)
Definition: UT_Matrix2.h:564
UT_Matrix2T< T > operator-() const
Definition: UT_Matrix2.h:147
png_infop png_bytep png_size_t buffer_size
Definition: png.h:2124
GLint GLenum GLint x
Definition: glcorearb.h:408
GLfloat GLfloat v1
Definition: glcorearb.h:816
GLuint GLfloat * val
Definition: glcorearb.h:1607
void outerproductUpdate(T b, const UT_Vector2T< S > &v1, const UT_Vector2T< S > &v2)
Definition: UT_Matrix2.h:311
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:75
T * data(void)
Return the raw matrix data.
Definition: UT_Matrix2.h:389
bool isEqual(const UT_Matrix2T< T > &m, T tolerance=T(SYS_FTOLERANCE)) const
Definition: UT_Matrix2.h:298
UT_Matrix2T< T > SYSmin(const UT_Matrix2T< T > &v1, const UT_Matrix2T< T > &v2)
Definition: UT_Matrix2.h:571
#define SYS_FTOLERANCE
Definition: SYS_Types.h:202
T & y(void)
Definition: UT_Vector2.h:286
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
UT_Matrix2T< T > & operator-=(T scalar)
Definition: UT_Matrix2.h:191
int invert()
Invert this matrix and return 0 if OK, 1 if singular.
Definition: UT_Matrix2.h:229
GLboolean r
Definition: glcorearb.h:1221
#define const
Definition: zconf.h:214
UT_Matrix2T< T > & operator+=(T scalar)
Definition: UT_Matrix2.h:185
UT_Matrix2T< T > & operator*=(T scalar)
Definition: UT_Matrix2.h:195
UT_Matrix2T< T > SYSmax(const UT_Matrix2T< T > &v1, const UT_Matrix2T< T > &v2)
Definition: UT_Matrix2.h:583
constexpr bool operator==(const UT_Matrix2T< T > &m) const noexcept
Definition: UT_Matrix2.h:168
constexpr T trace() const noexcept
Definition: UT_Matrix2.h:221
float fpreal32
Definition: SYS_Types.h:190
UT_FixedVector< T, 4 > FixedVectorType
Definition: UT_Matrix2.h:608