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

Unified Diff: tools/dom/src/Point.dart

Issue 21619004: Add magnitude getter to Point. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/point_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/Point.dart
diff --git a/tools/dom/src/Point.dart b/tools/dom/src/Point.dart
index 366cae055aadaabc000d0d117ce0bf58fc89d130..c5c1df8d741f0916aa5ff0bfd88439b0a4b39ecb 100644
--- a/tools/dom/src/Point.dart
+++ b/tools/dom/src/Point.dart
@@ -35,6 +35,12 @@ class Point {
}
/**
+ * Get the straight line (Euclidean) distance between the origin (0, 0) and
+ * this point.
+ */
+ num get magnitude => sqrt(x * x + y * y);
+
+ /**
* Returns the distance between two points.
*/
double distanceTo(Point other) {
« no previous file with comments | « tests/html/point_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698