- public Vec getUnit() {
- Point p1 = new Point(0, c, d);
- Point p2 = new Point(1, m+c, n+d);
- return p2.minus(p1).norm();
+ public AffineConstraint intersect(AffineConstraint con, float epsilon) {
+ if (!(con instanceof Line)) return con.intersect(this, epsilon);
+ Line line = (Line)con;
+ if (Math.abs(this.m-line.m) <= epsilon &&
+ Math.abs(this.n-line.n) <= epsilon &&
+ Math.abs(this.c-line.c) <= epsilon &&
+ Math.abs(this.d-line.d) <= epsilon)
+ return this;
+ float x = (line.c-this.c)/(this.m-line.m);
+ if (Math.abs( (m*x+c)-(line.m*x+line.c) ) > epsilon ) return null;
+ if (Math.abs( (n*x+d)-(line.n*x+line.d) ) > epsilon ) return null;
+ return new Point(x, m*x+c, n*x+d);
+ }
+
+ public AffineConstraint multiply(Matrix m) {
+ throw new RuntimeException("not yet implemented");