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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/Geometry.js

Issue 1975723003: DevTools: fix janky transition in sensors panel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 * @return {!WebInspector.Geometry.EulerAngles} 193 * @return {!WebInspector.Geometry.EulerAngles}
194 */ 194 */
195 WebInspector.Geometry.EulerAngles.fromRotationMatrix = function(rotationMatrix) 195 WebInspector.Geometry.EulerAngles.fromRotationMatrix = function(rotationMatrix)
196 { 196 {
197 var beta = Math.atan2(rotationMatrix.m23, rotationMatrix.m33); 197 var beta = Math.atan2(rotationMatrix.m23, rotationMatrix.m33);
198 var gamma = Math.atan2(-rotationMatrix.m13, Math.sqrt(rotationMatrix.m11 * r otationMatrix.m11 + rotationMatrix.m12 * rotationMatrix.m12)); 198 var gamma = Math.atan2(-rotationMatrix.m13, Math.sqrt(rotationMatrix.m11 * r otationMatrix.m11 + rotationMatrix.m12 * rotationMatrix.m12));
199 var alpha = Math.atan2(rotationMatrix.m12, rotationMatrix.m11); 199 var alpha = Math.atan2(rotationMatrix.m12, rotationMatrix.m11);
200 return new WebInspector.Geometry.EulerAngles(WebInspector.Geometry.radToDeg( alpha), WebInspector.Geometry.radToDeg(beta), WebInspector.Geometry.radToDeg(gam ma)); 200 return new WebInspector.Geometry.EulerAngles(WebInspector.Geometry.radToDeg( alpha), WebInspector.Geometry.radToDeg(beta), WebInspector.Geometry.radToDeg(gam ma));
201 } 201 }
202 202
203 WebInspector.Geometry.EulerAngles.prototype = {
204 /**
205 * @return {string}
206 */
207 toRotate3DString: function()
208 {
209 var gammaAxisY = Math.sin(WebInspector.Geometry.degToRad(this.beta));
210 var gammaAxisZ = Math.cos(WebInspector.Geometry.degToRad(this.beta));
211 var axis = {
212 alpha: [0, -1, 0],
213 beta: [1, 0, 0],
214 gamma: [0, gammaAxisY, gammaAxisZ]
215 };
216 return "rotate3d(" + axis.alpha.join(",") + "," + this.alpha + "deg) "
217 + "rotate3d(" + axis.beta.join(",") + "," + this.beta + "deg) "
218 + "rotate3d(" + axis.gamma.join(",") + "," + this.gamma + "deg)";
219 }
220 }
221
203 /** 222 /**
204 * @param {!WebInspector.Geometry.Vector} u 223 * @param {!WebInspector.Geometry.Vector} u
205 * @param {!WebInspector.Geometry.Vector} v 224 * @param {!WebInspector.Geometry.Vector} v
206 * @return {number} 225 * @return {number}
207 */ 226 */
208 WebInspector.Geometry.scalarProduct = function(u, v) 227 WebInspector.Geometry.scalarProduct = function(u, v)
209 { 228 {
210 return u.x * v.x + u.y * v.y + u.z * v.z; 229 return u.x * v.x + u.y * v.y + u.z * v.z;
211 } 230 }
212 231
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 var vLength = v.length(); 280 var vLength = v.length();
262 if (uLength <= WebInspector.Geometry._Eps || vLength <= WebInspector.Geometr y._Eps) 281 if (uLength <= WebInspector.Geometry._Eps || vLength <= WebInspector.Geometr y._Eps)
263 return 0; 282 return 0;
264 var cos = WebInspector.Geometry.scalarProduct(u, v) / uLength / vLength; 283 var cos = WebInspector.Geometry.scalarProduct(u, v) / uLength / vLength;
265 if (Math.abs(cos) > 1) 284 if (Math.abs(cos) > 1)
266 return 0; 285 return 0;
267 return WebInspector.Geometry.radToDeg(Math.acos(cos)); 286 return WebInspector.Geometry.radToDeg(Math.acos(cos));
268 } 287 }
269 288
270 /** 289 /**
290 * @param {number} deg
291 * @return {number}
292 */
293 WebInspector.Geometry.degToRad = function(deg)
lushnikov 2016/05/16 21:51:08 .toRadians = We avoid abbreviations as much as p
luoe 2016/05/16 22:15:56 Sounds good. I was trying to match the style of "
294 {
295 return deg * Math.PI / 180;
296 }
297
298 /**
271 * @param {number} rad 299 * @param {number} rad
272 * @return {number} 300 * @return {number}
273 */ 301 */
274 WebInspector.Geometry.radToDeg = function(rad) 302 WebInspector.Geometry.radToDeg = function(rad)
275 { 303 {
276 return rad * 180 / Math.PI; 304 return rad * 180 / Math.PI;
277 } 305 }
278 306
279 /** 307 /**
280 * @param {!CSSMatrix} matrix 308 * @param {!CSSMatrix} matrix
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 /** 521 /**
494 * @param {!Constraints|number} value 522 * @param {!Constraints|number} value
495 * @return {!Constraints} 523 * @return {!Constraints}
496 */ 524 */
497 Constraints.prototype.addHeight = function(value) 525 Constraints.prototype.addHeight = function(value)
498 { 526 {
499 if (typeof value === "number") 527 if (typeof value === "number")
500 return new Constraints(this.minimum.addHeight(value), this.preferred.add Height(value)); 528 return new Constraints(this.minimum.addHeight(value), this.preferred.add Height(value));
501 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred .addHeight(value.preferred)); 529 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred .addHeight(value.preferred));
502 } 530 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698