added mpardemo
[slipway.git] / src / edu / berkeley / slipway / gui / R.java
index fcc75c5..0296bd5 100644 (file)
@@ -7,6 +7,7 @@ import static com.atmel.fpslic.FpslicConstants.*;
 public class R {
 
     private double x1, x2, y1, y2;
+    public R(P p1, P p2) { this(p1.x, p1.y, p2.x, p2.y); }
     public R(double x1, double y1, double x2, double y2) {
         this.x1 = x1;
         this.x2 = x2;
@@ -59,4 +60,11 @@ public class R {
             default: return null;
         }
     }
+
+    public boolean within(R r) {
+        return minx() >= r.minx()
+            && miny() >= r.miny()
+            && maxx() <= r.maxx()
+            && maxy() <= r.maxy();
+    }
 }
\ No newline at end of file