HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_SymMatrix4.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 #ifndef __UT_SymMatrix4_h__
9 #define __UT_SymMatrix4_h__
10 
11 #include "UT_API.h"
12 #include <stdlib.h>
13 #include <iosfwd>
14 
15 #include "UT_VectorTypes.h"
16 
17 /// Symmetric 4x4 Matrices
18 template <typename T>
20 {
21 public:
22  /// Construct uninitialized matrix.
24  {
25  }
26 
27  // Default copy constructor is fine.
28  //UT_SymMatrix4(const UT_SymMatrix4T<T> &m);
29 
30  // Default assignment operator is fine.
31  //UT_SymMatrix4 &operator=(const UT_SymMatrix4T<T> &m);
32 
33  void zero()
34  {
35  q00 = 0; q01 = 0; q02 = 0;
36  q03 = 0; q11 = 0; q12 = 0;
37  q13 = 0; q22 = 0; q23 = 0;
38  q33 = 0;
39  }
40 
42  {
43  q00 += m.q00; q01 += m.q01; q02 += m.q02;
44  q03 += m.q03; q11 += m.q11; q12 += m.q12;
45  q13 += m.q13; q22 += m.q22; q23 += m.q23;
46  q33 += m.q33;
47  return *this;
48  }
49 
51  {
52  q00 *= scale; q01 *= scale; q02 *= scale;
53  q03 *= scale; q11 *= scale; q12 *= scale;
54  q13 *= scale; q22 *= scale; q23 *= scale;
55  q33 *= scale;
56  return *this;
57  }
58 
60  {
61  q00 += scale; q11 += scale;
62  q22 += scale; q33 += scale;
63  }
64 
66  {
67  q00 += c; q01 += c; q02 += c;
68  q03 += c; q11 += c; q12 += c;
69  q13 += c; q22 += c; q23 += c;
70  q33 += c;
71  return *this;
72  }
73 
74 
76  {
77  return SYSsqrt(getEuclideanNorm2());
78  }
80  {
81  return q00*q00 + 2*q01*q01 + 2*q02*q02 + 2*q03*q03
82  + q11*q11 + 2*q12*q12 + 2*q13*q13
83  + q22*q22 + 2*q23*q23
84  + q33*q33;
85  }
86 
87  void transpose() {}
88 
89  // Sets the matrix to v * vT
90  void outerproduct(const UT_Vector4 &v);
91  void outerproduct(fpreal64 a, fpreal64 b, fpreal64 c,
92  fpreal64 d);
93 
94  // Updates: Matrix += v * vT
95  void outerproductUpdate(const UT_Vector4 &v);
96  void outerproductUpdate(fpreal64 a, fpreal64 b, fpreal64 c,
97  fpreal64 d);
98 
99  // Calculates vT * Matrix * v
100  T vQv(const UT_Vector4 &v);
101  T vQv(const UT_Vector3 &v);
102 
103  template <typename S>
104  friend class UT_Matrix4T;
105 
106 private:
107  T q00, q01, q02, q03, q11, q12, q13, q22;
108  T q23, q33;
109 };
110 
111 // SymMatrix is traditionally doubles.
115 #endif
UT_SymMatrix4T< T > & operator+=(T c)
Definition: UT_SymMatrix4.h:65
const GLdouble * v
Definition: glcorearb.h:837
UT_SymMatrix4T< fpreal64 > UT_SymMatrix4D
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
#define UT_API
Definition: UT_API.h:14
Symmetric 4x4 Matrices.
Definition: UT_SymMatrix4.h:19
UT_SymMatrix4T< fpreal32 > UT_SymMatrix4F
UT_SymMatrix4T< T > & operator*=(T scale)
Definition: UT_SymMatrix4.h:50
void addScaledIdentity(T scale)
Definition: UT_SymMatrix4.h:59
double fpreal64
Definition: SYS_Types.h:201
GA_API const UT_StringHolder scale
T getEuclideanNorm2() const
Definition: UT_SymMatrix4.h:79
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
UT_SymMatrix4T< T > & operator+=(const UT_SymMatrix4T< T > &m)
Definition: UT_SymMatrix4.h:41
UT_SymMatrix4T< fpreal64 > UT_SymMatrix4