![]() |
The main property of the reflected line is that the angle between it and the normal is the same as the angle between the incident line and the normal. The slope of the reflected line will be: φr = 2φ - φi where φ is the slope of the line upon which the incident line falls and φi is the slope of the incident line. If you do have the bare slopes, the above equation gives you immediately the reflected line. Let's suppose you instead have two non-vertical lines y = ax+b and y = aix+bi where the second line is the incident line. We want to calculate the equation of the reflected y = arx+br line at the point of intersection. There are three cases: 1) a = ±1 and ai = 0
2) a = ±1 and ai ≠ 0
3) In the rest of the cases |
![]() |
The normal of the curve at a specific point is the same as the normal of the tangent line of the curve at that point. And the tangent line is (for a smooth curve):
The reflected line will be the same as if the incident line was colliding with the above tangent line instead of the curve. This allows to reduce this case to the previous one. If you have a parametric curve equation, then remember that
|
The applet below shows this in practice. Use the LEFT mouse button to select a point on the curve (you need not click exactly on the curve, as the closest point will be automatically determined), and use the RIGHT mouse button to select a point from which to shoot an incident line. The applet will automatically determine the normal, tangent and reflected lines. Click here to donwload the source code of the applet. GPL License.
More often than not, you need to know the reflection of a segment rather than a line, and this means that you need to take account how long the segment is and in which direction it falls on the dividing line:
The formula for the reflected vector is r = v - 2 (v.n)n, where n is the unitary normal vector at the point of intersection. For a graphcial explanation of this formula, see these figures:
Writing the above vector equation in cartesian coordinates, we have:
The following Java function computes the reflected segment at a point of a curve, given an intersection point and the normal at that point:
0001 /** 0002 * Computes the reflected segment at a point of a curve 0003 * @param x1 Starting point of the segment 0004 * @param y1 Starting point of the segment 0005 * @param xi Intersection of the segment with the curve acting as a mirror 0006 * @param yi Intersection of the segment with the curve acting as a mirror 0007 * @param nx Normal of the curve at the point of intersection 0008 * @param ny Normal of the curve at the point of intersection 0009 * @return Reflected segment (has the same norm as the falling segment) 0010 */ 0011 public Point2D.Double reflection(int x1, int y1, int xi, int yi, double nx, double ny ) { 0012 double rx, ry; 0013 double dot = (xi-x1)*nx+(yi-y1)*ny; 0014 rx = (xi-x1)-2*nx*dot; 0015 ry = (yi-y1)-2*ny*dot; 0016 return new Point2D.Double(rx,ry); 0017 } 0018
|
reflected-segment.java ( 783 bytes ) |