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

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

Issue 649203003: Type conversion fixes, ui/gfx/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 6 years, 1 month 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 | « ui/gfx/geometry/insets.h ('k') | ui/gfx/geometry/point.h » ('j') | 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/geometry/matrix3_f.h" 5 #include "ui/gfx/geometry/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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return true; 98 return true;
99 } 99 }
100 100
101 Matrix3F Matrix3F::Inverse() const { 101 Matrix3F Matrix3F::Inverse() const {
102 Matrix3F inverse = Matrix3F::Zeros(); 102 Matrix3F inverse = Matrix3F::Zeros();
103 double determinant = Determinant3x3(data_); 103 double determinant = Determinant3x3(data_);
104 if (std::numeric_limits<float>::epsilon() > std::abs(determinant)) 104 if (std::numeric_limits<float>::epsilon() > std::abs(determinant))
105 return inverse; // Singular matrix. Return Zeros(). 105 return inverse; // Singular matrix. Return Zeros().
106 106
107 inverse.set( 107 inverse.set(
108 (data_[M11] * data_[M22] - data_[M12] * data_[M21]) / determinant, 108 static_cast<float>((data_[M11] * data_[M22] - data_[M12] * data_[M21]) /
109 (data_[M02] * data_[M21] - data_[M01] * data_[M22]) / determinant, 109 determinant),
110 (data_[M01] * data_[M12] - data_[M02] * data_[M11]) / determinant, 110 static_cast<float>((data_[M02] * data_[M21] - data_[M01] * data_[M22]) /
111 (data_[M12] * data_[M20] - data_[M10] * data_[M22]) / determinant, 111 determinant),
112 (data_[M00] * data_[M22] - data_[M02] * data_[M20]) / determinant, 112 static_cast<float>((data_[M01] * data_[M12] - data_[M02] * data_[M11]) /
113 (data_[M02] * data_[M10] - data_[M00] * data_[M12]) / determinant, 113 determinant),
114 (data_[M10] * data_[M21] - data_[M11] * data_[M20]) / determinant, 114 static_cast<float>((data_[M12] * data_[M20] - data_[M10] * data_[M22]) /
115 (data_[M01] * data_[M20] - data_[M00] * data_[M21]) / determinant, 115 determinant),
116 (data_[M00] * data_[M11] - data_[M01] * data_[M10]) / determinant); 116 static_cast<float>((data_[M00] * data_[M22] - data_[M02] * data_[M20]) /
117 determinant),
118 static_cast<float>((data_[M02] * data_[M10] - data_[M00] * data_[M12]) /
119 determinant),
120 static_cast<float>((data_[M10] * data_[M21] - data_[M11] * data_[M20]) /
121 determinant),
122 static_cast<float>((data_[M01] * data_[M20] - data_[M00] * data_[M21]) /
123 determinant),
124 static_cast<float>((data_[M00] * data_[M11] - data_[M01] * data_[M10]) /
125 determinant));
117 return inverse; 126 return inverse;
118 } 127 }
119 128
120 float Matrix3F::Determinant() const { 129 float Matrix3F::Determinant() const {
121 return static_cast<float>(Determinant3x3(data_)); 130 return static_cast<float>(Determinant3x3(data_));
122 } 131 }
123 132
124 Vector3dF Matrix3F::SolveEigenproblem(Matrix3F* eigenvectors) const { 133 Vector3dF Matrix3F::SolveEigenproblem(Matrix3F* eigenvectors) const {
125 // The matrix must be symmetric. 134 // The matrix must be symmetric.
126 const float epsilon = std::numeric_limits<float>::epsilon(); 135 const float epsilon = std::numeric_limits<float>::epsilon();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // Normalize. 237 // Normalize.
229 eigvec.Scale(1.0f / eigvec.Length()); 238 eigvec.Scale(1.0f / eigvec.Length());
230 eigenvectors->set_column(i, eigvec); 239 eigenvectors->set_column(i, eigvec);
231 } 240 }
232 } 241 }
233 242
234 return Vector3dF(eigenvalues[0], eigenvalues[1], eigenvalues[2]); 243 return Vector3dF(eigenvalues[0], eigenvalues[1], eigenvalues[2]);
235 } 244 }
236 245
237 } // namespace gfx 246 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/insets.h ('k') | ui/gfx/geometry/point.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698