Mercurial > projects > doodle
diff doodle/tk/geometry.d @ 66:43cc2135ced0
Some code cleanups
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Thu, 12 Aug 2010 22:43:42 +0930 |
parents | 6c3993f4c3eb |
children | 31d10176415d |
line wrap: on
line diff
--- a/doodle/tk/geometry.d Thu Aug 12 22:24:28 2010 +0930 +++ b/doodle/tk/geometry.d Thu Aug 12 22:43:42 2010 +0930 @@ -140,9 +140,9 @@ } /* - static Rectangle from_arbitrary_corners(in Point corner1, in Point corner) { - } - */ + static Rectangle from_arbitrary_corners(in Point corner1, in Point corner) { + } + */ this(in Point position, in Vector size) { this(position.x, position.y, size.x, size.y); @@ -236,8 +236,8 @@ return Rectangle(r.position + displacement, r.size); } -Rectangle reposition(in Rectangle r, in Point new_position) { - return Rectangle(new_position, r.size); +Rectangle reposition(in Rectangle r, in Point newPosition) { + return Rectangle(newPosition, r.size); } Rectangle resize(in Rectangle r, in Vector new_size) { @@ -277,7 +277,7 @@ // // Influenced by http://ozviz.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ bool computeIntersection(in Point pa1, in Point pa2, out double ua, - in Point pb1, in Point pb2, out double ub) { + in Point pb1, in Point pb2, out double ub) { double den = (pb2.y - pb1.y) * (pa2.x - pa1.x) - (pb2.x - pb1.x) * (pa2.y - pa1.y); if (abs(den) < 1e-9) { // TODO consolidate constants used for numerical stability @@ -287,19 +287,19 @@ } else { // It will be safe to divide by den - double num_a = (pb2.x - pb1.x) * (pa1.y - pb1.y) - (pb2.y - pb1.y) * (pa1.x - pb1.x); - double num_b = (pa2.x - pa1.x) * (pa1.y - pb1.y) - (pa2.y - pa1.y) * (pa1.x - pb1.x); + double numA = (pb2.x - pb1.x) * (pa1.y - pb1.y) - (pb2.y - pb1.y) * (pa1.x - pb1.x); + double numB = (pa2.x - pa1.x) * (pa1.y - pb1.y) - (pa2.y - pa1.y) * (pa1.x - pb1.x); - ua = num_a / den; - ub = num_b / den; + ua = numA / den; + ub = numB / den; return true; } } /+ - double compute_angle(in Point p1, in Point p2) { - } + double compute_angle(in Point p1, in Point p2) { + } +/ }