/** * Computes the reflected segment at a point of a curve * @param x1 Starting point of the segment * @param y1 Starting point of the segment * @param xi Intersection of the segment with the curve acting as a mirror * @param yi Intersection of the segment with the curve acting as a mirror * @param nx Normal of the curve at the point of intersection * @param ny Normal of the curve at the point of intersection * @return Reflected segment (has the same norm as the falling segment) */ public Point2D.Double reflection(int x1, int y1, int xi, int yi, double nx, double ny ) { double rx, ry; double dot = (xi-x1)*nx+(yi-y1)*ny; rx = (xi-x1)-2*nx*dot; ry = (yi-y1)-2*ny*dot; return new Point2D.Double(rx,ry); }