Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: ui/gfx/matrix3_f.cc

Issue 22886002: Fix Matrix3F::SolveEigenproblem symmetry check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/matrix3_f.h" 5 #include "ui/gfx/matrix3_f.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 float Matrix3F::Determinant() const { 120 float Matrix3F::Determinant() const {
121 return static_cast<float>(Determinant3x3(data_)); 121 return static_cast<float>(Determinant3x3(data_));
122 } 122 }
123 123
124 Vector3dF Matrix3F::SolveEigenproblem(Matrix3F* eigenvectors) const { 124 Vector3dF Matrix3F::SolveEigenproblem(Matrix3F* eigenvectors) const {
125 // The matrix must be symmetric. 125 // The matrix must be symmetric.
126 const float epsilon = std::numeric_limits<float>::epsilon(); 126 const float epsilon = std::numeric_limits<float>::epsilon();
127 if (std::abs(data_[M01] - data_[M10]) > epsilon || 127 if (std::abs(data_[M01] - data_[M10]) > epsilon ||
128 std::abs(data_[M02] - data_[M02]) > epsilon || 128 std::abs(data_[M02] - data_[M20]) > epsilon ||
129 std::abs(data_[M12] - data_[M21]) > epsilon) { 129 std::abs(data_[M12] - data_[M21]) > epsilon) {
130 NOTREACHED(); 130 NOTREACHED();
131 return Vector3dF(); 131 return Vector3dF();
132 } 132 }
133 133
134 float eigenvalues[3]; 134 float eigenvalues[3];
135 float p = 135 float p =
136 data_[M01] * data_[M01] + 136 data_[M01] * data_[M01] +
137 data_[M02] * data_[M02] + 137 data_[M02] * data_[M02] +
138 data_[M12] * data_[M12]; 138 data_[M12] * data_[M12];
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // Normalize. 228 // Normalize.
229 eigvec.Scale(1.0f / eigvec.Length()); 229 eigvec.Scale(1.0f / eigvec.Length());
230 eigenvectors->set_column(i, eigvec); 230 eigenvectors->set_column(i, eigvec);
231 } 231 }
232 } 232 }
233 233
234 return Vector3dF(eigenvalues[0], eigenvalues[1], eigenvalues[2]); 234 return Vector3dF(eigenvalues[0], eigenvalues[1], eigenvalues[2]);
235 } 235 }
236 236
237 } // namespace gfx 237 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698