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

Side by Side Diff: tracing/tracing/base/math/math.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase Created 3 years, 9 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 | « tracing/tracing/base/math/bbox2_test.html ('k') | tracing/tracing/base/math/math_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. 3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 <link rel="import" href="/tracing/base/base.html"> 7 <link rel="import" href="/tracing/base/base.html">
8 <script src="/gl-matrix-min.js"></script> 8 <script src="/gl-matrix-min.js"></script>
9 9
10 <script> 10 <script>
(...skipping 12 matching lines...) Expand all
23 for (var exportName in glMatrixModule) { 23 for (var exportName in glMatrixModule) {
24 global[exportName] = glMatrixModule[exportName]; 24 global[exportName] = glMatrixModule[exportName];
25 } 25 }
26 } 26 }
27 })(this); 27 })(this);
28 </script> 28 </script>
29 29
30 <script> 30 <script>
31 'use strict'; 31 'use strict';
32 32
33 tr.exportTo('tr.b', function() { 33 tr.exportTo('tr.b.math', function() {
34 var PREFERRED_NUMBER_SERIES_MULTIPLIERS = [1, 2, 5, 10]; 34 var PREFERRED_NUMBER_SERIES_MULTIPLIERS = [1, 2, 5, 10];
35 35
36 /* Returns true when x and y are within delta of each other. */ 36 /* Returns true when x and y are within delta of each other. */
37 function approximately(x, y, delta) { 37 function approximately(x, y, delta) {
38 if (delta === undefined) 38 if (delta === undefined)
39 delta = 1e-9; 39 delta = 1e-9;
40 return Math.abs(x - y) < delta; 40 return Math.abs(x - y) < delta;
41 } 41 }
42 42
43 function clamp(x, lo, hi) { 43 function clamp(x, lo, hi) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 /** 209 /**
210 * Uses the 1-2-5 series to find the closest prefered number to min 210 * Uses the 1-2-5 series to find the closest prefered number to min
211 * whose absolute value is at least the absolute value of |min|. 211 * whose absolute value is at least the absolute value of |min|.
212 * https://en.wikipedia.org/wiki/Preferred_number 212 * https://en.wikipedia.org/wiki/Preferred_number
213 */ 213 */
214 function preferredNumberLargerThanMin(min) { 214 function preferredNumberLargerThanMin(min) {
215 var absMin = Math.abs(min); 215 var absMin = Math.abs(min);
216 // The conservative guess is the largest power of 10 less than 216 // The conservative guess is the largest power of 10 less than
217 // or equal to |absMin|. 217 // or equal to |absMin|.
218 var conservativeGuess = tr.b.lesserPower(absMin); 218 var conservativeGuess = tr.b.math.lesserPower(absMin);
219 var minPreferedNumber = undefined; 219 var minPreferedNumber = undefined;
220 for (var multiplier of PREFERRED_NUMBER_SERIES_MULTIPLIERS) { 220 for (var multiplier of PREFERRED_NUMBER_SERIES_MULTIPLIERS) {
221 var tightenedGuess = conservativeGuess * multiplier; 221 var tightenedGuess = conservativeGuess * multiplier;
222 if (tightenedGuess >= absMin) { 222 if (tightenedGuess >= absMin) {
223 minPreferedNumber = tightenedGuess; 223 minPreferedNumber = tightenedGuess;
224 break; 224 break;
225 } 225 }
226 } 226 }
227 if (minPreferedNumber === undefined) { 227 if (minPreferedNumber === undefined) {
228 throw new Error('Could not compute preferred number for ' + min); 228 throw new Error('Could not compute preferred number for ' + min);
(...skipping 10 matching lines...) Expand all
239 deg2rad, 239 deg2rad,
240 erf, 240 erf,
241 lesserPower, 241 lesserPower,
242 greaterPower, 242 greaterPower,
243 lesserWholeNumber, 243 lesserWholeNumber,
244 greaterWholeNumber, 244 greaterWholeNumber,
245 preferredNumberLargerThanMin, 245 preferredNumberLargerThanMin,
246 }; 246 };
247 }); 247 });
248 </script> 248 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/base/math/bbox2_test.html ('k') | tracing/tracing/base/math/math_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698