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

Side by Side Diff: dart/sdk/lib/math/point.dart

Issue 66253002: Version 0.8.10.9 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 part of dart.math; 4 part of dart.math;
5 5
6 /** 6 /**
7 * A utility class for representing two-dimensional positions. 7 * A utility class for representing two-dimensional positions.
8 */ 8 */
9 class Point<T extends num> { 9 class Point<T extends num> {
10 final T x; 10 final T x;
11 final T y; 11 final T y;
12 12
13 const Point([T x = 0, T y = 0]): this.x = x, this.y = y; 13 const Point(T x, T y): this.x = x, this.y = y;
14 14
15 String toString() => 'Point($x, $y)'; 15 String toString() => 'Point($x, $y)';
16 16
17 bool operator ==(other) { 17 bool operator ==(other) {
18 if (other is !Point) return false; 18 if (other is !Point) return false;
19 return x == other.x && y == other.y; 19 return x == other.x && y == other.y;
20 } 20 }
21 21
22 int get hashCode => _JenkinsSmiHash.hash2(x.hashCode, y.hashCode); 22 int get hashCode => _JenkinsSmiHash.hash2(x.hashCode, y.hashCode);
23 23
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 * 72 *
73 * Squared distances can be used for comparisons when the actual value is not 73 * Squared distances can be used for comparisons when the actual value is not
74 * required. 74 * required.
75 */ 75 */
76 T squaredDistanceTo(Point<T> other) { 76 T squaredDistanceTo(Point<T> other) {
77 var dx = x - other.x; 77 var dx = x - other.x;
78 var dy = y - other.y; 78 var dy = y - other.y;
79 return dx * dx + dy * dy; 79 return dx * dx + dy * dy;
80 } 80 }
81 } 81 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/html/dartium/html_dartium.dart ('k') | dart/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698