Chromium Code Reviews| 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(const VectorType& a, const VectorType& bt); | |
|
Alexei Svitkine (slow)
2013/01/31 20:02:38
This is the outer-product right?
Consider making
motek.
2013/01/31 22:00:24
Done.
| |
| 19 ~Matrix3F(); | |
| 20 | |
| 21 bool IsEqual(const Matrix3F& rhs) const; | |
| 22 | |
| 23 // Element-wise comparison with given precision. A convenience method | |
| 24 // primairly intended for unit tests. | |
| 25 bool IsNear(const Matrix3F& rhs, ScalarType precision) const; | |
| 26 | |
| 27 ScalarType get(int i, int j) const; | |
| 28 void set(int i, int j, ScalarType v); | |
| 29 void set(ScalarType v); | |
| 30 void set(ScalarType m00, ScalarType m01, ScalarType m02, | |
| 31 ScalarType m10, ScalarType m11, ScalarType m12, | |
| 32 ScalarType m20, ScalarType m21, ScalarType m22); | |
| 33 | |
| 34 VectorType GetColumn(int i) const; | |
| 35 void SetColumn(int i, const VectorType& c); | |
| 36 | |
| 37 // Returns an inverse of this if the matrix is non-singular, zero (== Zero()) | |
| 38 // otherwise. | |
| 39 Matrix3F Inverse() const; | |
| 40 | |
| 41 // Value of the determinant of the matrix. | |
| 42 ScalarType Determinant() const; | |
| 43 | |
| 44 // Trace (sum of diagonal elements) of the matrix. | |
| 45 ScalarType Trace() const; | |
| 46 | |
| 47 // Compute eigenvalues and (optionally) normalized eigenvectors of | |
| 48 // a positive defnite matrix *this. Eigenvectors are computed only if | |
| 49 // non-null |eigenvectors| matrix is passed. If it is NULL, the routine | |
| 50 // will not attempt to compute eigenvectors but will still return eigenvalues | |
| 51 // if they can be computed. | |
| 52 // If eigenvalues cannot be computed (the matrix does not meet constraints) | |
| 53 // the 0-vector is returned. Note that to retrieve eigenvalues, the matrix | |
| 54 // only needs to be symmetric while eigenvectors require it to be | |
| 55 // positive-definite. Passing a non-positive definite matrix will result in | |
| 56 // NaNs in vectors which cannot be computed. | |
| 57 // Eigenvectors are placed as column in |eigenvectors| in order corresponding | |
| 58 // to eigenvalues. | |
| 59 VectorType SolveEigenproblem(Matrix3F* eigenvectors) const; | |
| 60 | |
| 61 static Matrix3F Zeros(); | |
| 62 static Matrix3F Ones(); | |
| 63 static Matrix3F Identity(); | |
| 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 |