| OLD | NEW |
| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * @param {!CSSMatrix} rotationMatrix | 192 * @param {!CSSMatrix} rotationMatrix |
| 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.radiansTo
Degrees(alpha), WebInspector.Geometry.radiansToDegrees(beta), WebInspector.Geome
try.radiansToDegrees(gamma)); |
| 201 } |
| 202 |
| 203 WebInspector.Geometry.EulerAngles.prototype = { |
| 204 /** |
| 205 * @return {string} |
| 206 */ |
| 207 toRotate3DString: function() |
| 208 { |
| 209 var gammaAxisY = Math.sin(WebInspector.Geometry.degreesToRadians(this.be
ta)); |
| 210 var gammaAxisZ = Math.cos(WebInspector.Geometry.degreesToRadians(this.be
ta)); |
| 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 } |
| 201 } | 220 } |
| 202 | 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; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 */ | 276 */ |
| 258 WebInspector.Geometry.calculateAngle = function(u, v) | 277 WebInspector.Geometry.calculateAngle = function(u, v) |
| 259 { | 278 { |
| 260 var uLength = u.length(); | 279 var uLength = u.length(); |
| 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.radiansToDegrees(Math.acos(cos)); |
| 287 } |
| 288 |
| 289 /** |
| 290 * @param {number} deg |
| 291 * @return {number} |
| 292 */ |
| 293 WebInspector.Geometry.degreesToRadians = function(deg) |
| 294 { |
| 295 return deg * Math.PI / 180; |
| 268 } | 296 } |
| 269 | 297 |
| 270 /** | 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.radiansToDegrees = 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 |
| 281 * @param {!Array.<number>} points | 309 * @param {!Array.<number>} points |
| 282 * @param {{minX: number, maxX: number, minY: number, maxY: number}=} aggregateB
ounds | 310 * @param {{minX: number, maxX: number, minY: number, maxY: number}=} aggregateB
ounds |
| 283 * @return {!{minX: number, maxX: number, minY: number, maxY: number}} | 311 * @return {!{minX: number, maxX: number, minY: number, maxY: number}} |
| 284 */ | 312 */ |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |