OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_GFX_MATRIX3_F_H_ | |
6 #define UI_GFX_MATRIX3_F_H_ | |
7 | |
8 #include "ui/gfx/vector3d_f.h" | |
9 | |
10 namespace gfx { | |
11 | |
12 class UI_EXPORT Matrix3F { | |
13 public: | |
14 typedef float ScalarType; | |
15 typedef Vector3dF VectorType; | |
16 | |
17 Matrix3F(const Matrix3F& rhs); | |
18 ~Matrix3F(); | |
19 | |
20 bool IsEqual(const Matrix3F& rhs) const; | |
21 | |
22 // Element-wise comparison with given precision. A convenience method | |
23 // primairly intended for unit tests. | |
24 bool IsNear(const Matrix3F& rhs, ScalarType precision) const; | |
danakj
2013/01/31 22:38:30
nit: primarily
If this is just for tests, can you
motek.
2013/01/31 23:29:56
On the second thought: I may actually need it in p
| |
25 | |
26 ScalarType get(int i, int j) const; | |
27 void set(int i, int j, ScalarType v); | |
28 void set(ScalarType v); | |
29 void set(ScalarType m00, ScalarType m01, ScalarType m02, | |
30 ScalarType m10, ScalarType m11, ScalarType m12, | |
31 ScalarType m20, ScalarType m21, ScalarType m22); | |
32 | |
33 VectorType GetColumn(int i) const; | |
34 void SetColumn(int i, const VectorType& c); | |
35 | |
36 // Returns an inverse of this if the matrix is non-singular, zero (== Zero()) | |
37 // otherwise. | |
38 Matrix3F Inverse() const; | |
39 | |
40 // Value of the determinant of the matrix. | |
41 ScalarType Determinant() const; | |
42 | |
43 // Trace (sum of diagonal elements) of the matrix. | |
44 ScalarType Trace() const; | |
45 | |
46 // Compute eigenvalues and (optionally) normalized eigenvectors of | |
47 // a positive defnite matrix *this. Eigenvectors are computed only if | |
48 // non-null |eigenvectors| matrix is passed. If it is NULL, the routine | |
49 // will not attempt to compute eigenvectors but will still return eigenvalues | |
50 // if they can be computed. | |
51 // If eigenvalues cannot be computed (the matrix does not meet constraints) | |
52 // the 0-vector is returned. Note that to retrieve eigenvalues, the matrix | |
53 // only needs to be symmetric while eigenvectors require it to be | |
54 // positive-definite. Passing a non-positive definite matrix will result in | |
55 // NaNs in vectors which cannot be computed. | |
56 // Eigenvectors are placed as column in |eigenvectors| in order corresponding | |
57 // to eigenvalues. | |
58 VectorType SolveEigenproblem(Matrix3F* eigenvectors) const; | |
59 | |
60 static Matrix3F Zeros(); | |
61 static Matrix3F Ones(); | |
62 static Matrix3F Identity(); | |
63 static Matrix3F FromOuterProduct(const VectorType& a, const VectorType& bt); | |
64 | |
65 private: | |
66 ScalarType data_[9]; | |
67 | |
68 Matrix3F(); // Uninitialized default. | |
69 }; | |
70 | |
71 inline bool operator==(const Matrix3F& lhs, const Matrix3F& rhs) { | |
72 return lhs.IsEqual(rhs); | |
73 } | |
74 | |
75 } // namespace gfx | |
76 | |
77 #endif // UI_GFX_MATRIX3_F_H_ | |
OLD | NEW |