@Test public void contains() throws Exception { aStart = GeometryFactory.createVector(5,5); aDirection = GeometryFactory.createVector(1,0); a = GeometryFactory.createRay2D(aStart, aDirection); point = GeometryFactory.createVector(7,0); assertFalse(a.contains(point)); point = GeometryFactory.createVector(7,5); assertTrue(a.contains(point)); point = GeometryFactory.createVector(4,5); assertFalse(a.contains(point)); aStart = GeometryFactory.createVector(0,0); aDirection = GeometryFactory.createVector(0,1); a = GeometryFactory.createRay2D(aStart, aDirection); point = GeometryFactory.createVector(0,1); assertTrue(a.contains(point)); point = GeometryFactory.createVector(0,-2); assertFalse(a.contains(point)); aStart = GeometryFactory.createVector(1,0); aDirection = GeometryFactory.createVector(1,1); a = GeometryFactory.createRay2D(aStart, aDirection); point = GeometryFactory.createVector(3,2); assertTrue(a.contains(point)); point = GeometryFactory.createVector(0,-1); assertFalse(a.contains(point)); }
public boolean contains(Vector2D point) { Vector2D newNorm = point.subtract(this.getStart()).getNormalized(); double dotProduct = newNorm.dot(this.getDirection().getNormalized()); return Math.abs(1.0 - dotProduct) < EPSILON; }
Ray2D { public boolean contains(Vector2D point) { Vector2D newNorm = point.subtract(this.getStart()).getNormalized(); double dotProduct = newNorm.dot(this.getDirection().getNormalized()); return Math.abs(1.0 - dotProduct) < EPSILON; } }
Ray2D { public boolean contains(Vector2D point) { Vector2D newNorm = point.subtract(this.getStart()).getNormalized(); double dotProduct = newNorm.dot(this.getDirection().getNormalized()); return Math.abs(1.0 - dotProduct) < EPSILON; } Ray2D(Vector2D start, Vector2D direction); }
Ray2D { public boolean contains(Vector2D point) { Vector2D newNorm = point.subtract(this.getStart()).getNormalized(); double dotProduct = newNorm.dot(this.getDirection().getNormalized()); return Math.abs(1.0 - dotProduct) < EPSILON; } Ray2D(Vector2D start, Vector2D direction); Vector2D getStart(); void setStart(Vector2D start); Vector2D getDirection(); void setDirection(Vector2D direction); Vector2D intersectionPoint(Ray2D other); Ray2D intersectionRay(Ray2D other); Segment2D intersectionSegment(Ray2D other); boolean contains(Vector2D point); boolean isParallel(Ray2D other); boolean equals(Ray2D other); String toString(); }
Ray2D { public boolean contains(Vector2D point) { Vector2D newNorm = point.subtract(this.getStart()).getNormalized(); double dotProduct = newNorm.dot(this.getDirection().getNormalized()); return Math.abs(1.0 - dotProduct) < EPSILON; } Ray2D(Vector2D start, Vector2D direction); Vector2D getStart(); void setStart(Vector2D start); Vector2D getDirection(); void setDirection(Vector2D direction); Vector2D intersectionPoint(Ray2D other); Ray2D intersectionRay(Ray2D other); Segment2D intersectionSegment(Ray2D other); boolean contains(Vector2D point); boolean isParallel(Ray2D other); boolean equals(Ray2D other); String toString();  }