OLD | NEW |
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 | 4 |
5 part of "math.dart"; | 5 part of "dart:math"; |
6 | 6 |
7 /** | 7 /** |
8 * A utility class for representing two-dimensional positions. | 8 * A utility class for representing two-dimensional positions. |
9 */ | 9 */ |
10 class Point<T extends num> { | 10 class Point<T extends num> { |
11 final T x; | 11 final T x; |
12 final T y; | 12 final T y; |
13 | 13 |
14 const Point(T x, T y) | 14 const Point(T x, T y) |
15 : this.x = x, | 15 : this.x = x, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 * | 83 * |
84 * Squared distances can be used for comparisons when the actual value is not | 84 * Squared distances can be used for comparisons when the actual value is not |
85 * required. | 85 * required. |
86 */ | 86 */ |
87 T squaredDistanceTo(Point<T> other) { | 87 T squaredDistanceTo(Point<T> other) { |
88 var dx = x - other.x; | 88 var dx = x - other.x; |
89 var dy = y - other.y; | 89 var dy = y - other.y; |
90 return dx * dx + dy * dy; | 90 return dx * dx + dy * dy; |
91 } | 91 } |
92 } | 92 } |
OLD | NEW |