Page 5
Line normals
Page 6
Index
See this article in english 
Page 7
Distance between a point and a line

Reflections and point-collisions in 2D

Alexander Hristov

Reflected line at a point of a line

Reflected line at a point

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

In this case the reflected line is x = x0

2) a = ±1 and ai ≠ 0

In this case ar = 1/ai , br = y0 - x0ar, so  the reflected line is y = x/ai + (y0 - x0/ai)

3) In the rest of the cases

Reflection equation

Reflected line at a point of a curve

Reflection at a curve

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):

Reflection at a point of a 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

Reflection equation to a parametric curve

 

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.

Reflected segment

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:

Reflection of segments

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:

reflected-segment.java
 
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
 

 

Source code



 

Comments

 

Add a Comment

Name (optional)
EMail (optional, will not be displayed)

Text